19declare(strict_types=1);
96 protected int $id = 0,
97 protected bool $referenced =
true
102 $this->
ilias = $DIC[
"ilias"];
103 $this->obj_definition =
$DIC[
"objDefinition"];
104 $this->db =
$DIC[
"ilDB"];
105 $this->log =
$DIC[
"ilLog"];
107 $this->
error = $DIC[
"ilErr"];
108 $this->tree =
$DIC[
"tree"];
109 $this->app_event_handler =
$DIC[
"ilAppEventHandler"];
110 $this->lom_services =
$DIC->learningObjectMetadata();
111 $object_dic = LocalDIC::dic();
112 $this->properties_aggregator = $object_dic[
'properties.aggregator'];
113 $this->translations_repository = $object_dic[
'properties.translations.repository'];
115 $this->call_by_reference = $this->referenced;
117 if (isset(
$DIC[
"lng"])) {
118 $this->
lng = $DIC[
"lng"];
121 if (isset(
$DIC[
"ilUser"])) {
122 $this->
user = $DIC[
"ilUser"];
125 if (isset(
$DIC[
"rbacadmin"])) {
126 $this->rbac_admin =
$DIC[
"rbacadmin"];
129 if (isset(
$DIC[
"rbacreview"])) {
130 $this->rbac_review =
$DIC[
"rbacreview"];
134 $this->referenced =
false;
137 if ($this->referenced) {
150 if ($this->object_properties ===
null) {
151 $this->object_properties = $this->properties_aggregator->getFor($this->
id, $this->type);
161 $this->object_properties =
null;
170 return ($this->call_by_reference) ?
true : $this->referenced;
179 $this->process_auto_reating =
true;
186 $ilUser =
$DIC[
"ilUser"];
187 }
catch (InvalidArgumentException
$e) {
190 if ($this->referenced) {
191 if (!isset($this->ref_id)) {
192 $message =
"ilObject::read(): No ref_id given! (" . $this->type .
")";
198 "SELECT od.obj_id, od.type, od.title, od.description, od.owner, od.create_date," . PHP_EOL
199 .
"od.last_update, od.import_id, ore.ref_id, ore.obj_id, ore.deleted, ore.deleted_by" . PHP_EOL
200 .
"FROM " . self::TABLE_OBJECT_DATA .
" od" . PHP_EOL
201 .
"JOIN object_reference ore ON od.obj_id = ore.obj_id" . PHP_EOL
202 .
"WHERE ore.ref_id = " . $this->db->quote($this->ref_id,
"integer") . PHP_EOL
205 $result = $this->db->query($sql);
208 if ($this->db->numRows($result) === 0) {
210 "ilObject::read(): Object with ref_id %s not found! (%s)",
217 if (!isset($this->
id)) {
218 $message = sprintf(
"ilObject::read(): No obj_id given! (%s)", $this->type);
223 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
224 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
225 .
"WHERE obj_id = " . $this->db->quote($this->
id,
"integer") . PHP_EOL
227 $result = $this->db->query($sql);
229 if ($this->db->numRows($result) === 0) {
230 $message = sprintf(
"ilObject::read(): Object with obj_id: %s (%s) not found!", $this->
id, $this->type);
234 $obj = $this->db->fetchAssoc($result);
236 $this->
id = (
int) $obj[
"obj_id"];
239 if ($this->type != $obj[
"type"] && $obj[
"type"] !=
"xxx") {
241 "ilObject::read(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
251 $this->type = (string) $obj[
"type"];
252 $this->title = (string) $obj[
"title"];
254 $this->untranslatedTitle = (string) $obj[
"title"];
257 $this->desc = (string) $obj[
"description"];
258 $this->owner = (
int) $obj[
"owner"];
259 $this->create_date = (string) $obj[
"create_date"];
260 $this->last_update = (string) $obj[
"last_update"];
261 $this->import_id = (string) $obj[
"import_id"];
263 if ($this->obj_definition->isRBACObject($this->getType())) {
265 "SELECT obj_id, description" . PHP_EOL
266 .
"FROM object_description" . PHP_EOL
267 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
270 $res = $this->db->query($sql);
272 $this->long_desc =
'';
274 if (($row->description ??
'') !==
'') {
281 $translation_type = $this->obj_definition->getTranslationType($this->type);
283 if ($translation_type ==
"sys") {
284 $this->title = $this->
lng->txt(
"obj_" . $this->type);
286 } elseif ($translation_type ==
"db") {
288 "SELECT title, description" . PHP_EOL
289 .
"FROM object_translation" . PHP_EOL
290 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
291 .
"AND lang_code = " . $this->db->quote($ilUser->getCurrentLanguage(),
'text') . PHP_EOL
293 $r = $this->db->query($sql);
296 $this->title = (string) $row->title;
297 $this->setDescription((
string) $row->description);
301 $this->object_properties =
null;
317 $this->referenced =
true;
322 return $this->ref_id ?? 0;
365 $this->object_properties = $this->
getObjectProperties()->withPropertyTitleAndDescription($property);
367 $this->title = $property->getTitle();
381 ->getPropertyTitleAndDescription()->withDescription($description);
383 $this->object_properties = $this->
getObjectProperties()->withPropertyTitleAndDescription($property);
386 $this->desc = $property->getDescription();
387 $this->long_desc = $property->getLongDescription();
395 if ($this->long_desc !==
'') {
399 if ($this->desc !==
'') {
425 "SELECT obj_id" . PHP_EOL
426 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
428 .
"ORDER BY create_date DESC" . PHP_EOL
438 return (
int) $row->obj_id;
448 $property_is_online = $property_is_online->withOffline();
451 $this->object_properties = $this->
getObjectProperties()->withPropertyIsOnline($property_is_online);
461 return $this->obj_definition->supportsOfflineHandling($this->
getType());
471 "SELECT import_id" . PHP_EOL
472 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
473 .
"WHERE obj_id = " .
$db->
quote($obj_id,
"integer") . PHP_EOL
478 return (
string) $row->import_id;
505 if ($owner_id != -1) {
511 $own_name =
$lng->
txt(
"unknown");
513 $own_name =
$owner->getFullname();
521 $this->owner = $usr_id;
549 if (!isset($this->type)) {
550 $message = sprintf(
"%s::create(): No object type given!", get_class($this));
554 $this->log->write(
"ilObject::create(), start");
560 } elseif (is_object(
$user)) {
564 $now_string = (
new DataFactory())->clock()->utc()->now()
565 ->format(self::DATABASE_DATE_FORMAT);
567 $this->
id = $this->db->nextId(self::TABLE_OBJECT_DATA);
569 "obj_id" => [
"integer", $this->
getId()],
570 "type" => [
"text", $this->
getType()],
571 "title" => [
"text", $this->
getTitle()],
573 "owner" => [
"integer",
$owner],
574 "create_date" => [
"date", $now_string],
575 "last_update" => [
"date", $now_string],
579 $this->db->insert(self::TABLE_OBJECT_DATA, $values);
580 $this->object_properties =
null;
583 if ($this->obj_definition->isRBACObject($this->getType())) {
588 $this->db->insert(
'object_description', $values);
596 if ($this->obj_definition->isOrgUnitPermissionType($this->type)) {
603 "SELECT last_update, create_date" . PHP_EOL
604 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
605 .
"WHERE obj_id = " . $this->db->quote($this->
id,
"integer") . PHP_EOL
607 $obj_set = $this->db->query($sql);
608 $obj_rec = $this->db->fetchAssoc($obj_set);
609 $this->last_update = $obj_rec[
"last_update"];
610 $this->create_date = $obj_rec[
"create_date"];
618 "ilObject::create(), finished, obj_id: %s, type: %s, title: %s",
625 $this->app_event_handler->raise(
626 'components/ILIAS/ILIASObject',
629 'obj_id' => $this->
id,
630 'obj_type' => $this->type
641 $this->app_event_handler->raise(
642 'components/ILIAS/ILIASObject',
645 'obj_id' => $this->
getId(),
646 'obj_type' => $this->
getType(),
666 $this->app_event_handler->raise(
667 'components/ILIAS/ILIASObject',
669 [
'obj_id' => $this->
getId(),
670 'obj_type' => $this->
getType(),
676 if ($element ==
'General') {
677 $paths = $this->lom_services->paths();
678 $reader = $this->lom_services->read(
682 $paths->custom()->withNextStep(
'general')->get()
685 $this->
setTitle($reader->firstData($paths->title())->value());
686 $this->
setDescription($reader->firstData($paths->descriptions())->value());
707 $ilUser =
$DIC[
"ilUser"];
709 $this->lom_services->derive()->fromBasicProperties(
712 $ilUser->getPref(
'language')
731 $paths = $this->lom_services->paths();
733 $manipulator = $this->lom_services->manipulate($this->
getId(), 0, $this->
getType())
734 ->prepareCreateOrUpdate($paths->title(), $this->getTitle());
737 $manipulator = $manipulator->prepareCreateOrUpdate(
738 $paths->firstDescription(),
739 $this->getLongDescription()
742 $manipulator = $manipulator->prepareDelete($paths->firstDescription());
745 $manipulator->execute();
762 $this->lom_services->deleteAll($this->
getId(), 0, $this->
getType());
782 "owner" => [
"integer", $this->
getOwner()],
785 (
new DateTimeImmutable(
'@' . time(),
new DateTimeZone(
'UTC')))
786 ->format(self::DATABASE_DATE_FORMAT)
791 "obj_id" => [
"integer", $this->
getId()]
794 $this->db->update(self::TABLE_OBJECT_DATA, $values, $where);
807 "SELECT obj_id" . PHP_EOL
808 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
810 .
"ORDER BY create_date DESC" . PHP_EOL
816 return (
int) $row[
"obj_id"];
832 "SELECT ref_id" . PHP_EOL
833 .
"FROM object_reference" . PHP_EOL
834 .
"WHERE obj_id = " .
$db->
quote(
$id,
'integer') . PHP_EOL
841 $ref[(
int) $row[
"ref_id"]] = (
int) $row[
"ref_id"];
850 return (
string)
$DIC[
"ilObjDataCache"]->lookupTitle($obj_id);
859 return $DIC[
'ilObjDataCache']->lookupOfflineStatus($obj_id);
868 return (
int)
$DIC[
"ilObjDataCache"]->lookupOwner($obj_id);
880 if ($partial_match) {
885 "SELECT obj_id" . PHP_EOL
886 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
887 .
"WHERE " . $where . PHP_EOL
898 $object_ids[] = (
int) $row[
'obj_id'];
907 return (
string)
$DIC[
"ilObjDataCache"]->lookupDescription($obj_id);
929 "SELECT MAX(last_update) as last_update" . PHP_EOL
930 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
931 .
"WHERE " .
$db->
in(
"obj_id", $obj_ids,
false,
"integer") . PHP_EOL
937 return (
string) $row[
"last_update"];
943 return $DIC[
"ilObjDataCache"]->lookupObjId(
$ref_id);
952 "deleted" => [
"date",
$db->
now()],
953 "deleted_by" => [
"integer", $deleted_by]
957 "ref_id" => [
"integer",
$ref_id]
960 $db->
update(
"object_reference", $values, $where);
972 "UPDATE object_reference" . PHP_EOL
973 .
"SET deleted = " .
$db->
now() .
", " . PHP_EOL
975 .
"WHERE " .
$db->
in(
"ref_id", $ref_ids,
false,
"integer") . PHP_EOL;
986 "deleted" => [
"timestamp",
null],
987 "deleted_by" => [
"integer", 0]
991 "ref_id" => [
"integer",
$ref_id]
994 $db->
update(
"object_reference", $values, $where);
1003 "SELECT deleted" . PHP_EOL
1004 .
"FROM object_reference" . PHP_EOL
1010 return $row[
"deleted"] ??
null;
1022 "title" => [
"text",
$title],
1023 "last_update" => [
"date",
$db->
now()]
1027 "obj_id" => [
"integer", $obj_id]
1030 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1046 "description" => [
"text",
$desc],
1047 "last_update" => [
"date",
$db->
now()]
1051 "obj_id" => [
"integer", $obj_id]
1054 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1060 "SELECT obj_id, description" . PHP_EOL
1061 .
"FROM object_description" . PHP_EOL
1062 .
"WHERE obj_id = " .
$db->
quote($obj_id,
'integer') . PHP_EOL
1066 if ($result->numRows()) {
1068 "description" => [
"clob",
$desc]
1070 $db->
update(
"object_description", $values, $where);
1073 "description" => [
"clob",
$desc],
1074 "obj_id" => [
"integer",$obj_id]
1076 $db->
insert(
"object_description", $values);
1091 "last_update" => [
"date",
$db->
now()]
1095 "obj_id" => [
"integer", $obj_id]
1098 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1106 return $DIC[
"ilObjDataCache"]->lookupType(
$DIC[
"ilObjDataCache"]->lookupObjId(
$id));
1109 return $DIC[
"ilObjDataCache"]->lookupType(
$id);
1115 return $DIC->repositoryTree()->isDeleted(
$ref_id);
1124 foreach ($ref_ids as
$ref_id) {
1136 return $DIC[
"ilObjDataCache"]->lookupObjId(
$ref_id);
1152 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
1153 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1161 $objects[$row[
"title"] .
"." . $row[
"obj_id"]] = [
1162 "id" => $row[
"obj_id"],
1163 "type" => $row[
"type"],
1164 "title" => $row[
"title"],
1165 "description" => $row[
"description"]
1181 $this->tree->insertNode($this->
getRefId(), $parent_ref_id);
1184 $log_entry = sprintf(
1185 "ilObject::putInTree(), parent_ref: %s, ref_id: %s, obj_id: %s, type: %s, title: %s",
1193 $this->log->write($log_entry);
1195 $this->app_event_handler->raise(
1196 'components/ILIAS/ILIASObject',
1200 'obj_type' => $this->
getType(),
1201 'obj_id' => $this->
getId(),
1202 'parent_ref_id' => $parent_ref_id
1220 $parent_roles = $this->rbac_review->getParentRoleIds($parent_ref_id);
1221 foreach ($parent_roles as $parent_role) {
1225 $operations = $this->rbac_review->getOperationsOfRole(
1226 (
int) $parent_role[
'obj_id'],
1228 (
int) $parent_role[
'parent']
1230 $this->rbac_admin->grantPermission(
1231 (
int) $parent_role[
'obj_id'],
1244 if (!isset($this->
id)) {
1245 $message =
"ilObject::createNewReference(): No obj_id given!";
1249 $next_id = $this->db->nextId(
'object_reference');
1252 "ref_id" => [
"integer", $next_id],
1253 "obj_id" => [
"integer", $this->
getId()]
1256 $this->db->insert(
"object_reference", $values);
1258 $this->ref_id = $next_id;
1259 $this->referenced =
true;
1266 if (!isset($this->
id)) {
1267 $message =
"ilObject::countReferences(): No obj_id given!";
1272 "SELECT COUNT(ref_id) num" . PHP_EOL
1273 .
"FROM object_reference" . PHP_EOL
1274 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
1277 $res = $this->db->query($sql);
1278 $row = $this->db->fetchObject(
$res);
1280 return (
int) $row->num;
1291 public function delete():
bool
1301 if ($this->type !=
$type) {
1302 $log_entry = sprintf(
1303 "ilObject::delete(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
1309 $this->log->write($log_entry);
1310 $this->
error->raiseError(
1311 sprintf(
"ilObject::delete(): Type mismatch. (%s/%s)", $this->type, $this->
id),
1312 $this->
error->WARNING
1316 $this->app_event_handler->raise(
'components/ILIAS/ILIASObject',
'beforeDeletion', [
'object' => $this]);
1321 "DELETE FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1322 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") . PHP_EOL
1324 $this->db->manipulate($sql);
1327 "DELETE FROM object_description" . PHP_EOL
1328 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") . PHP_EOL
1330 $this->db->manipulate($sql);
1334 "ilObject::delete(), deleted object, obj_id: %s, type: %s, title: %s",
1346 $news_item->deleteNewsOfContext($this->
getId(), $this->
getType());
1353 "DELETE FROM dav_property" . PHP_EOL
1354 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
'integer') . PHP_EOL
1356 $this->db->manipulate($sql);
1367 "ilObject::delete(), object not deleted, number of references: %s, obj_id: %s, type: %s, title: %s",
1377 if ($this->referenced) {
1380 $this->app_event_handler->raise(
'components/ILIAS/ILIASObject',
'deleteReference', [
'ref_id' => $this->
getRefId()]);
1383 "DELETE FROM object_reference" . PHP_EOL
1384 .
"WHERE ref_id = " . $this->db->quote($this->
getRefId(),
'integer') . PHP_EOL
1386 $this->db->manipulate($sql);
1390 "ilObject::delete(), reference deleted, ref_id: %s, obj_id: %s, type: %s, title: %s",
1411 if ($this->referenced) {
1436 $action->setRefId($this->
getRefId());
1452 public static function _exists(
int $id,
bool $reference =
false, ?
string $type =
null): bool
1459 "SELECT object_data.obj_id" . PHP_EOL
1460 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1461 .
"LEFT JOIN object_reference ON object_reference.obj_id = object_data.obj_id " . PHP_EOL
1462 .
"WHERE object_reference.ref_id= " .
$db->
quote(
$id,
"integer") . PHP_EOL
1466 "SELECT object_data.obj_id" . PHP_EOL
1467 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1468 .
"WHERE obj_id = " .
$db->
quote(
$id,
"integer") . PHP_EOL
1473 $sql .=
" AND object_data.type = " .
$db->
quote(
$type,
"text") . PHP_EOL;
1495 $order =
" ORDER BY title";
1499 $where =
"WHERE type = " .
$db->
quote($obj_type,
"text");
1507 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
1508 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1517 $row[
"desc"] = $row[
"description"];
1518 $arr[$row[
"obj_id"]] = $row;
1534 bool $show_path =
true
1543 "SELECT obj_data.title obj_title, path_data.title path_title, child" . PHP_EOL
1544 .
"FROM tree " . PHP_EOL
1545 .
"JOIN object_reference obj_ref ON child = obj_ref.ref_id " . PHP_EOL
1546 .
"JOIN object_data obj_data ON obj_ref.obj_id = obj_data.obj_id " . PHP_EOL
1547 .
"JOIN object_reference path_ref ON parent = path_ref.ref_id " . PHP_EOL
1548 .
"JOIN object_data path_data ON path_ref.obj_id = path_data.obj_id " . PHP_EOL
1549 .
"WHERE " .
$db->
in(
"child", $ref_ids,
false,
"integer") . PHP_EOL
1550 .
"ORDER BY obj_data.title" . PHP_EOL
1555 $options[0] =
$lng->
txt(
'obj_' . $new_type .
'_select');
1561 if (strlen(
$title = $row->obj_title) > 40) {
1566 if (strlen(
$path = $row->path_title) > 40) {
1573 $options[$row->child] =
$title;
1575 return $options ?: [];
1581 public function cloneObject(
int $target_id,
int $copy_id = 0,
bool $omit_tree =
false): ?
ilObject
1586 $ilUser =
$DIC[
"ilUser"];
1587 $rbac_admin =
$DIC[
"rbacadmin"];
1589 $class_name = (
'ilObj' . $this->obj_definition->getClassName($this->getType()));
1593 $this->obj_log->debug($this->
getTitle());
1594 $this->obj_log->debug(
"isTreeCopyDisabled: " . $options->isTreeCopyDisabled());
1595 $this->obj_log->debug(
"omit_tree: " . $omit_tree);
1598 $new_obj =
new $class_name(0,
false);
1599 $new_obj->setOwner($ilUser->getId());
1600 $new_obj->title = $this->
getTitle();
1601 $new_obj->long_desc = $this->getLongDescription();
1602 $new_obj->desc = $this->getDescription();
1603 $new_obj->type = $this->getType();
1606 $new_obj->create(
true);
1608 if (!$options->isTreeCopyDisabled() && !$omit_tree) {
1609 $title_with_suffix = $this->appendCopyInfo($target_id, $copy_id, $new_obj->getId());
1610 $title = mb_strlen($title_with_suffix) < self::TITLE_LENGTH ? $title_with_suffix : $title;
1611 $this->obj_log->debug(
"title incl. copy info: " . $title);
1612 $new_obj->setTitle($title);
1616 if ($this->supportsOfflineHandling()) {
1617 if ($options->isRootNode($this->getRefId())) {
1618 $new_obj->getObjectProperties()->storePropertyIsOnline(
1619 $new_obj->getObjectProperties()->getPropertyIsOnline()->withOffline()
1622 $new_obj->getObjectProperties()->storePropertyIsOnline(
1623 $this->getObjectProperties()->getPropertyIsOnline()
1628 if (!$options->isTreeCopyDisabled() && !$omit_tree) {
1630 $new_obj->createReference();
1631 $new_obj->putInTree($target_id);
1632 $new_obj->setPermissions($target_id);
1635 if ($this->getRefId()) {
1637 $rbac_admin->
copyLocalRoles($this->getRefId(), $new_obj->getRefId());
1647 "INSERT INTO dav_property" . PHP_EOL
1648 .
"(obj_id, node_id, ns, name, value)" . PHP_EOL
1649 .
"SELECT " . $this->db->quote($new_obj->getId(),
'integer') .
", node_id, ns, name, value " . PHP_EOL
1650 .
"FROM dav_property" . PHP_EOL
1651 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
'integer') . PHP_EOL
1653 $this->db->manipulate($sql);
1656 $customIconFactory =
$DIC[
'object.customicons.factory'];
1657 $customIcon = $customIconFactory->getByObjId($this->
getId(), $this->getType());
1658 $customIcon->copy($new_obj->getId());
1660 $new_obj->getObjectProperties()->storePropertyTileImage(
1661 $new_obj->getObjectProperties()->getPropertyTileImage()->withTileImage(
1662 $this->getObjectProperties()->getPropertyTileImage()
1663 ->getTileImage()->cloneFor($new_obj->getId())
1667 $this->app_event_handler->raise(
1668 'components/ILIAS/ILIASObject',
1671 'object' => $new_obj,
1672 'cloned_from_object' => $this,
1688 if (!$cp_options->isRootNode($this->getRefId())) {
1693 $obj_translations = $this->getObjectProperties()->clonePropertyTranslations($new_obj_id);
1695 $other_children_of_same_type = $this->tree->getChildsByType($target_id, $this->type);
1697 if ($obj_translations->getLanguages() === []) {
1698 $existing_titles = array_map(
1699 fn(array $child):
string => $child[
'title'],
1700 $other_children_of_same_type
1703 return $this->appendNumberOfCopiesToTitle(
1709 return $this->appendCopyInfoToTranslations($obj_translations, $other_children_of_same_type);
1714 array $other_children_of_same_type
1716 $nodes_translations = array_map(
1718 $this->translations_repository->getFor($child[
'obj_id']),
1719 $other_children_of_same_type
1722 $title_translations_per_lang = array_reduce(
1723 $nodes_translations,
1724 $this->getCallbackForTitlesPerLanguageTransformation(),
1728 $installed_langs = $this->
lng->getInstalledLanguages();
1729 foreach ($obj_translations->
getLanguages() as $language) {
1731 $language->withTitle(
1732 $this->appendNumberOfCopiesToTitle(
1733 $language->getTitle(),
1734 $title_translations_per_lang[$language->getLanguageCode()] ?? []
1740 $this->translations_repository->store($obj_translations);
1747 return function (array $npl, ?
Translations $nt): array {
1748 $langs = $nt->getLanguages();
1749 foreach ($langs as
$lang) {
1750 if (!array_key_exists(
$lang->getLanguageCode(), $npl)) {
1751 $npl[
$lang->getLanguageCode()] = [];
1753 $npl[
$lang->getLanguageCode()][] =
$lang->getTitle();
1761 array $other_titles_for_lang
1763 $title_without_suffix = $this->buildTitleWithoutCopySuffix($title);
1764 if ($this->isTitleUnique($title_without_suffix, $other_titles_for_lang)) {
1765 return $title_without_suffix;
1768 for ($i = 1;
true; $i++) {
1769 $title_with_suffix =
"{$title_without_suffix} ({$i})";
1770 if ($this->isTitleUnique($title_with_suffix, $other_titles_for_lang)) {
1771 return $title_with_suffix;
1778 foreach ($nodes as $node) {
1779 if (($title === $node)) {
1788 if (preg_match(
'/ \((\d+)\)$/', $title, $matches)) {
1789 return substr($title, 0, -strlen($matches[0]));
1809 $obj = $factory->getInstanceByRefId($target_id,
false);
1811 $obj->applyDidacticTemplate($tpl_id);
1822 $this->lom_services->derive()
1823 ->fromObject($this->
getId(), 0, $this->getType())
1824 ->forObject($target_obj->
getId(), 0, $target_obj->
getType());
1828 public static function getIconForReference(
1833 bool $offline =
false
1837 $icon_factory =
$DIC[
'ui.factory']->symbol()->icon();
1838 $irss =
$DIC[
'resource_storage'];
1840 if ($obj_id ==
"" && $type ==
"") {
1854 $property_icon = LocalDIC::dic()[
'properties.additional.repository']->getFor($obj_id)->getPropertyIcon();
1855 $custom_icon = $property_icon->getCustomIcon();
1856 if ($custom_icon?->exists()) {
1857 return $custom_icon->getFullPath() .
'?tmp=' . filemtime($custom_icon->getFullPath());
1860 $file_type_specific_icon = $property_icon->getObjectTypeSpecificIcon($obj_id, $icon_factory, $irss);
1861 if ($file_type_specific_icon !==
null) {
1862 return $file_type_specific_icon->getIconPath();
1867 $path = $dtpl_icon_factory->getIconPathForReference(
$ref_id);
1869 $path = $dtpl_icon_factory->getIconPathForObject($obj_id);
1877 return self::getIconForType($type);
1879 return "./images/standard/icon_{$type}.svg";
1885 $objDefinition =
$DIC[
'objDefinition'];
1886 if (!$objDefinition->isPluginTypeName($type)) {
1890 if ($objDefinition->getClassName($type) !==
'') {
1891 $class_name =
"il{$objDefinition->getClassName($type)}Plugin";
1892 $location = $objDefinition->getLocation($type);
1893 if (is_file(
$location .
"/class.{$class_name}.php")) {
1894 return call_user_func([$class_name,
'_getIcon'], $type);
1910 string $size =
"big",
1912 bool $offline =
false
1914 return self::getIconForReference(0, $obj_id, $size, $type, $offline);
1919 if ($this->process_auto_reating
1920 && $this->hasAutoRating()
1921 && method_exists($this,
"setRating")
1923 $this->setRating(
true);
1931 $type = $this->type;
1933 if (!
$ref_id || !in_array($type, [
"file",
"lm",
"wiki"])) {
1937 return $this->selfOrParentWithRatingEnabled();
1942 $tree = $this->tree;
1945 if (!$parent_ref_id) {
1948 if ($parent_ref_id) {
1971 $objDefinition =
$DIC[
"objDefinition"];
1972 $tree =
$DIC->repositoryTree();
1978 $deps[
"del_ids"][$obj_id] = $obj_id;
1980 if (!$objDefinition->isPluginTypeName($type)) {
1981 $class_name =
"ilObj" . $objDefinition->getClassName($type);
1982 $odeps = call_user_func([$class_name,
"getDeletionDependencies"], $obj_id);
1983 if (is_array($odeps)) {
1997 foreach ($deps[
"del_ids"] as $obj_id) {
1998 unset($deps[
"dep"][$obj_id]);
2000 $deps = $deps[
"dep"];
2015 $db =
$DIC->database();
2018 "SELECT obj_id, description" . PHP_EOL
2019 .
"FROM object_description" . PHP_EOL
2020 .
"WHERE " . $db->
in(
"obj_id", $obj_ids,
false,
"integer") . PHP_EOL
2022 $result = $db->
query($sql);
2026 $all[$row[
"obj_id"]] = $row[
"description"];
2035 $db =
$DIC->database();
2036 $obj_definition =
$DIC[
"objDefinition"];
2042 "SELECT od.obj_id, od.type, od.title" . PHP_EOL
2043 .
"FROM object_data od" . PHP_EOL
2044 .
"JOIN object_reference oref ON(oref.obj_id = od.obj_id)" . PHP_EOL
2045 .
"JOIN tree ON (tree.child = oref.ref_id)" . PHP_EOL
2049 $sql .=
"WHERE od.owner = " . $db->
quote(
$user_id,
"integer") . PHP_EOL;
2052 "LEFT JOIN usr_data ud ON (ud.usr_id = od.owner)" . PHP_EOL
2053 .
"WHERE (od.owner < " . $db->
quote(1,
"integer") . PHP_EOL
2054 .
"OR od.owner IS NULL OR ud.login IS NULL)" . PHP_EOL
2055 .
"AND od.owner <> " . $db->
quote(-1,
"integer") . PHP_EOL
2060 "AND " . $db->
in(
"od.type", $types,
false,
"text") . PHP_EOL
2061 .
"AND tree.tree > " . $db->
quote(0,
"integer") . PHP_EOL
2068 $all[$row[
"type"]][$row[
"obj_id"]] = $row[
"title"];
2080 $db =
$DIC->database();
2082 if (!in_array($type, [
"catr",
"crsr",
"sess",
"grpr",
"prgr"])) {
2087 $missing_obj_ids = [];
2088 foreach ($obj_title_map as $obj_id => $title) {
2089 if (!trim($title)) {
2090 $missing_obj_ids[] = $obj_id;
2094 if (!
sizeof($missing_obj_ids)) {
2104 "SELECT oref.obj_id, od.type, od.title" . PHP_EOL
2105 .
"FROM object_data od" . PHP_EOL
2106 .
"JOIN container_reference oref ON (od.obj_id = oref.target_obj_id)" . PHP_EOL
2107 .
"AND " . $db->
in(
"oref.obj_id", $missing_obj_ids,
false,
"integer") . PHP_EOL
2109 $result = $db->
query($sql);
2112 $obj_title_map[$row[
"obj_id"]] = $row[
"title"];
2116 foreach ($missing_obj_ids as $obj_id) {
2118 $obj_title_map[$obj_id] = $sess->getFirstAppointment()->appointmentToString();
2127 $db =
$DIC->database();
2130 "SELECT create_date" . PHP_EOL
2131 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
2132 .
"WHERE obj_id = " . $db->
quote($obj_id,
"integer") . PHP_EOL
2134 $result = $db->
query($sql);
2136 return $rec[
"create_date"];
2149 return $this->obj_definition->getSubObjects($this->type, $filter);
2160 "SELECT obj_id FROM object_data" . PHP_EOL
2161 .
"WHERE type = 'typ'" . PHP_EOL
2162 .
"AND title = " .
$ilDB->quote($type,
'text') . PHP_EOL
2171 return (
int) $row[
'obj_id'] ??
null;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class handles translation mode for an object.
withLanguage(Language $lang)
static _deleteByObjId(int $a_obj_id)
Delete by objekt id.
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.
static _deleteSettingsOfBlock(int $a_block_id, string $a_block_type)
INTERNAL CLASS: Please do not use in consumer code.
static cloneDependencies(int $a_src_ref_id, int $a_target_ref_id, int $a_copy_id)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static _getInstance(int $a_copy_id)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static getActionsByTemplateId(int $a_tpl_id)
Get actions of one template.
static deleteByRefId(int $a_ref_id)
static deleteByObjId(int $a_obj_id)
static lookupTemplateId(int $a_ref_id)
static assignTemplate(int $a_ref_id, int $a_obj_id, int $a_tpl_id)
static getInstance()
Get the singleton instance of this ilECSImportManager.
Error Handling & global info handling.
static _deleteByObjId(int $a_obj_id)
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 getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
A news item can be created by different sources.
static deleteAllEntries(int $ref_id)
Delete all db entries for ref id.
static add(ilObject $object)
parses the objects.xml it handles the xml-description of all ilias objects
isPlugin(string $obj_name)
get RBAC status by type returns true if object type is an (activated) plugin type
isRBACObject(string $obj_name)
get RBAC status by type returns true if object type is a RBAC object type
getSubObjectsRecursively(string $obj_type, bool $include_source_obj=true, bool $add_admin_objects=false)
Get all sub objects by type.
Class ilObjectFactory This class offers methods to get instances of the type-specific object classes ...
Object not found exception.
static lookupTxtById(string $plugin_id, string $lang_var)
const AUTO_RATING_NEW_OBJECTS
Class ilObject Basic functions for all objects.
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
setPermissions(int $parent_ref_id)
createReference()
creates reference for object
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupOwnerName(int $owner_id)
Lookup owner name for owner id.
ilRbacReview $rbac_review
cloneMetaData(ilObject $target_obj)
Copy meta data.
static _writeDescription(int $obj_id, string $desc)
write description to db (static)
putInTree(int $parent_ref_id)
maybe this method should be in tree object!?
static _setDeletedDate(int $ref_id, int $deleted_by)
initDefaultRoles()
init default roles settings Purpose of this function is to create a local role folder and local roles...
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static _lookupOwner(int $obj_id)
Lookup owner user ID for object ID.
appendNumberOfCopiesToTitle(string $title, array $other_titles_for_lang)
static _getAllReferences(int $id)
get all reference ids for object ID
updateOwner()
update owner of object in db
appendCopyInfoToTranslations(Translations $obj_translations, array $other_children_of_same_type)
supportsOfflineHandling()
cloneDependencies(int $target_id, int $copy_id)
Clone object dependencies.
doMDUpdateListener(string $a_element)
static _lookupDeletedDate(int $ref_id)
selfOrParentWithRatingEnabled()
static collectDeletionDependencies(array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
Collect deletion dependencies.
ilAppEventHandler $app_event_handler
static _isInTrash(int $ref_id)
getPossibleSubObjects(bool $filter=true)
get all possible sub objects of this type the object can decide which types of sub objects are possib...
buildTitleWithoutCopySuffix(string $title)
static _lookupObjIdByImportId(string $import_id)
Get (latest) object id for an import id.
static _writeTitle(int $obj_id, string $title)
write title to db (static)
static _getIdForImportId(string $import_id)
applyDidacticTemplate(int $tpl_id)
static _lookupImportId(int $obj_id)
ilObjectDefinition $obj_definition
static _getIdsForTitle(string $title, string $type='', bool $partial_match=false)
isTitleUnique(string $title, array $nodes)
getLastUpdateDate()
Get last update date in YYYY-MM-DD HH-MM-SS format.
bool $process_auto_reating
static _prepareCloneSelection(array $ref_ids, string $new_type, bool $show_path=true)
Prepare copy wizard object selection.
appendCopyInfo(int $target_id, int $copy_id, int $new_obj_id)
Prepend Copy info if object with same name exists in that container.
static getDeletionDependencies(int $obj_id)
Get deletion dependencies.
static setDeletedDates(array $ref_ids, int $user_id)
LOMServices $lom_services
Aggregator $properties_aggregator
setImportId(string $import_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _getLastUpdateOfObjects(array $obj_ids)
static _lookupLastUpdate(int $obj_id, bool $formatted=false)
getOwnerName()
get full name of object owner
withReferences()
determines whether objects are referenced or not (got ref ids or not)
Properties $object_properties
getLongDescription()
get object long description (stored in object_description)
string $untranslatedTitle
static _writeImportId(int $obj_id, string $import_id)
write import id to db (static)
static getAllOwnedRepositoryObjects(int $user_id)
setOfflineStatus(bool $status)
create()
note: title, description and type should be set when this function is called
static _lookupCreationDate(int $obj_id)
static _getObjectTypeIdByTitle(string $type, ?\ilDBInterface $ilDB=null)
getUntranslatedTitle()
Get untranslated object title WebDAV needs to access the untranslated title of an object.
TranslationsRepository $translations_repository
static getIconForType(string $type)
getCallbackForTitlesPerLanguageTransformation()
static _getObjectsDataForType(string $type, bool $omit_trash=false)
get all objects of a certain type
beforeMDUpdateListener(string $a_element)
static _getObjectsByType(string $obj_type="", ?int $owner=null)
const DATABASE_DATE_FORMAT
static _resetDeletedDate(int $ref_id)
static getLongDescriptions(array $obj_ids)
static _lookupObjId(int $ref_id)
MDUpdateListener(string $element)
Metadata update listener.
setParentRolePermissions(int $parent_ref_id)
Initialize the permissions of parent roles (local roles of categories, global roles....
setDescription(string $description)
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
getCreateDate()
Get create date in YYYY-MM-DD HH-MM-SS format.
static fixMissingTitles($type, array &$obj_title_map)
Try to fix missing object titles.
getPresentationTitle()
get presentation title Normally same as title Overwritten for sessions
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
Class ilRbacAdmin Core functions for role based access control.
copyLocalRoles(int $a_source_id, int $a_target_id)
Copy local roles This method creates a copy of all local role.
revokePermission(int $a_ref_id, int $a_rol_id=0, bool $a_keep_protected=true)
Revokes permissions of an object of one role.
static delete(int $ref_id)
class ilRbacReview Contains Review functions of core Rbac.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
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 getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
update(string $table_name, array $values, array $where)
@description $where MUST contain existing columns only.
insert(string $table_name, array $values)
fetchObject(ilDBStatement $query_result)
setLimit(int $limit, int $offset=0)
like(string $column, string $type, string $value="?", bool $case_insensitive=true)
Generate a like subquery.
numRows(ilDBStatement $statement)
quote($value, string $type)
manipulate(string $query)
Run a (write) Query on the database.
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
in(string $field, array $values, bool $negate=false, string $type="")
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilObjForumAdministration.