19 declare(strict_types=1);
87 protected int $id = 0,
88 protected bool $referenced =
true 93 $this->
ilias = $DIC[
"ilias"];
94 $this->obj_definition = $DIC[
"objDefinition"];
95 $this->db = $DIC[
"ilDB"];
96 $this->log = $DIC[
"ilLog"];
98 $this->error = $DIC[
"ilErr"];
99 $this->tree = $DIC[
"tree"];
100 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
101 $this->object_dic = ilObjectDIC::dic();
103 $this->call_by_reference = $this->referenced;
105 if (isset($DIC[
"lng"])) {
106 $this->
lng = $DIC[
"lng"];
109 if (isset($DIC[
"ilUser"])) {
110 $this->
user = $DIC[
"ilUser"];
113 if (isset($DIC[
"rbacadmin"])) {
114 $this->rbac_admin = $DIC[
"rbacadmin"];
117 if (isset($DIC[
"rbacreview"])) {
118 $this->rbac_review = $DIC[
"rbacreview"];
122 $this->referenced =
false;
125 if ($this->referenced) {
138 if ($this->object_properties === null) {
139 $this->object_properties = $this->object_dic[
'object_properties_agregator']->getFor($this->
id, $this->type);
149 $this->object_properties = null;
158 return ($this->call_by_reference) ? true : $this->referenced;
167 $this->process_auto_reating =
true;
174 $ilUser = $DIC[
"ilUser"];
178 if ($this->referenced) {
179 if (!isset($this->ref_id)) {
180 $message =
"ilObject::read(): No ref_id given! (" . $this->type .
")";
181 $this->error->raiseError(
$message, $this->error->WARNING);
186 "SELECT od.obj_id, od.type, od.title, od.description, od.owner, od.create_date," . PHP_EOL
187 .
"od.last_update, od.import_id, ore.ref_id, ore.obj_id, ore.deleted, ore.deleted_by" . PHP_EOL
188 .
"FROM " . self::TABLE_OBJECT_DATA .
" od" . PHP_EOL
189 .
"JOIN object_reference ore ON od.obj_id = ore.obj_id" . PHP_EOL
190 .
"WHERE ore.ref_id = " . $this->db->quote($this->ref_id,
"integer") . PHP_EOL
193 $result = $this->db->query($sql);
196 if ($this->db->numRows($result) === 0) {
198 "ilObject::read(): Object with ref_id %s not found! (%s)",
202 $this->error->raiseError(
$message, $this->error->WARNING);
205 if (!isset($this->
id)) {
206 $message = sprintf(
"ilObject::read(): No obj_id given! (%s)", $this->type);
207 $this->error->raiseError(
$message, $this->error->WARNING);
211 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
212 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
213 .
"WHERE obj_id = " . $this->db->quote($this->
id,
"integer") . PHP_EOL
215 $result = $this->db->query($sql);
217 if ($this->db->numRows($result) === 0) {
218 $message = sprintf(
"ilObject::read(): Object with obj_id: %s (%s) not found!", $this->
id, $this->type);
222 $obj = $this->db->fetchAssoc($result);
224 $this->
id = (
int) $obj[
"obj_id"];
227 if ($this->type != $obj[
"type"] && $obj[
"type"] !=
"xxx") {
229 "ilObject::read(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
239 $this->type = (string) $obj[
"type"];
240 $this->title = (string) $obj[
"title"];
242 $this->untranslatedTitle = (string) $obj[
"title"];
245 $this->desc = (string) $obj[
"description"];
246 $this->owner = (
int) $obj[
"owner"];
247 $this->create_date = (string) $obj[
"create_date"];
248 $this->last_update = (string) $obj[
"last_update"];
249 $this->import_id = (string) $obj[
"import_id"];
251 if ($this->obj_definition->isRBACObject($this->getType())) {
253 "SELECT obj_id, description" . PHP_EOL
254 .
"FROM object_description" . PHP_EOL
255 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
258 $res = $this->db->query($sql);
260 $this->long_desc =
'';
262 if (($row->description ??
'') !==
'') {
269 $translation_type = $this->obj_definition->getTranslationType($this->type);
271 if ($translation_type ==
"sys") {
272 $this->title = $this->
lng->txt(
"obj_" . $this->type);
274 } elseif ($translation_type ==
"db") {
276 "SELECT title, description" . PHP_EOL
277 .
"FROM object_translation" . PHP_EOL
278 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
279 .
"AND lang_code = " . $this->db->quote($ilUser->getCurrentLanguage(),
'text') . PHP_EOL
281 $r = $this->db->query($sql);
284 $this->title = (string) $row->title;
285 $this->setDescription((
string) $row->description);
289 $this->object_properties = null;
305 $this->referenced =
true;
310 return $this->ref_id ?? 0;
318 final public function setType(
string $type): void
347 final public function setTitle(
string $title): void
353 $this->object_properties = $this->
getObjectProperties()->withPropertyTitleAndDescription($property);
355 $this->title = $property->getTitle();
369 ->getPropertyTitleAndDescription()->withDescription($description);
371 $this->object_properties = $this->
getObjectProperties()->withPropertyTitleAndDescription($property);
374 $this->desc = $property->getDescription();
375 $this->long_desc = $property->getLongDescription();
383 if ($this->long_desc !==
'') {
387 if ($this->desc !==
'') {
410 $db = $DIC->database();
413 "SELECT obj_id" . PHP_EOL
414 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
415 .
"WHERE import_id = " . $db->
quote($import_id,
"text") . PHP_EOL
416 .
"ORDER BY create_date DESC" . PHP_EOL
418 $result = $db->
query($sql);
420 if ($db->
numRows($result) == 0) {
426 return (
int) $row->obj_id;
436 $property_is_online = $property_is_online->withOffline();
439 $this->object_properties = $this->
getObjectProperties()->withPropertyIsOnline($property_is_online);
449 return $this->obj_definition->supportsOfflineHandling($this->
getType());
456 $db = $DIC->database();
459 "SELECT import_id" . PHP_EOL
460 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
461 .
"WHERE obj_id = " . $db->
quote($obj_id,
"integer") . PHP_EOL
466 return (
string) $row->import_id;
490 $lng = $DIC->language();
493 if ($owner_id != -1) {
499 $own_name = $lng->
txt(
"unknown");
500 if (is_object($owner)) {
501 $own_name = $owner->getFullname();
509 $this->owner = $usr_id;
535 $user = $DIC[
"ilUser"];
537 if (!isset($this->type)) {
538 $message = sprintf(
"%s::create(): No object type given!", get_class($this));
539 $this->error->raiseError(
$message, $this->error->WARNING);
542 $this->log->write(
"ilObject::create(), start");
548 } elseif (is_object($user)) {
549 $owner = $user->
getId();
552 $this->
id = $this->db->nextId(self::TABLE_OBJECT_DATA);
554 "obj_id" => [
"integer", $this->
getId()],
555 "type" => [
"text", $this->
getType()],
556 "title" => [
"text", $this->
getTitle()],
558 "owner" => [
"integer",
$owner],
559 "create_date" => [
"date", $this->db->now()],
560 "last_update" => [
"date", $this->db->now()],
564 $this->db->insert(self::TABLE_OBJECT_DATA, $values);
565 $this->object_properties = null;
568 if ($this->obj_definition->isRBACObject($this->getType())) {
573 $this->db->insert(
'object_description', $values);
581 if ($this->obj_definition->isOrgUnitPermissionType($this->type)) {
588 "SELECT last_update, create_date" . PHP_EOL
589 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
590 .
"WHERE obj_id = " . $this->db->quote($this->
id,
"integer") . PHP_EOL
592 $obj_set = $this->db->query($sql);
593 $obj_rec = $this->db->fetchAssoc($obj_set);
594 $this->last_update = $obj_rec[
"last_update"];
595 $this->create_date = $obj_rec[
"create_date"];
601 $this->log->write(sprintf(
602 "ilObject::create(), finished, obj_id: %s, type: %s, title: %s",
608 $this->app_event_handler->raise(
612 'obj_id' => $this->
id,
613 'obj_type' => $this->type
624 $this->app_event_handler->raise(
628 'obj_id' => $this->
getId(),
629 'obj_type' => $this->
getType(),
649 $this->app_event_handler->raise(
652 [
'obj_id' => $this->
getId(),
653 'obj_type' => $this->
getType(),
659 if ($element ==
'General') {
661 if (!is_object($md_gen = $md->getGeneral())) {
664 $this->
setTitle($md_gen->getTitle());
666 foreach ($md_gen->getDescriptionIds() as
$id) {
667 $md_des = $md_gen->getDescription(
$id);
690 $ilUser = $DIC[
"ilUser"];
693 $md_creator->setTitle($this->
getTitle());
694 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
696 $md_creator->setDescriptionLanguage($ilUser->getPref(
'language'));
697 $md_creator->setKeywordLanguage($ilUser->getPref(
'language'));
700 $md_creator->create();
718 $md_gen = $md->getGeneral();
723 $md_gen = $md->getGeneral();
726 $md_gen->setTitle($this->
getTitle());
729 $md_des_ids = $md_gen->getDescriptionIds();
730 if (count($md_des_ids) > 0) {
731 $md_des = $md_gen->getDescription($md_des_ids[0]);
773 "owner" => [
"integer", $this->
getOwner()],
774 "last_update" => [
"date", $this->db->now()]
778 "obj_id" => [
"integer", $this->
getId()]
781 $this->db->update(self::TABLE_OBJECT_DATA, $values, $where);
790 $db = $DIC->database();
794 "SELECT obj_id" . PHP_EOL
795 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
796 .
"WHERE import_id = " . $db->
quote($import_id,
"text") . PHP_EOL
797 .
"ORDER BY create_date DESC" . PHP_EOL
800 $result = $db->
query($sql);
803 return (
int) $row[
"obj_id"];
816 $db = $DIC->database();
819 "SELECT ref_id" . PHP_EOL
820 .
"FROM object_reference" . PHP_EOL
821 .
"WHERE obj_id = " . $db->
quote($id,
'integer') . PHP_EOL
824 $result = $db->
query($sql);
828 $ref[(
int) $row[
"ref_id"]] = (
int) $row[
"ref_id"];
837 return (
string) $DIC[
"ilObjDataCache"]->lookupTitle($obj_id);
846 return $DIC[
'ilObjDataCache']->lookupOfflineStatus($obj_id);
855 return (
int) $DIC[
"ilObjDataCache"]->lookupOwner($obj_id);
861 final public static function _getIdsForTitle(
string $title,
string $type =
'',
bool $partial_match =
false): array
864 $db = $DIC->database();
866 $where =
"title = " . $db->
quote($title,
"text");
867 if ($partial_match) {
868 $where = $db->
like(
"title",
"text",
'%' . $title .
'%');
872 "SELECT obj_id" . PHP_EOL
873 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
874 .
"WHERE " . $where . PHP_EOL
878 $sql .=
" AND type = " . $db->
quote($type,
"text");
881 $result = $db->
query($sql);
885 $object_ids[] = (
int) $row[
'obj_id'];
894 return (
string) $DIC[
"ilObjDataCache"]->lookupDescription($obj_id);
901 $last_update = $DIC[
"ilObjDataCache"]->lookupLastUpdate($obj_id);
913 $db = $DIC->database();
916 "SELECT MAX(last_update) as last_update" . PHP_EOL
917 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
918 .
"WHERE " . $db->
in(
"obj_id", $obj_ids,
false,
"integer") . PHP_EOL
921 $result = $db->
query($sql);
924 return (
string) $row[
"last_update"];
930 return $DIC[
"ilObjDataCache"]->lookupObjId($ref_id);
936 $db = $DIC->database();
939 "deleted" => [
"date", $db->
now()],
940 "deleted_by" => [
"integer", $deleted_by]
944 "ref_id" => [
"integer",
$ref_id]
947 $db->
update(
"object_reference", $values, $where);
956 $db = $DIC->database();
959 "UPDATE object_reference" . PHP_EOL
960 .
"SET deleted = " . $db->
now() .
", " . PHP_EOL
961 .
"deleted_by = " . $db->
quote($user_id,
"integer") . PHP_EOL
962 .
"WHERE " . $db->
in(
"ref_id", $ref_ids,
false,
"integer") . PHP_EOL;
970 $db = $DIC->database();
973 "deleted" => [
"timestamp", null],
974 "deleted_by" => [
"integer", 0]
978 "ref_id" => [
"integer",
$ref_id]
981 $db->
update(
"object_reference", $values, $where);
987 $db = $DIC->database();
990 "SELECT deleted" . PHP_EOL
991 .
"FROM object_reference" . PHP_EOL
992 .
"WHERE ref_id = " . $db->
quote($ref_id,
"integer") . PHP_EOL
994 $result = $db->
query($sql);
997 return $row[
"deleted"] ?? null;
1003 final public static function _writeTitle(
int $obj_id,
string $title): void
1006 $db = $DIC->database();
1009 "title" => [
"text",
$title],
1010 "last_update" => [
"date", $db->
now()]
1014 "obj_id" => [
"integer", $obj_id]
1017 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1027 $db = $DIC->database();
1028 $obj_definition = $DIC[
"objDefinition"];
1033 "description" => [
"text",
$desc],
1034 "last_update" => [
"date", $db->
now()]
1038 "obj_id" => [
"integer", $obj_id]
1041 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1047 "SELECT obj_id, description" . PHP_EOL
1048 .
"FROM object_description" . PHP_EOL
1049 .
"WHERE obj_id = " . $db->
quote($obj_id,
'integer') . PHP_EOL
1051 $result = $db->
query($sql);
1053 if ($result->numRows()) {
1055 "description" => [
"clob",
$desc]
1057 $db->
update(
"object_description", $values, $where);
1060 "description" => [
"clob",
$desc],
1061 "obj_id" => [
"integer",$obj_id]
1063 $db->
insert(
"object_description", $values);
1074 $db = $DIC->database();
1078 "last_update" => [
"date", $db->
now()]
1082 "obj_id" => [
"integer", $obj_id]
1085 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1093 return $DIC[
"ilObjDataCache"]->lookupType($DIC[
"ilObjDataCache"]->lookupObjId($id));
1096 return $DIC[
"ilObjDataCache"]->lookupType($id);
1102 return $DIC->repositoryTree()->isSaved($ref_id);
1111 foreach ($ref_ids as $ref_id) {
1123 return $DIC[
"ilObjDataCache"]->lookupObjId($ref_id);
1136 $db = $DIC->database();
1139 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
1140 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1141 .
"WHERE type = " . $db->
quote($type,
"text") . PHP_EOL
1143 $result = $db->
query($sql);
1148 $objects[$row[
"title"] .
"." . $row[
"obj_id"]] = [
1149 "id" => $row[
"obj_id"],
1150 "type" => $row[
"type"],
1151 "title" => $row[
"title"],
1152 "description" => $row[
"description"]
1168 $this->tree->insertNode($this->
getRefId(), $parent_ref_id);
1171 $log_entry = sprintf(
1172 "ilObject::putInTree(), parent_ref: %s, ref_id: %s, obj_id: %s, type: %s, title: %s",
1180 $this->log->write($log_entry);
1182 $this->app_event_handler->raise(
1187 'obj_type' => $this->
getType(),
1188 'obj_id' => $this->
getId(),
1189 'parent_ref_id' => $parent_ref_id
1207 $parent_roles = $this->rbac_review->getParentRoleIds($parent_ref_id);
1208 foreach ($parent_roles as $parent_role) {
1212 $operations = $this->rbac_review->getOperationsOfRole(
1213 (
int) $parent_role[
'obj_id'],
1215 (
int) $parent_role[
'parent']
1217 $this->rbac_admin->grantPermission(
1218 (
int) $parent_role[
'obj_id'],
1231 if (!isset($this->
id)) {
1232 $message =
"ilObject::createNewReference(): No obj_id given!";
1233 $this->error->raiseError(
$message, $this->error->WARNING);
1236 $next_id = $this->db->nextId(
'object_reference');
1239 "ref_id" => [
"integer", $next_id],
1240 "obj_id" => [
"integer", $this->
getId()]
1243 $this->db->insert(
"object_reference", $values);
1245 $this->ref_id = $next_id;
1246 $this->referenced =
true;
1253 if (!isset($this->
id)) {
1254 $message =
"ilObject::countReferences(): No obj_id given!";
1255 $this->error->raiseError(
$message, $this->error->WARNING);
1259 "SELECT COUNT(ref_id) num" . PHP_EOL
1260 .
"FROM object_reference" . PHP_EOL
1261 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
1264 $res = $this->db->query($sql);
1265 $row = $this->db->fetchObject(
$res);
1267 return (
int) $row->num;
1278 public function delete():
bool 1281 $rbac_admin = $DIC[
"rbacadmin"];
1288 if ($this->type != $type) {
1289 $log_entry = sprintf(
1290 "ilObject::delete(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
1296 $this->log->write($log_entry);
1297 $this->error->raiseError(
1298 sprintf(
"ilObject::delete(): Type mismatch. (%s/%s)", $this->type, $this->
id),
1299 $this->error->WARNING
1303 $this->app_event_handler->raise(
'Services/Object',
'beforeDeletion', [
'object' => $this]);
1306 "DELETE FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1307 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") . PHP_EOL
1309 $this->db->manipulate($sql);
1312 "DELETE FROM object_description" . PHP_EOL
1313 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") . PHP_EOL
1315 $this->db->manipulate($sql);
1319 "ilObject::delete(), deleted object, obj_id: %s, type: %s, title: %s",
1331 $news_item->deleteNewsOfContext($this->
getId(), $this->
getType());
1338 "DELETE FROM dav_property" . PHP_EOL
1339 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
'integer') . PHP_EOL
1341 $this->db->manipulate($sql);
1352 "ilObject::delete(), object not deleted, number of references: %s, obj_id: %s, type: %s, title: %s",
1362 if ($this->referenced) {
1365 $this->app_event_handler->raise(
'Services/Object',
'deleteReference', [
'ref_id' => $this->
getRefId()]);
1368 "DELETE FROM object_reference" . PHP_EOL
1369 .
"WHERE ref_id = " . $this->db->quote($this->
getRefId(),
'integer') . PHP_EOL
1371 $this->db->manipulate($sql);
1375 "ilObject::delete(), reference deleted, ref_id: %s, obj_id: %s, type: %s, title: %s",
1396 if ($this->referenced) {
1421 $action->setRefId($this->
getRefId());
1437 public static function _exists(
int $id,
bool $reference =
false, ?
string $type = null): bool
1440 $db = $DIC->database();
1444 "SELECT object_data.obj_id" . PHP_EOL
1445 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1446 .
"LEFT JOIN object_reference ON object_reference.obj_id = object_data.obj_id " . PHP_EOL
1447 .
"WHERE object_reference.ref_id= " . $db->
quote($id,
"integer") . PHP_EOL
1451 "SELECT object_data.obj_id" . PHP_EOL
1452 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1453 .
"WHERE obj_id = " . $db->
quote($id,
"integer") . PHP_EOL
1458 $sql .=
" AND object_data.type = " . $db->
quote($type,
"text") . PHP_EOL;
1461 $result = $db->
query($sql);
1463 return (
bool) $db->
numRows($result);
1478 $db = $DIC->database();
1480 $order =
" ORDER BY title";
1484 $where =
"WHERE type = " . $db->
quote($obj_type,
"text");
1486 if (!is_null($owner)) {
1487 $where .=
" AND owner = " . $db->
quote($owner,
"integer");
1492 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
1493 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1497 $result = $db->
query($sql);
1500 if ($db->
numRows($result) > 0) {
1502 $row[
"desc"] = $row[
"description"];
1503 $arr[$row[
"obj_id"]] = $row;
1519 bool $show_path =
true 1523 $db = $DIC->database();
1524 $lng = $DIC->language();
1525 $obj_definition = $DIC[
"objDefinition"];
1528 "SELECT obj_data.title obj_title, path_data.title path_title, child" . PHP_EOL
1529 .
"FROM tree " . PHP_EOL
1530 .
"JOIN object_reference obj_ref ON child = obj_ref.ref_id " . PHP_EOL
1531 .
"JOIN object_data obj_data ON obj_ref.obj_id = obj_data.obj_id " . PHP_EOL
1532 .
"JOIN object_reference path_ref ON parent = path_ref.ref_id " . PHP_EOL
1533 .
"JOIN object_data path_data ON path_ref.obj_id = path_data.obj_id " . PHP_EOL
1534 .
"WHERE " . $db->
in(
"child", $ref_ids,
false,
"integer") . PHP_EOL
1535 .
"ORDER BY obj_data.title" . PHP_EOL
1539 if (!$obj_definition->
isPlugin($new_type)) {
1540 $options[0] = $lng->
txt(
'obj_' . $new_type .
'_select');
1546 if (strlen($title = $row->obj_title) > 40) {
1547 $title = substr($title, 0, 40) .
'...';
1551 if (strlen(
$path = $row->path_title) > 40) {
1555 $title .=
' (' . $lng->
txt(
'path') .
': ' .
$path .
')';
1558 $options[$row->child] =
$title;
1560 return $options ?: [];
1566 public function cloneObject(
int $target_id,
int $copy_id = 0,
bool $omit_tree =
false): ?
ilObject 1571 $ilUser = $DIC[
"ilUser"];
1572 $rbac_admin = $DIC[
"rbacadmin"];
1574 $class_name = (
'ilObj' . $this->obj_definition->getClassName($this->
getType()));
1579 $this->obj_log->debug($title);
1580 $this->obj_log->debug(
"isTreeCopyDisabled: " . $options->isTreeCopyDisabled());
1581 $this->obj_log->debug(
"omit_tree: " . $omit_tree);
1582 if (!$options->isTreeCopyDisabled() && !$omit_tree) {
1583 $title_with_suffix = $this->
appendCopyInfo($target_id, $copy_id);
1584 $title = mb_strlen($title_with_suffix) < self::TITLE_LENGTH ? $title_with_suffix :
$title;
1585 $this->obj_log->debug(
"title incl. copy info: " . $title);
1590 $new_obj =
new $class_name(0,
false);
1591 $new_obj->setOwner($ilUser->getId());
1592 $new_obj->title =
$title;
1595 $new_obj->type = $this->
getType();
1598 $new_obj->create(
true);
1601 if ($options->isRootNode($this->getRefId())) {
1602 $new_obj->getObjectProperties()->storePropertyIsOnline(
1603 $new_obj->getObjectProperties()->getPropertyIsOnline()->withOffline()
1606 $new_obj->getObjectProperties()->storePropertyIsOnline(
1612 if (!$options->isTreeCopyDisabled() && !$omit_tree) {
1614 $new_obj->createReference();
1615 $new_obj->putInTree($target_id);
1616 $new_obj->setPermissions($target_id);
1631 "INSERT INTO dav_property" . PHP_EOL
1632 .
"(obj_id, node_id, ns, name, value)" . PHP_EOL
1633 .
"SELECT " . $this->db->quote($new_obj->getId(),
'integer') .
", node_id, ns, name, value " . PHP_EOL
1634 .
"FROM dav_property" . PHP_EOL
1635 .
"WHERE obj_id = " . $this->db->quote($this->getId(),
'integer') . PHP_EOL
1637 $this->db->manipulate($sql);
1640 $customIconFactory = $DIC[
'object.customicons.factory'];
1641 $customIcon = $customIconFactory->getByObjId($this->
getId(), $this->
getType());
1642 $customIcon->copy($new_obj->getId());
1644 $new_obj->getObjectProperties()->storePropertyTileImage(
1645 $new_obj->getObjectProperties()->getPropertyTileImage()->withTileImage(
1647 ->getTileImage()->cloneFor($new_obj->getId())
1651 $this->app_event_handler->raise(
1655 'object' => $new_obj,
1656 'cloned_from_object' => $this,
1669 if (!$cp_options->isRootNode($this->getRefId())) {
1675 $other_children_of_same_type = $this->tree->getChildsByType($target_id, $this->type);
1677 if ($obj_translations->getLanguages() === []) {
1678 $existing_titles = array_map(
1679 fn(array $child):
string => $child[
'title'],
1680 $other_children_of_same_type
1684 $this->
lng->txt(
'copy_of_suffix'),
1685 $this->
lng->txt(
'copy_n_of_suffix'),
1696 array $other_children_of_same_type
1698 $nodes_translations = array_map(
1701 $other_children_of_same_type
1704 $title_translations_per_lang = array_reduce(
1705 $nodes_translations,
1710 $new_languages = [];
1711 $installed_langs = $this->
lng->getInstalledLanguages();
1712 foreach ($obj_translations->
getLanguages() as $language) {
1713 $lang_code = $language->getLanguageCode();
1714 $suffix_lang = $lang_code;
1715 if (!in_array($suffix_lang, $installed_langs)) {
1716 $suffix_lang = $this->
lng->getDefaultLanguage();
1718 $language->setTitle(
1720 $this->
lng->txtlng(
'common',
'copy_of_suffix', $suffix_lang),
1721 $this->
lng->txtlng(
'common',
'copy_n_of_suffix', $suffix_lang),
1722 $language->getTitle(),
1723 $title_translations_per_lang[$lang_code] ?? []
1726 $new_languages[$lang_code] = $language;
1736 $langs = $nt->getLanguages();
1737 foreach ($langs as
$lang) {
1738 if (!array_key_exists($lang->getLanguageCode(), $npl)) {
1739 $npl[$lang->getLanguageCode()] = [];
1741 $npl[$lang->getLanguageCode()][] = $lang->getTitle();
1748 string $copy_suffix,
1749 string $copy_n_suffix,
1751 array $other_titles_for_lang
1754 $title_with_suffix =
"{$title_without_suffix} {$copy_suffix}";
1755 if ($other_titles_for_lang === []
1756 || $this->
isTitleUnique($title_with_suffix, $other_titles_for_lang)) {
1757 return $title_with_suffix;
1760 for ($i = 2;
true;$i++) {
1761 $title_with_suffix = $title_without_suffix .
' ' . sprintf($copy_n_suffix, $i);
1762 if ($this->
isTitleUnique($title_with_suffix, $other_titles_for_lang)) {
1763 return $title_with_suffix;
1770 foreach ($nodes as $node) {
1771 if (($title === $node)) {
1786 $regexp_for_suffix = preg_replace(
1787 '/([\^$.\[\]|()?*+{}])/',
1792 $regexp_for_file_name =
'/' . preg_replace(
'/%1\\\\\$s/',
'([0-9]+)', $regexp_for_suffix) .
'$/';
1794 if (preg_match($regexp_for_file_name, $title, $matches)) {
1795 return substr($title, 0, -strlen($matches[0]));
1798 if (str_ends_with($title,
" {$copy_suffix}")) {
1825 $obj = $factory->getInstanceByRefId($target_id,
false);
1827 $obj->applyDidacticTemplate($tpl_id);
1839 $md->cloneMD($target_obj->
getId(), 0, $target_obj->
getType());
1843 public static function getIconForReference(
1848 bool $offline =
false 1852 $objDefinition = $DIC[
'objDefinition'];
1853 $icon_factory = $DIC[
'ui.factory']->symbol()->icon();
1854 $irss = $DIC[
'resource_storage'];
1856 if ($obj_id ==
"" && $type ==
"") {
1870 $property_icon = ilObjectDIC::dic()[
'additional_properties_repository']->getFor($obj_id)->getPropertyIcon();
1871 $custom_icon = $property_icon->getCustomIcon();
1872 if ($custom_icon?->exists()) {
1873 return $custom_icon->getFullPath() .
'?tmp=' . filemtime($custom_icon->getFullPath());
1876 $file_type_specific_icon = $property_icon->getObjectTypeSpecificIcon($obj_id, $icon_factory, $irss);
1877 if ($file_type_specific_icon !== null) {
1878 return $file_type_specific_icon->getIconPath();
1883 $path = $dtpl_icon_factory->getIconPathForReference($ref_id);
1885 $path = $dtpl_icon_factory->getIconPathForObject($obj_id);
1893 if ($objDefinition->isPluginTypeName($type)) {
1894 if ($objDefinition->getClassName($type) !=
"") {
1895 $class_name =
"il" . $objDefinition->getClassName($type) .
'Plugin';
1896 $location = $objDefinition->getLocation($type);
1897 if (is_file(
$location .
"/class." . $class_name .
".php")) {
1898 return call_user_func([$class_name,
"_getIcon"], $type, $size, $obj_id);
1906 return "./images/standard/icon_" . $type .
".svg";
1920 string $size =
"big",
1922 bool $offline =
false 1924 return self::getIconForReference(0, $obj_id, $size, $type, $offline);
1929 if ($this->process_auto_reating
1931 && method_exists($this,
"setRating")
1933 $this->setRating(
true);
1943 if (!$ref_id || !in_array($type, [
"file",
"lm",
"wiki"])) {
1955 if (!$parent_ref_id) {
1958 if ($parent_ref_id) {
1981 $objDefinition = $DIC[
"objDefinition"];
1982 $tree = $DIC->repositoryTree();
1988 $deps[
"del_ids"][$obj_id] = $obj_id;
1990 if (!$objDefinition->isPluginTypeName($type)) {
1991 $class_name =
"ilObj" . $objDefinition->getClassName($type);
1992 $odeps = call_user_func([$class_name,
"getDeletionDependencies"], $obj_id);
1993 if (is_array($odeps)) {
2007 foreach ($deps[
"del_ids"] as $obj_id) {
2008 unset($deps[
"dep"][$obj_id]);
2010 $deps = $deps[
"dep"];
2025 $db = $DIC->database();
2028 "SELECT obj_id, description" . PHP_EOL
2029 .
"FROM object_description" . PHP_EOL
2030 .
"WHERE " . $db->
in(
"obj_id", $obj_ids,
false,
"integer") . PHP_EOL
2032 $result = $db->
query($sql);
2036 $all[$row[
"obj_id"]] = $row[
"description"];
2045 $db = $DIC->database();
2046 $obj_definition = $DIC[
"objDefinition"];
2052 "SELECT od.obj_id, od.type, od.title" . PHP_EOL
2053 .
"FROM object_data od" . PHP_EOL
2054 .
"JOIN object_reference oref ON(oref.obj_id = od.obj_id)" . PHP_EOL
2055 .
"JOIN tree ON (tree.child = oref.ref_id)" . PHP_EOL
2059 $sql .=
"WHERE od.owner = " . $db->
quote($user_id,
"integer") . PHP_EOL;
2062 "LEFT JOIN usr_data ud ON (ud.usr_id = od.owner)" . PHP_EOL
2063 .
"WHERE (od.owner < " . $db->
quote(1,
"integer") . PHP_EOL
2064 .
"OR od.owner IS NULL OR ud.login IS NULL)" . PHP_EOL
2065 .
"AND od.owner <> " . $db->
quote(-1,
"integer") . PHP_EOL
2070 "AND " . $db->
in(
"od.type", $types,
false,
"text") . PHP_EOL
2071 .
"AND tree.tree > " . $db->
quote(0,
"integer") . PHP_EOL
2078 $all[$row[
"type"]][$row[
"obj_id"]] = $row[
"title"];
2090 $db = $DIC->database();
2092 if (!in_array($type, [
"catr",
"crsr",
"sess",
"grpr",
"prgr"])) {
2097 $missing_obj_ids = [];
2098 foreach ($obj_title_map as $obj_id => $title) {
2099 if (!trim($title)) {
2100 $missing_obj_ids[] = $obj_id;
2104 if (!
sizeof($missing_obj_ids)) {
2114 "SELECT oref.obj_id, od.type, od.title" . PHP_EOL
2115 .
"FROM object_data od" . PHP_EOL
2116 .
"JOIN container_reference oref ON (od.obj_id = oref.target_obj_id)" . PHP_EOL
2117 .
"AND " . $db->
in(
"oref.obj_id", $missing_obj_ids,
false,
"integer") . PHP_EOL
2119 $result = $db->
query($sql);
2122 $obj_title_map[$row[
"obj_id"]] = $row[
"title"];
2126 foreach ($missing_obj_ids as $obj_id) {
2128 $obj_title_map[$obj_id] = $sess->getFirstAppointment()->appointmentToString();
2137 $db = $DIC->database();
2140 "SELECT create_date" . PHP_EOL
2141 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
2142 .
"WHERE obj_id = " . $db->
quote($obj_id,
"integer") . PHP_EOL
2144 $result = $db->
query($sql);
2146 return $rec[
"create_date"];
2159 return $this->obj_definition->getSubObjects($this->type, $filter);
2166 $ilDB = $DIC->database();
2170 "SELECT obj_id FROM object_data" . PHP_EOL
2171 .
"WHERE type = 'typ'" . PHP_EOL
2172 .
"AND title = " .
$ilDB->quote($type,
'text') . PHP_EOL
2181 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 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 delete(int $a_ref_id)
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...
Class ChatMainBarProvider .
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
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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 formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
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 _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
parses the objects.xml it handles the xml-description of all ilias objects
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)
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 _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)
header include for all ilias files.
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
Error Handling & global info handling.
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.
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
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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)
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...