19 declare(strict_types=1);
94 protected int $id = 0,
95 protected bool $referenced =
true 100 $this->
ilias = $DIC[
"ilias"];
101 $this->obj_definition = $DIC[
"objDefinition"];
102 $this->db = $DIC[
"ilDB"];
103 $this->log = $DIC[
"ilLog"];
105 $this->error = $DIC[
"ilErr"];
106 $this->tree = $DIC[
"tree"];
107 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
108 $this->lom_services = $DIC->learningObjectMetadata();
109 $object_dic = LocalDIC::dic();
110 $this->properties_aggregator = $object_dic[
'properties.aggregator'];
111 $this->translations_repository = $object_dic[
'properties.translations.repository'];
113 $this->call_by_reference = $this->referenced;
115 if (isset($DIC[
"lng"])) {
116 $this->
lng = $DIC[
"lng"];
119 if (isset($DIC[
"ilUser"])) {
120 $this->
user = $DIC[
"ilUser"];
123 if (isset($DIC[
"rbacadmin"])) {
124 $this->rbac_admin = $DIC[
"rbacadmin"];
127 if (isset($DIC[
"rbacreview"])) {
128 $this->rbac_review = $DIC[
"rbacreview"];
132 $this->referenced =
false;
135 if ($this->referenced) {
148 if ($this->object_properties ===
null) {
149 $this->object_properties = $this->properties_aggregator->getFor($this->
id, $this->type);
159 $this->object_properties =
null;
168 return ($this->call_by_reference) ? true : $this->referenced;
177 $this->process_auto_reating =
true;
184 $ilUser = $DIC[
"ilUser"];
188 if ($this->referenced) {
189 if (!isset($this->ref_id)) {
190 $message =
"ilObject::read(): No ref_id given! (" . $this->type .
")";
191 $this->error->raiseError(
$message, $this->error->WARNING);
196 "SELECT od.obj_id, od.type, od.title, od.description, od.owner, od.create_date," . PHP_EOL
197 .
"od.last_update, od.import_id, ore.ref_id, ore.obj_id, ore.deleted, ore.deleted_by" . PHP_EOL
198 .
"FROM " . self::TABLE_OBJECT_DATA .
" od" . PHP_EOL
199 .
"JOIN object_reference ore ON od.obj_id = ore.obj_id" . PHP_EOL
200 .
"WHERE ore.ref_id = " . $this->db->quote($this->ref_id,
"integer") . PHP_EOL
203 $result = $this->db->query($sql);
206 if ($this->db->numRows($result) === 0) {
208 "ilObject::read(): Object with ref_id %s not found! (%s)",
212 $this->error->raiseError(
$message, $this->error->WARNING);
215 if (!isset($this->
id)) {
216 $message = sprintf(
"ilObject::read(): No obj_id given! (%s)", $this->type);
217 $this->error->raiseError(
$message, $this->error->WARNING);
221 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
222 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
223 .
"WHERE obj_id = " . $this->db->quote($this->
id,
"integer") . PHP_EOL
225 $result = $this->db->query($sql);
227 if ($this->db->numRows($result) === 0) {
228 $message = sprintf(
"ilObject::read(): Object with obj_id: %s (%s) not found!", $this->
id, $this->type);
232 $obj = $this->db->fetchAssoc($result);
234 $this->
id = (
int) $obj[
"obj_id"];
237 if ($this->type != $obj[
"type"] && $obj[
"type"] !=
"xxx") {
239 "ilObject::read(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
249 $this->type = (string) $obj[
"type"];
250 $this->title = (string) $obj[
"title"];
252 $this->untranslatedTitle = (string) $obj[
"title"];
255 $this->desc = (string) $obj[
"description"];
256 $this->owner = (
int) $obj[
"owner"];
257 $this->create_date = (string) $obj[
"create_date"];
258 $this->last_update = (string) $obj[
"last_update"];
259 $this->import_id = (string) $obj[
"import_id"];
261 if ($this->obj_definition->isRBACObject($this->getType())) {
263 "SELECT obj_id, description" . PHP_EOL
264 .
"FROM object_description" . PHP_EOL
265 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
268 $res = $this->db->query($sql);
270 $this->long_desc =
'';
272 if (($row->description ??
'') !==
'') {
279 $translation_type = $this->obj_definition->getTranslationType($this->type);
281 if ($translation_type ==
"sys") {
282 $this->title = $this->
lng->txt(
"obj_" . $this->type);
284 } elseif ($translation_type ==
"db") {
286 "SELECT title, description" . PHP_EOL
287 .
"FROM object_translation" . PHP_EOL
288 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
289 .
"AND lang_code = " . $this->db->quote($ilUser->getCurrentLanguage(),
'text') . PHP_EOL
291 $r = $this->db->query($sql);
294 $this->title = (string) $row->title;
295 $this->setDescription((
string) $row->description);
299 $this->object_properties =
null;
315 $this->referenced =
true;
320 return $this->ref_id ?? 0;
328 final public function setType(
string $type): void
357 final public function setTitle(
string $title): void
363 $this->object_properties = $this->
getObjectProperties()->withPropertyTitleAndDescription($property);
365 $this->title = $property->getTitle();
379 ->getPropertyTitleAndDescription()->withDescription($description);
381 $this->object_properties = $this->
getObjectProperties()->withPropertyTitleAndDescription($property);
384 $this->desc = $property->getDescription();
385 $this->long_desc = $property->getLongDescription();
393 if ($this->long_desc !==
'') {
397 if ($this->desc !==
'') {
420 $db = $DIC->database();
423 "SELECT obj_id" . PHP_EOL
424 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
425 .
"WHERE import_id = " . $db->
quote($import_id,
"text") . PHP_EOL
426 .
"ORDER BY create_date DESC" . PHP_EOL
428 $result = $db->
query($sql);
430 if ($db->
numRows($result) == 0) {
436 return (
int) $row->obj_id;
446 $property_is_online = $property_is_online->withOffline();
449 $this->object_properties = $this->
getObjectProperties()->withPropertyIsOnline($property_is_online);
459 return $this->obj_definition->supportsOfflineHandling($this->
getType());
466 $db = $DIC->database();
469 "SELECT import_id" . PHP_EOL
470 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
471 .
"WHERE obj_id = " . $db->
quote($obj_id,
"integer") . PHP_EOL
476 return (
string) $row->import_id;
500 $lng = $DIC->language();
503 if ($owner_id != -1) {
509 $own_name = $lng->
txt(
"unknown");
510 if (is_object($owner)) {
511 $own_name = $owner->getFullname();
519 $this->owner = $usr_id;
545 $user = $DIC[
"ilUser"];
547 if (!isset($this->type)) {
548 $message = sprintf(
"%s::create(): No object type given!", get_class($this));
549 $this->error->raiseError(
$message, $this->error->WARNING);
552 $this->log->write(
"ilObject::create(), start");
558 } elseif (is_object($user)) {
559 $owner = $user->
getId();
562 $this->
id = $this->db->nextId(self::TABLE_OBJECT_DATA);
564 "obj_id" => [
"integer", $this->
getId()],
565 "type" => [
"text", $this->
getType()],
566 "title" => [
"text", $this->
getTitle()],
568 "owner" => [
"integer",
$owner],
569 "create_date" => [
"date", $this->db->now()],
570 "last_update" => [
"date", $this->db->now()],
574 $this->db->insert(self::TABLE_OBJECT_DATA, $values);
575 $this->object_properties =
null;
578 if ($this->obj_definition->isRBACObject($this->getType())) {
583 $this->db->insert(
'object_description', $values);
591 if ($this->obj_definition->isOrgUnitPermissionType($this->type)) {
598 "SELECT last_update, create_date" . PHP_EOL
599 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
600 .
"WHERE obj_id = " . $this->db->quote($this->
id,
"integer") . PHP_EOL
602 $obj_set = $this->db->query($sql);
603 $obj_rec = $this->db->fetchAssoc($obj_set);
604 $this->last_update = $obj_rec[
"last_update"];
605 $this->create_date = $obj_rec[
"create_date"];
613 "ilObject::create(), finished, obj_id: %s, type: %s, title: %s",
620 $this->app_event_handler->raise(
621 'components/ILIAS/ILIASObject',
624 'obj_id' => $this->
id,
625 'obj_type' => $this->type
636 $this->app_event_handler->raise(
637 'components/ILIAS/ILIASObject',
640 'obj_id' => $this->
getId(),
641 'obj_type' => $this->
getType(),
661 $this->app_event_handler->raise(
662 'components/ILIAS/ILIASObject',
664 [
'obj_id' => $this->
getId(),
665 'obj_type' => $this->
getType(),
671 if ($element ==
'General') {
672 $paths = $this->lom_services->paths();
673 $reader = $this->lom_services->read(
677 $paths->custom()->withNextStep(
'general')->get()
680 $this->
setTitle($reader->firstData($paths->title())->value());
681 $this->
setDescription($reader->firstData($paths->descriptions())->value());
702 $ilUser = $DIC[
"ilUser"];
704 $this->lom_services->derive()->fromBasicProperties(
707 $ilUser->getPref(
'language')
726 $paths = $this->lom_services->paths();
728 $manipulator = $this->lom_services->manipulate($this->
getId(), 0, $this->
getType())
729 ->prepareCreateOrUpdate($paths->title(), $this->
getTitle());
732 $manipulator = $manipulator->prepareCreateOrUpdate(
733 $paths->firstDescription(),
737 $manipulator = $manipulator->prepareDelete($paths->firstDescription());
740 $manipulator->execute();
757 $this->lom_services->deleteAll($this->
getId(), 0, $this->
getType());
777 "owner" => [
"integer", $this->
getOwner()],
778 "last_update" => [
"date", $this->db->now()]
782 "obj_id" => [
"integer", $this->
getId()]
785 $this->db->update(self::TABLE_OBJECT_DATA, $values, $where);
794 $db = $DIC->database();
798 "SELECT obj_id" . PHP_EOL
799 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
800 .
"WHERE import_id = " . $db->
quote($import_id,
"text") . PHP_EOL
801 .
"ORDER BY create_date DESC" . PHP_EOL
804 $result = $db->
query($sql);
807 return (
int) $row[
"obj_id"];
820 $db = $DIC->database();
823 "SELECT ref_id" . PHP_EOL
824 .
"FROM object_reference" . PHP_EOL
825 .
"WHERE obj_id = " . $db->
quote($id,
'integer') . PHP_EOL
828 $result = $db->
query($sql);
832 $ref[(
int) $row[
"ref_id"]] = (
int) $row[
"ref_id"];
841 return (
string) $DIC[
"ilObjDataCache"]->lookupTitle($obj_id);
850 return $DIC[
'ilObjDataCache']->lookupOfflineStatus($obj_id);
859 return (
int) $DIC[
"ilObjDataCache"]->lookupOwner($obj_id);
865 final public static function _getIdsForTitle(
string $title,
string $type =
'',
bool $partial_match =
false): array
868 $db = $DIC->database();
870 $where =
"title = " . $db->
quote($title,
"text");
871 if ($partial_match) {
872 $where = $db->
like(
"title",
"text",
'%' . $title .
'%');
876 "SELECT obj_id" . PHP_EOL
877 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
878 .
"WHERE " . $where . PHP_EOL
882 $sql .=
" AND type = " . $db->
quote($type,
"text");
885 $result = $db->
query($sql);
889 $object_ids[] = (
int) $row[
'obj_id'];
898 return (
string) $DIC[
"ilObjDataCache"]->lookupDescription($obj_id);
905 $last_update = $DIC[
"ilObjDataCache"]->lookupLastUpdate($obj_id);
917 $db = $DIC->database();
920 "SELECT MAX(last_update) as last_update" . PHP_EOL
921 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
922 .
"WHERE " . $db->
in(
"obj_id", $obj_ids,
false,
"integer") . PHP_EOL
925 $result = $db->
query($sql);
928 return (
string) $row[
"last_update"];
934 return $DIC[
"ilObjDataCache"]->lookupObjId($ref_id);
940 $db = $DIC->database();
943 "deleted" => [
"date", $db->
now()],
944 "deleted_by" => [
"integer", $deleted_by]
948 "ref_id" => [
"integer",
$ref_id]
951 $db->
update(
"object_reference", $values, $where);
960 $db = $DIC->database();
963 "UPDATE object_reference" . PHP_EOL
964 .
"SET deleted = " . $db->
now() .
", " . PHP_EOL
965 .
"deleted_by = " . $db->
quote($user_id,
"integer") . PHP_EOL
966 .
"WHERE " . $db->
in(
"ref_id", $ref_ids,
false,
"integer") . PHP_EOL;
974 $db = $DIC->database();
977 "deleted" => [
"timestamp",
null],
978 "deleted_by" => [
"integer", 0]
982 "ref_id" => [
"integer",
$ref_id]
985 $db->
update(
"object_reference", $values, $where);
991 $db = $DIC->database();
994 "SELECT deleted" . PHP_EOL
995 .
"FROM object_reference" . PHP_EOL
996 .
"WHERE ref_id = " . $db->
quote($ref_id,
"integer") . PHP_EOL
998 $result = $db->
query($sql);
1001 return $row[
"deleted"] ??
null;
1007 final public static function _writeTitle(
int $obj_id,
string $title): void
1010 $db = $DIC->database();
1013 "title" => [
"text",
$title],
1014 "last_update" => [
"date", $db->
now()]
1018 "obj_id" => [
"integer", $obj_id]
1021 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1031 $db = $DIC->database();
1032 $obj_definition = $DIC[
"objDefinition"];
1037 "description" => [
"text",
$desc],
1038 "last_update" => [
"date", $db->
now()]
1042 "obj_id" => [
"integer", $obj_id]
1045 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1051 "SELECT obj_id, description" . PHP_EOL
1052 .
"FROM object_description" . PHP_EOL
1053 .
"WHERE obj_id = " . $db->
quote($obj_id,
'integer') . PHP_EOL
1055 $result = $db->
query($sql);
1057 if ($result->numRows()) {
1059 "description" => [
"clob",
$desc]
1061 $db->
update(
"object_description", $values, $where);
1064 "description" => [
"clob",
$desc],
1065 "obj_id" => [
"integer",$obj_id]
1067 $db->
insert(
"object_description", $values);
1078 $db = $DIC->database();
1082 "last_update" => [
"date", $db->
now()]
1086 "obj_id" => [
"integer", $obj_id]
1089 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1097 return $DIC[
"ilObjDataCache"]->lookupType($DIC[
"ilObjDataCache"]->lookupObjId($id));
1100 return $DIC[
"ilObjDataCache"]->lookupType($id);
1106 return $DIC->repositoryTree()->isDeleted($ref_id);
1115 foreach ($ref_ids as $ref_id) {
1127 return $DIC[
"ilObjDataCache"]->lookupObjId($ref_id);
1140 $db = $DIC->database();
1143 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
1144 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1145 .
"WHERE type = " . $db->
quote($type,
"text") . PHP_EOL
1147 $result = $db->
query($sql);
1152 $objects[$row[
"title"] .
"." . $row[
"obj_id"]] = [
1153 "id" => $row[
"obj_id"],
1154 "type" => $row[
"type"],
1155 "title" => $row[
"title"],
1156 "description" => $row[
"description"]
1172 $this->tree->insertNode($this->
getRefId(), $parent_ref_id);
1175 $log_entry = sprintf(
1176 "ilObject::putInTree(), parent_ref: %s, ref_id: %s, obj_id: %s, type: %s, title: %s",
1184 $this->log->write($log_entry);
1186 $this->app_event_handler->raise(
1187 'components/ILIAS/ILIASObject',
1191 'obj_type' => $this->
getType(),
1192 'obj_id' => $this->
getId(),
1193 'parent_ref_id' => $parent_ref_id
1211 $parent_roles = $this->rbac_review->getParentRoleIds($parent_ref_id);
1212 foreach ($parent_roles as $parent_role) {
1216 $operations = $this->rbac_review->getOperationsOfRole(
1217 (
int) $parent_role[
'obj_id'],
1219 (
int) $parent_role[
'parent']
1221 $this->rbac_admin->grantPermission(
1222 (
int) $parent_role[
'obj_id'],
1235 if (!isset($this->
id)) {
1236 $message =
"ilObject::createNewReference(): No obj_id given!";
1237 $this->error->raiseError(
$message, $this->error->WARNING);
1240 $next_id = $this->db->nextId(
'object_reference');
1243 "ref_id" => [
"integer", $next_id],
1244 "obj_id" => [
"integer", $this->
getId()]
1247 $this->db->insert(
"object_reference", $values);
1249 $this->ref_id = $next_id;
1250 $this->referenced =
true;
1257 if (!isset($this->
id)) {
1258 $message =
"ilObject::countReferences(): No obj_id given!";
1259 $this->error->raiseError(
$message, $this->error->WARNING);
1263 "SELECT COUNT(ref_id) num" . PHP_EOL
1264 .
"FROM object_reference" . PHP_EOL
1265 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
1268 $res = $this->db->query($sql);
1269 $row = $this->db->fetchObject(
$res);
1271 return (
int) $row->num;
1282 public function delete():
bool 1285 $rbac_admin = $DIC[
"rbacadmin"];
1292 if ($this->type != $type) {
1293 $log_entry = sprintf(
1294 "ilObject::delete(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
1300 $this->log->write($log_entry);
1301 $this->error->raiseError(
1302 sprintf(
"ilObject::delete(): Type mismatch. (%s/%s)", $this->type, $this->
id),
1303 $this->error->WARNING
1307 $this->app_event_handler->raise(
'components/ILIAS/ILIASObject',
'beforeDeletion', [
'object' => $this]);
1312 "DELETE FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1313 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") . PHP_EOL
1315 $this->db->manipulate($sql);
1318 "DELETE FROM object_description" . PHP_EOL
1319 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") . PHP_EOL
1321 $this->db->manipulate($sql);
1325 "ilObject::delete(), deleted object, obj_id: %s, type: %s, title: %s",
1337 $news_item->deleteNewsOfContext($this->
getId(), $this->
getType());
1344 "DELETE FROM dav_property" . PHP_EOL
1345 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
'integer') . PHP_EOL
1347 $this->db->manipulate($sql);
1358 "ilObject::delete(), object not deleted, number of references: %s, obj_id: %s, type: %s, title: %s",
1368 if ($this->referenced) {
1371 $this->app_event_handler->raise(
'components/ILIAS/ILIASObject',
'deleteReference', [
'ref_id' => $this->
getRefId()]);
1374 "DELETE FROM object_reference" . PHP_EOL
1375 .
"WHERE ref_id = " . $this->db->quote($this->
getRefId(),
'integer') . PHP_EOL
1377 $this->db->manipulate($sql);
1381 "ilObject::delete(), reference deleted, ref_id: %s, obj_id: %s, type: %s, title: %s",
1402 if ($this->referenced) {
1427 $action->setRefId($this->
getRefId());
1443 public static function _exists(
int $id,
bool $reference =
false, ?
string $type =
null): bool
1446 $db = $DIC->database();
1450 "SELECT object_data.obj_id" . PHP_EOL
1451 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1452 .
"LEFT JOIN object_reference ON object_reference.obj_id = object_data.obj_id " . PHP_EOL
1453 .
"WHERE object_reference.ref_id= " . $db->
quote($id,
"integer") . PHP_EOL
1457 "SELECT object_data.obj_id" . PHP_EOL
1458 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1459 .
"WHERE obj_id = " . $db->
quote($id,
"integer") . PHP_EOL
1464 $sql .=
" AND object_data.type = " . $db->
quote($type,
"text") . PHP_EOL;
1467 $result = $db->
query($sql);
1469 return (
bool) $db->
numRows($result);
1484 $db = $DIC->database();
1486 $order =
" ORDER BY title";
1490 $where =
"WHERE type = " . $db->
quote($obj_type,
"text");
1492 if (!is_null($owner)) {
1493 $where .=
" AND owner = " . $db->
quote($owner,
"integer");
1498 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
1499 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1503 $result = $db->
query($sql);
1506 if ($db->
numRows($result) > 0) {
1508 $row[
"desc"] = $row[
"description"];
1509 $arr[$row[
"obj_id"]] = $row;
1525 bool $show_path =
true 1529 $db = $DIC->database();
1530 $lng = $DIC->language();
1531 $obj_definition = $DIC[
"objDefinition"];
1534 "SELECT obj_data.title obj_title, path_data.title path_title, child" . PHP_EOL
1535 .
"FROM tree " . PHP_EOL
1536 .
"JOIN object_reference obj_ref ON child = obj_ref.ref_id " . PHP_EOL
1537 .
"JOIN object_data obj_data ON obj_ref.obj_id = obj_data.obj_id " . PHP_EOL
1538 .
"JOIN object_reference path_ref ON parent = path_ref.ref_id " . PHP_EOL
1539 .
"JOIN object_data path_data ON path_ref.obj_id = path_data.obj_id " . PHP_EOL
1540 .
"WHERE " . $db->
in(
"child", $ref_ids,
false,
"integer") . PHP_EOL
1541 .
"ORDER BY obj_data.title" . PHP_EOL
1545 if (!$obj_definition->
isPlugin($new_type)) {
1546 $options[0] = $lng->
txt(
'obj_' . $new_type .
'_select');
1552 if (strlen($title = $row->obj_title) > 40) {
1553 $title = substr($title, 0, 40) .
'...';
1557 if (strlen(
$path = $row->path_title) > 40) {
1561 $title .=
' (' . $lng->
txt(
'path') .
': ' .
$path .
')';
1564 $options[$row->child] =
$title;
1566 return $options ?: [];
1572 public function cloneObject(
int $target_id,
int $copy_id = 0,
bool $omit_tree =
false): ?
ilObject 1577 $ilUser = $DIC[
"ilUser"];
1578 $rbac_admin = $DIC[
"rbacadmin"];
1580 $class_name = (
'ilObj' . $this->obj_definition->getClassName($this->
getType()));
1584 $this->obj_log->debug($this->
getTitle());
1585 $this->obj_log->debug(
"isTreeCopyDisabled: " . $options->isTreeCopyDisabled());
1586 $this->obj_log->debug(
"omit_tree: " . $omit_tree);
1589 $new_obj =
new $class_name(0,
false);
1590 $new_obj->setOwner($ilUser->getId());
1591 $new_obj->title = $this->
getTitle();
1594 $new_obj->type = $this->
getType();
1597 $new_obj->create(
true);
1599 if (!$options->isTreeCopyDisabled() && !$omit_tree) {
1600 $title_with_suffix = $this->
appendCopyInfo($target_id, $copy_id, $new_obj->getId());
1601 $title = mb_strlen($title_with_suffix) < self::TITLE_LENGTH ? $title_with_suffix :
$title;
1602 $this->obj_log->debug(
"title incl. copy info: " . $title);
1603 $new_obj->setTitle($title);
1608 if ($options->isRootNode($this->getRefId())) {
1609 $new_obj->getObjectProperties()->storePropertyIsOnline(
1610 $new_obj->getObjectProperties()->getPropertyIsOnline()->withOffline()
1613 $new_obj->getObjectProperties()->storePropertyIsOnline(
1619 if (!$options->isTreeCopyDisabled() && !$omit_tree) {
1621 $new_obj->createReference();
1622 $new_obj->putInTree($target_id);
1623 $new_obj->setPermissions($target_id);
1638 "INSERT INTO dav_property" . PHP_EOL
1639 .
"(obj_id, node_id, ns, name, value)" . PHP_EOL
1640 .
"SELECT " . $this->db->quote($new_obj->getId(),
'integer') .
", node_id, ns, name, value " . PHP_EOL
1641 .
"FROM dav_property" . PHP_EOL
1642 .
"WHERE obj_id = " . $this->db->quote($this->getId(),
'integer') . PHP_EOL
1644 $this->db->manipulate($sql);
1647 $customIconFactory = $DIC[
'object.customicons.factory'];
1648 $customIcon = $customIconFactory->getByObjId($this->
getId(), $this->
getType());
1649 $customIcon->copy($new_obj->getId());
1651 $new_obj->getObjectProperties()->storePropertyTileImage(
1652 $new_obj->getObjectProperties()->getPropertyTileImage()->withTileImage(
1654 ->getTileImage()->cloneFor($new_obj->getId())
1658 $this->app_event_handler->raise(
1659 'components/ILIAS/ILIASObject',
1662 'object' => $new_obj,
1663 'cloned_from_object' => $this,
1679 if (!$cp_options->isRootNode($this->getRefId())) {
1686 $other_children_of_same_type = $this->tree->getChildsByType($target_id, $this->type);
1688 if ($obj_translations->getLanguages() === []) {
1690 fn(array $child):
string => $child[
'title'],
1691 $other_children_of_same_type
1695 $this->
lng->txt(
'copy_of_suffix'),
1696 $this->
lng->txt(
'copy_n_of_suffix'),
1707 array $other_children_of_same_type
1711 $this->translations_repository->getFor($child[
'obj_id']),
1712 $other_children_of_same_type
1715 $title_translations_per_lang = array_reduce(
1716 $nodes_translations,
1721 $installed_langs = $this->
lng->getInstalledLanguages();
1722 foreach ($obj_translations->
getLanguages() as $language) {
1723 $lang_code = $language->getLanguageCode();
1724 $suffix_lang = $lang_code;
1725 if (!in_array($suffix_lang, $installed_langs)) {
1726 $suffix_lang = $this->
lng->getDefaultLanguage();
1729 $language->withTitle(
1730 $this->appendNumberOfCopiesToTitle(
1731 $this->lng->txtlng(
'common',
'copy_of_suffix', $suffix_lang),
1732 $this->
lng->txtlng(
'common',
'copy_n_of_suffix', $suffix_lang),
1733 $language->getTitle(),
1734 $title_translations_per_lang[$lang_code] ?? []
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();
1760 string $copy_suffix,
1761 string $copy_n_suffix,
1763 array $other_titles_for_lang
1766 $title_with_suffix =
"{$title_without_suffix} {$copy_suffix}";
1767 if ($other_titles_for_lang === []
1768 || $this->
isTitleUnique($title_with_suffix, $other_titles_for_lang)) {
1769 return $title_with_suffix;
1772 for ($i = 2;
true;$i++) {
1773 $title_with_suffix = $title_without_suffix .
' ' . sprintf($copy_n_suffix, $i);
1774 if ($this->
isTitleUnique($title_with_suffix, $other_titles_for_lang)) {
1775 return $title_with_suffix;
1782 foreach ($nodes as $node) {
1783 if (($title === $node)) {
1798 $regexp_for_suffix = preg_replace(
1799 '/([\^$.\[\]|()?*+{}])/',
1804 $regexp_for_file_name =
'/' . preg_replace(
'/%1\\\\\$s/',
'([0-9]+)', $regexp_for_suffix) .
'$/';
1806 if (preg_match($regexp_for_file_name, $title, $matches)) {
1807 return substr($title, 0, -strlen($matches[0]));
1810 if (str_ends_with($title,
" {$copy_suffix}")) {
1837 $obj = $factory->getInstanceByRefId($target_id,
false);
1839 $obj->applyDidacticTemplate($tpl_id);
1850 $this->lom_services->derive()
1852 ->forObject($target_obj->
getId(), 0, $target_obj->
getType());
1856 public static function getIconForReference(
1861 bool $offline =
false 1865 $icon_factory = $DIC[
'ui.factory']->symbol()->icon();
1866 $irss = $DIC[
'resource_storage'];
1868 if ($obj_id ==
"" && $type ==
"") {
1882 $property_icon = LocalDIC::dic()[
'properties.additional.repository']->getFor($obj_id)->getPropertyIcon();
1883 $custom_icon = $property_icon->getCustomIcon();
1884 if ($custom_icon?->exists()) {
1885 return $custom_icon->getFullPath() .
'?tmp=' . filemtime($custom_icon->getFullPath());
1888 $file_type_specific_icon = $property_icon->getObjectTypeSpecificIcon($obj_id, $icon_factory, $irss);
1889 if ($file_type_specific_icon !==
null) {
1890 return $file_type_specific_icon->getIconPath();
1895 $path = $dtpl_icon_factory->getIconPathForReference($ref_id);
1897 $path = $dtpl_icon_factory->getIconPathForObject($obj_id);
1905 return self::getIconForType($type);
1907 return "./images/standard/icon_{$type}.svg";
1913 $objDefinition = $DIC[
'objDefinition'];
1914 if (!$objDefinition->isPluginTypeName($type)) {
1918 if ($objDefinition->getClassName($type) !==
'') {
1919 $class_name =
"il{$objDefinition->getClassName($type)}Plugin";
1920 $location = $objDefinition->getLocation($type);
1921 if (is_file(
$location .
"/class.{$class_name}.php")) {
1922 return call_user_func([$class_name,
'_getIcon'], $type);
1938 string $size =
"big",
1940 bool $offline =
false 1942 return self::getIconForReference(0, $obj_id, $size, $type, $offline);
1947 if ($this->process_auto_reating
1949 && method_exists($this,
"setRating")
1951 $this->setRating(
true);
1961 if (!$ref_id || !in_array($type, [
"file",
"lm",
"wiki"])) {
1973 if (!$parent_ref_id) {
1976 if ($parent_ref_id) {
1999 $objDefinition = $DIC[
"objDefinition"];
2000 $tree = $DIC->repositoryTree();
2006 $deps[
"del_ids"][$obj_id] = $obj_id;
2008 if (!$objDefinition->isPluginTypeName($type)) {
2009 $class_name =
"ilObj" . $objDefinition->getClassName($type);
2010 $odeps = call_user_func([$class_name,
"getDeletionDependencies"], $obj_id);
2011 if (is_array($odeps)) {
2025 foreach ($deps[
"del_ids"] as $obj_id) {
2026 unset($deps[
"dep"][$obj_id]);
2028 $deps = $deps[
"dep"];
2043 $db = $DIC->database();
2046 "SELECT obj_id, description" . PHP_EOL
2047 .
"FROM object_description" . PHP_EOL
2048 .
"WHERE " . $db->
in(
"obj_id", $obj_ids,
false,
"integer") . PHP_EOL
2050 $result = $db->
query($sql);
2054 $all[$row[
"obj_id"]] = $row[
"description"];
2063 $db = $DIC->database();
2064 $obj_definition = $DIC[
"objDefinition"];
2070 "SELECT od.obj_id, od.type, od.title" . PHP_EOL
2071 .
"FROM object_data od" . PHP_EOL
2072 .
"JOIN object_reference oref ON(oref.obj_id = od.obj_id)" . PHP_EOL
2073 .
"JOIN tree ON (tree.child = oref.ref_id)" . PHP_EOL
2077 $sql .=
"WHERE od.owner = " . $db->
quote($user_id,
"integer") . PHP_EOL;
2080 "LEFT JOIN usr_data ud ON (ud.usr_id = od.owner)" . PHP_EOL
2081 .
"WHERE (od.owner < " . $db->
quote(1,
"integer") . PHP_EOL
2082 .
"OR od.owner IS NULL OR ud.login IS NULL)" . PHP_EOL
2083 .
"AND od.owner <> " . $db->
quote(-1,
"integer") . PHP_EOL
2088 "AND " . $db->
in(
"od.type", $types,
false,
"text") . PHP_EOL
2089 .
"AND tree.tree > " . $db->
quote(0,
"integer") . PHP_EOL
2096 $all[$row[
"type"]][$row[
"obj_id"]] = $row[
"title"];
2108 $db = $DIC->database();
2110 if (!in_array($type, [
"catr",
"crsr",
"sess",
"grpr",
"prgr"])) {
2115 $missing_obj_ids = [];
2116 foreach ($obj_title_map as $obj_id => $title) {
2117 if (!trim($title)) {
2118 $missing_obj_ids[] = $obj_id;
2122 if (!
sizeof($missing_obj_ids)) {
2132 "SELECT oref.obj_id, od.type, od.title" . PHP_EOL
2133 .
"FROM object_data od" . PHP_EOL
2134 .
"JOIN container_reference oref ON (od.obj_id = oref.target_obj_id)" . PHP_EOL
2135 .
"AND " . $db->
in(
"oref.obj_id", $missing_obj_ids,
false,
"integer") . PHP_EOL
2137 $result = $db->
query($sql);
2140 $obj_title_map[$row[
"obj_id"]] = $row[
"title"];
2144 foreach ($missing_obj_ids as $obj_id) {
2146 $obj_title_map[$obj_id] = $sess->getFirstAppointment()->appointmentToString();
2155 $db = $DIC->database();
2158 "SELECT create_date" . PHP_EOL
2159 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
2160 .
"WHERE obj_id = " . $db->
quote($obj_id,
"integer") . PHP_EOL
2162 $result = $db->
query($sql);
2164 return $rec[
"create_date"];
2177 return $this->obj_definition->getSubObjects($this->type, $filter);
2184 $ilDB = $DIC->database();
2188 "SELECT obj_id FROM object_data" . PHP_EOL
2189 .
"WHERE type = 'typ'" . PHP_EOL
2190 .
"AND title = " .
$ilDB->quote($type,
'text') . PHP_EOL
2199 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)
appendCopyInfoToTranslations(Translations $obj_translations, array $other_children_of_same_type)
static _writeTitle(int $obj_id, string $title)
write title to db (static)
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 _getObjectsByType(string $obj_type="", ?int $owner=null)
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.
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)
TranslationsRepository $translations_repository
Class handles translation mode for an object.
appendCopyInfo(int $target_id, int $copy_id, int $new_obj_id)
Prepend Copy info if object with same name exists in that container.
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 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)
Aggregator $properties_aggregator
Properties $object_properties
static _getIdForImportId(string $import_id)
static _lookupObjId(int $ref_id)
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
static _resetDeletedDate(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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)
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...
withLanguage(Language $lang)
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!?
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.
$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
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
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)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
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)
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPresentationTitle()
get presentation title Normally same as title Overwritten for sessions
static _writeDescription(int $obj_id, string $desc)
write description to db (static)