ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjectListGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 define("IL_LIST_AS_TRIGGER", "trigger");
5 define("IL_LIST_FULL", "full");
6 require_once('./Services/Repository/classes/class.ilObjectPlugin.php');
7 
24 {
28  protected $access;
29 
33  protected $lng;
34 
38  protected $user;
39 
43  protected $obj_definition;
44 
48  protected $tree;
49 
53  protected $settings;
54 
58  protected $tpl;
59 
60  const DETAILS_MINIMAL = 10;
61  const DETAILS_SEARCH = 20 ;
62  const DETAILS_ALL = 30;
63 
64  const CONTEXT_REPOSITORY = 1;
65  const CONTEXT_WORKSPACE = 2;
68  const CONTEXT_SEARCH = 6;
69 
73 
74  public $ctrl;
75  public $description_enabled = true;
76  public $preconditions_enabled = true;
77  public $properties_enabled = true;
79  public $commands_enabled = true;
80  public $cust_prop = array();
81  public $cust_commands = array();
82  public $info_screen_enabled = false;
83  public $condition_depth = 0;
84  public $std_cmd_only = false;
85  public $sub_item_html = array();
86  public $multi_download_enabled = false;
87  public $download_checkbox_state = self::DOWNLOAD_CHECKBOX_NONE;
88 
89  protected $obj_id;
90  protected $ref_id;
91  protected $type;
92  protected $sub_obj_id;
93  protected $sub_obj_type;
94 
95  protected $substitutions = null;
96  protected $substitutions_enabled = false;
97 
98  protected $icons_enabled = false;
99  protected $checkboxes_enabled = false;
100  protected $position_enabled = false;
101  protected $progress_enabled = false;
102  protected $item_detail_links_enabled = false;
103  protected $item_detail_links = array();
104  protected $item_detail_links_intro = '';
105 
106  protected $search_fragments_enabled = false;
107  protected $search_fragment = '';
108  protected $path_linked = false;
109 
110  protected $enabled_relevance = false;
111  protected $relevance = 0;
112 
113  protected $expand_enabled = false;
114  protected $is_expanded = true;
115  protected $bold_title = false;
116 
117  protected $copy_enabled = true;
118 
119  protected $details_level = self::DETAILS_ALL;
120 
121  protected $reference_ref_id = false;
122  protected $separate_commands = false;
123  protected $search_fragment_enabled = false;
124  protected $additional_information = false;
125  protected $static_link_enabled = false;
126 
127  protected $repository_transfer_enabled = false;
128  protected $shared = false;
129  protected $restrict_to_goto = false;
130 
131  protected $comments_enabled = false;
132  protected $comments_settings_enabled = false;
133  protected $notes_enabled = false;
134  protected $tags_enabled = false;
135 
136  protected $rating_enabled = false;
137  protected $rating_categories_enabled = false;
138  protected $rating_text = false;
139  protected $rating_ctrl_path = false;
140 
141  protected $timings_enabled = true;
142  protected $force_visible_only = false;
143  protected $prevent_duplicate_commands = array();
144  protected $parent_ref_id;
145  protected $context;
146 
147  protected static $cnt_notes = array();
148  protected static $cnt_tags = array();
149  protected static $tags = array();
150  protected static $comments_activation = array();
151  protected static $preload_done = false;
152 
153  protected $title_link = '';
154  protected $title_link_disabled = false;
155 
156  protected static $js_unique_id = 0;
157 
158 
159  protected static $tpl_file_name = "tpl.container_list_item.html";
160  protected static $tpl_component = "Services/Container";
161 
165  protected $path_gui = null;
166 
170  protected $ui;
171 
176  public function __construct($a_context = self::CONTEXT_REPOSITORY)
177  {
178  global $DIC;
179  $this->access = $DIC->access();
180  $this->user = $DIC->user();
181  $this->obj_definition = $DIC["objDefinition"];
182  $this->tree = $DIC->repositoryTree();
183  $this->settings = $DIC->settings();
184 
185  $this->ui = $DIC->ui();
186  $this->rbacsystem = $DIC->rbac()->system();
187  $this->ctrl = $DIC->ctrl();
188  $this->lng = $DIC->language();
189  $this->mode = IL_LIST_FULL;
190  $this->path_enabled = false;
191  $this->context = $a_context;
192 
193  $this->enableComments(false);
194  $this->enableNotes(false);
195  $this->enableTags(false);
196 
197  // unique js-ids
198  $this->setParentRefId((int) $_REQUEST["ref_id"]);
199 
200  //echo "list";
201  $this->init();
202 
203  include_once('Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
204  $this->ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
205 
206  $this->lng->loadLanguageModule("obj");
207  }
208 
209 
216  public function setContainerObject($container_obj)
217  {
218  $this->container_obj = $container_obj;
219  }
220 
228  public function getContainerObject()
229  {
230  return $this->container_obj;
231  }
232 
233 
239  public function init()
240  {
241  // Create static links for default command (linked title) or not
242  $this->static_link_enabled = true;
243  $this->delete_enabled = true;
244  $this->cut_enabled = true;
245  $this->subscribe_enabled = true;
246  $this->link_enabled = false;
247  $this->copy_enabled = false;
248  $this->progress_enabled = false;
249  $this->notice_properties_enabled = true;
250  $this->info_screen_enabled = false;
251  $this->type = ""; // "cat", "course", ...
252  $this->gui_class_name = ""; // "ilobjcategorygui", "ilobjcoursegui", ...
253 
254  // general commands array, e.g.
255  include_once('./Services/Object/classes/class.ilObjectAccess.php');
256  $this->commands = ilObjectAccess::_getCommands();
257  }
258 
259  // Single get set methods
266  public function enableProperties($a_status)
267  {
268  $this->properties_enabled = $a_status;
269 
270  return;
271  }
278  public function getPropertiesStatus()
279  {
281  }
288  public function enablePreconditions($a_status)
289  {
290  $this->preconditions_enabled = $a_status;
291 
292  return;
293  }
294 
295  public function getNoticePropertiesStatus()
296  {
298  }
299 
306  public function enableNoticeProperties($a_status)
307  {
308  $this->notice_properties_enabled = $a_status;
309 
310  return;
311  }
318  public function getPreconditionsStatus()
319  {
321  }
328  public function enableDescription($a_status)
329  {
330  $this->description_enabled = $a_status;
331 
332  return;
333  }
340  public function getDescriptionStatus()
341  {
343  }
344 
351  public function getSearchFragmentStatus()
352  {
354  }
355 
362  public function enableSearchFragments($a_status)
363  {
364  $this->search_fragment_enabled = $a_status;
365 
366  return;
367  }
368 
374  public function enableLinkedPath($a_status)
375  {
376  $this->path_linked = $a_status;
377  }
378 
383  public function enabledRelevance()
384  {
386  }
387 
392  public function enableRelevance($a_status)
393  {
394  $this->enabled_relevance = $a_status;
395  }
396 
402  public function setRelevance($a_rel)
403  {
404  $this->relevance = $a_rel;
405  }
406 
412  public function getRelevance()
413  {
414  return $this->relevance;
415  }
416 
422  public function enableIcon($a_status)
423  {
424  $this->icons_enabled = $a_status;
425  }
426 
432  public function getIconStatus()
433  {
434  return $this->icons_enabled;
435  }
436 
442  public function enableCheckbox($a_status)
443  {
444  $this->checkboxes_enabled = $a_status;
445  }
446 
452  public function getCheckboxStatus()
453  {
455  }
456 
462  public function enableExpand($a_status)
463  {
464  $this->expand_enabled = $a_status;
465  }
466 
472  public function getExpandStatus()
473  {
474  return $this->expand_enabled;
475  }
476 
477  public function setExpanded($a_status)
478  {
479  $this->is_expanded = $a_status;
480  }
481 
482  public function isExpanded()
483  {
484  return $this->is_expanded;
485  }
492  public function setPositionInputField($a_field_index, $a_position_value)
493  {
494  $this->position_enabled = true;
495  $this->position_field_index = $a_field_index;
496  $this->position_value = $a_position_value;
497  }
498 
505  public function enableDelete($a_status)
506  {
507  $this->delete_enabled = $a_status;
508 
509  return;
510  }
517  public function getDeleteStatus()
518  {
519  return $this->delete_enabled;
520  }
521 
528  public function enableCut($a_status)
529  {
530  $this->cut_enabled = $a_status;
531 
532  return;
533  }
539  public function getCutStatus()
540  {
541  return $this->cut_enabled;
542  }
543 
550  public function enableCopy($a_status)
551  {
552  $this->copy_enabled = $a_status;
553 
554  return;
555  }
561  public function getCopyStatus()
562  {
563  return $this->copy_enabled;
564  }
565 
572  public function enableSubscribe($a_status)
573  {
574  $this->subscribe_enabled = $a_status;
575 
576  return;
577  }
583  public function getSubscribeStatus()
584  {
585  return $this->subscribe_enabled;
586  }
587 
594  public function enableLink($a_status)
595  {
596  $this->link_enabled = $a_status;
597 
598  return;
599  }
605  public function getLinkStatus()
606  {
607  return $this->link_enabled;
608  }
609 
617  public function enablePath($a_path, $a_start_node = null, \ilPathGUI $path_gui = null)
618  {
619  $this->path_enabled = $a_path;
620  $this->path_start_node = (int) $a_start_node;
621  $this->path_gui = $path_gui;
622  }
623 
629  public function getPathStatus()
630  {
631  return $this->path_enabled;
632  }
633 
640  public function enableCommands($a_status, $a_std_only = false)
641  {
642  $this->commands_enabled = $a_status;
643  $this->std_cmd_only = $a_std_only;
644  }
650  public function getCommandsStatus()
651  {
653  }
654 
661  public function enableInfoScreen($a_info_screen)
662  {
663  $this->info_screen_enabled = $a_info_screen;
664  }
665 
671  public function addSubItemHTML($a_html)
672  {
673  $this->sub_item_html[] = $a_html;
674  }
675 
681  public function getInfoScreenStatus()
682  {
684  }
685 
693  public function enableProgressInfo($a_status)
694  {
695  $this->progress_enabled = $a_status;
696  }
697 
705  public function getProgressInfoStatus()
706  {
708  }
709 
717  public function enableSubstitutions($a_status)
718  {
719  $this->substitutions_enabled = $a_status;
720  }
721 
728  public function getSubstitutionStatus()
729  {
731  }
732 
741  public function enableItemDetailLinks($a_status)
742  {
743  $this->item_detail_links_enabled = $a_status;
744  }
745 
752  public function getItemDetailLinkStatus()
753  {
755  }
756 
764  public function setItemDetailLinks($a_detail_links, $a_intro_txt = '')
765  {
766  $this->item_detail_links = $a_detail_links;
767  $this->item_detail_links_intro = $a_intro_txt;
768  }
769 
777  public function insertItemDetailLinks()
778  {
779  if (!count($this->item_detail_links)) {
780  return true;
781  }
782  if (strlen($this->item_detail_links_intro)) {
783  $this->tpl->setCurrentBlock('item_detail_intro');
784  $this->tpl->setVariable('ITEM_DETAIL_INTRO_TXT', $this->item_detail_links_intro);
785  $this->tpl->parseCurrentBlock();
786  }
787 
788  foreach ($this->item_detail_links as $info) {
789  $this->tpl->setCurrentBlock('item_detail_link');
790  $this->tpl->setVariable('ITEM_DETAIL_LINK_TARGET', $info['target']);
791  $this->tpl->setVariable('ITEM_DETAIL_LINK_DESC', $info['desc']);
792  $this->tpl->setVariable('ITEM_DETAIL_LINK_HREF', $info['link']);
793  $this->tpl->setVariable('ITEM_DETAIL_LINK_NAME', $info['name']);
794  $this->tpl->parseCurrentBlock();
795  }
796  $this->tpl->setCurrentBlock('item_detail_links');
797  $this->tpl->parseCurrentBlock();
798  }
799 
800 
801 
806  public function setTitle($a_title)
807  {
808  $this->title = $a_title;
809  }
810 
816  public function getTitle()
817  {
818  return $this->title;
819  }
820 
825  public function setDescription($a_description)
826  {
827  $this->description = $a_description;
828  }
829 
835  public function getDescription()
836  {
837  return $this->description;
838  }
839 
845  public function setSearchFragment($a_text)
846  {
847  $this->search_fragment = $a_text;
848  }
849 
854  public function getSearchFragment()
855  {
856  return $this->search_fragment;
857  }
858 
864  public function setSeparateCommands($a_val)
865  {
866  $this->separate_commands = $a_val;
867  }
868 
874  public function getSeparateCommands()
875  {
877  }
887  public function getCommandId()
888  {
889  return $this->ref_id;
890  }
891 
897  public function setAdditionalInformation($a_val)
898  {
899  $this->additional_information = $a_val;
900  }
901 
907  public function getAdditionalInformation()
908  {
910  }
911 
919  public function setDetailsLevel($a_level)
920  {
921  $this->details_level = $a_level;
922  }
923 
928  public function getDetailsLevel()
929  {
930  return $this->details_level;
931  }
932 
938  public function enableRepositoryTransfer($a_value)
939  {
940  $this->repository_transfer_enabled = (bool) $a_value;
941  }
942 
948  public function restrictToGoto($a_value)
949  {
950  $this->restrict_to_goto = (bool) $a_value;
951  }
952 
953 
959  public function getDefaultCommand()
960  {
961  return $this->default_command;
962  }
963 
969  public function checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id = "")
970  {
971  $ilAccess = $this->access;
972 
973  // e.g: subitems should not be readable since their parent sesssion is readonly.
974  if ($a_permission != 'visible' and $this->isVisibleOnlyForced()) {
975  return false;
976  }
977 
978  $cache_prefix = null;
979  if ($this->context == self::CONTEXT_WORKSPACE || $this->context == self::CONTEXT_WORKSPACE_SHARING) {
980  $cache_prefix = "wsp";
981  if (!$this->ws_access) {
982  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
983  $this->ws_access = new ilWorkspaceAccessHandler();
984  }
985  }
986 
987  if (isset($this->access_cache[$a_permission]["-" . $a_cmd][$cache_prefix . $a_ref_id])) {
988  return $this->access_cache[$a_permission]["-" . $a_cmd][$cache_prefix . $a_ref_id];
989  }
990 
991  if ($this->context == self::CONTEXT_REPOSITORY) {
992  $access = $ilAccess->checkAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id);
993  if ($ilAccess->getPreventCachingLastResult()) {
994  $this->prevent_access_caching = true;
995  }
996  } else {
997  $access = $this->ws_access->checkAccess($a_permission, $a_cmd, $a_ref_id, $a_type);
998  }
999 
1000  $this->access_cache[$a_permission]["-" . $a_cmd][$cache_prefix . $a_ref_id] = $access;
1001  return $access;
1002  }
1003 
1013  public function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "")
1014  {
1015  $this->offline_mode = false;
1016  if ($this->type == "sahs") {
1017  include_once('Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php');
1018  $this->offline_mode = ilObjSAHSLearningModuleAccess::_lookupUserIsOfflineMode($a_obj_id);
1019  }
1020  $this->access_cache = array();
1021  $this->ref_id = $a_ref_id;
1022  $this->obj_id = $a_obj_id;
1023  $this->setTitle($a_title);
1024  $this->setDescription($a_description);
1025  #$this->description = $a_description;
1026 
1027  // checks, whether any admin commands are included in the output
1028  $this->adm_commands_included = false;
1029  $this->prevent_access_caching = false;
1030  }
1031 
1032  public function setConditionTarget($a_ref_id, $a_obj_id, $a_target_type)
1033  {
1034  $this->condition_target = array(
1035  'ref_id' => $a_ref_id,
1036  'obj_id' => $a_obj_id,
1037  'target_type' => $a_target_type
1038  );
1039  }
1040 
1041  public function resetConditionTarget()
1042  {
1043  $this->condition_target = array();
1044  }
1045 
1046  public function disableTitleLink($a_status)
1047  {
1048  $this->title_link_disabled = $a_status;
1049  }
1050  // end-patch lok
1051 
1052  public function setDefaultCommandParameters(array $a_params)
1053  {
1054  $this->default_command_params = $a_params;
1055  }
1056 
1066  public function createDefaultCommand($command)
1067  {
1068  // begin-patch lok
1069  if ($this->static_link_enabled and !$this->default_command_params) {
1070  include_once('./Services/Link/classes/class.ilLink.php');
1071  if ($link = ilLink::_getStaticLink($this->ref_id, $this->type, false)) {
1072  $command['link'] = $link;
1073  $command['frame'] = '_top';
1074  }
1075  }
1076  if ($this->default_command_params) {
1077  $params = array();
1078  foreach ($this->default_command_params as $name => $value) {
1079  $params[] = $name . '=' . $value;
1080  }
1081  $params = implode('&', $params);
1082 
1083  // #12370
1084  if (!stristr($command['link'], '?')) {
1085  $command['link'] .= '?' . $params;
1086  } else {
1087  $command['link'] .= '&' . $params;
1088  }
1089  }
1090  return $command;
1091  }
1092 
1105  public function getCommandLink($a_cmd)
1106  {
1107  if ($this->context == self::CONTEXT_REPOSITORY) {
1108  // BEGIN WebDAV Get mount webfolder link.
1109  require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1110  if ($a_cmd == 'mount_webfolder' && ilDAVActivationChecker::_isActive()) {
1111  require_once('Services/WebDAV/classes/class.ilWebDAVUtil.php');
1112  $dav_util = ilWebDAVUtil::getInstance();
1113 
1114  // XXX: The following is a very dirty, ugly trick.
1115  // To mount URI needs to be put into two attributes:
1116  // href and folder. This hack returns both attributes
1117  // like this: http://...mount_uri..." folder="http://...folder_uri...
1118  return $dav_util->getMountURI($this->ref_id) .
1119  '" folder="' . $dav_util->getFolderURI($this->ref_id);
1120  }
1121  // END WebDAV Get mount webfolder link.
1122 
1123  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
1124  $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
1125  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
1126  return $cmd_link;
1127 
1128  /* separate method for this line
1129  $cmd_link = $this->ctrl->getLinkTargetByClass($this->gui_class_name,
1130  $a_cmd);
1131  return $cmd_link;
1132  */
1133  } else {
1134  $this->ctrl->setParameterByClass($this->gui_class_name, "ref_id", "");
1135  $this->ctrl->setParameterByClass($this->gui_class_name, "wsp_id", $this->ref_id);
1136  return $this->ctrl->getLinkTargetByClass($this->gui_class_name, $a_cmd);
1137  }
1138  }
1139 
1140 
1150  public function getCommandFrame($a_cmd)
1151  {
1152  // BEGIN WebDAV Get mount webfolder link.
1153  require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1154  if ($a_cmd == 'mount_webfolder' && ilDAVActivationChecker::_isActive()) {
1155  return '_blank';
1156  }
1157  // begin-patch fm
1158  if ($a_cmd == 'fileManagerLaunch') {
1159  return '_blank';
1160  }
1161  // end-patch fm
1162  return "";
1163  }
1164 
1174  public function getCommandImage($a_cmd)
1175  {
1176  return "";
1177  }
1178 
1190  public function getProperties()
1191  {
1192  $lng = $this->lng;
1193  $ilUser = $this->user;
1194 
1195  $props = array();
1196  // please list alert properties first
1197  // example (use $lng->txt instead of "Status"/"Offline" strings):
1198  // $props[] = array("alert" => true, "property" => "Status", "value" => "Offline");
1199  // $props[] = array("alert" => false, "property" => ..., "value" => ...);
1200  // ...
1201 
1202  // #8280: WebDav is only supported in repository
1203  if ($this->context == self::CONTEXT_REPOSITORY) {
1204  // add centralized offline status
1205  if (ilObject::lookupOfflineStatus($this->obj_id)) {
1206  $props[] =
1207  [
1208  'alert' => true,
1209  'property' => $lng->txt("status"),
1210  'value' => $lng->txt("offline")
1211  ];
1212  }
1213 
1214  // BEGIN WebDAV Display locking information
1215  require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1217  // Show lock info
1218  require_once('Services/WebDAV/classes/lock/class.ilWebDAVLockBackend.php');
1219  $webdav_lock_backend = new ilWebDAVLockBackend();
1220  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
1221  if ($lock = $webdav_lock_backend->getLocksOnObjectId($this->obj_id)) {
1222  $lock_user = new ilObjUser($lock->getIliasOwner());
1223 
1224  $props[] = array(
1225  "alert" => false,
1226  "property" => $lng->txt("in_use_by"),
1227  "value" => $lock_user->getLogin(),
1228  "link" => "./ilias.php?user=" . $lock_user->getId() . '&cmd=showUserProfile&cmdClass=ilpersonaldesktopgui&baseClass=ilPersonalDesktopGUI',
1229  );
1230  }
1231  }
1232  // END WebDAV Display locking information
1233 
1234  if ($this->getDetailsLevel() == self::DETAILS_SEARCH) {
1235  return $props;
1236  }
1237 
1238  // BEGIN WebDAV Display warning for invisible Unix files and files with special characters
1239  if (preg_match('/^(\\.|\\.\\.)$/', $this->title)) {
1240  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1241  "value" => $lng->txt("filename_special_filename"),
1242  'propertyNameVisible' => false);
1243  } elseif (preg_match('/^\\./', $this->title)) {
1244  $props[] = array("alert" => false, "property" => $lng->txt("filename_visibility"),
1245  "value" => $lng->txt("filename_hidden_unix_file"),
1246  'propertyNameVisible' => false);
1247  } elseif (preg_match('/~$/', $this->title)) {
1248  $props[] = array("alert" => false, "property" => $lng->txt("filename_visibility"),
1249  "value" => $lng->txt("filename_hidden_backup_file"),
1250  'propertyNameVisible' => false);
1251  } elseif (preg_match('/[\\/]/', $this->title)) {
1252  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1253  "value" => $lng->txt("filename_special_characters"),
1254  'propertyNameVisible' => false);
1255  } elseif (preg_match('/[\\\\\\/:*?"<>|]/', $this->title)) {
1256  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1257  "value" => $lng->txt("filename_windows_special_characters"),
1258  'propertyNameVisible' => false);
1259  } elseif (preg_match('/\\.$/', $this->title)) {
1260  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1261  "value" => $lng->txt("filename_windows_empty_extension"),
1262  'propertyNameVisible' => false);
1263  } elseif (preg_match('/^(\\.|\\.\\.)$/', $this->title)) {
1264  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1265  "value" => $lng->txt("filename_special_filename"),
1266  'propertyNameVisible' => false);
1267  } elseif (preg_match('/#/', $this->title)) {
1268  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1269  "value" => $lng->txt("filename_windows_webdav_issue"),
1270  'propertyNameVisible' => false);
1271  }
1272  }
1273  // END WebDAV Display warning for invisible files and files with special characters
1274  }
1275 
1276  return $props;
1277  }
1278 
1282  public function addCustomProperty(
1283  $a_property = "",
1284  $a_value = "",
1285  $a_alert = false,
1286  $a_newline = false
1287  ) {
1288  $this->cust_prop[] = array("property" => $a_property, "value" => $a_value,
1289  "alert" => $a_alert, "newline" => $a_newline);
1290  }
1291 
1295  public function getCustomProperties($a_prop)
1296  {
1297  if (is_array($this->cust_prop)) {
1298  foreach ($this->cust_prop as $prop) {
1299  $a_prop[] = $prop;
1300  }
1301  }
1302  return $a_prop;
1303  }
1304 
1309  public function getAlertProperties()
1310  {
1311  $alert = array();
1312  foreach ((array) $this->getProperties() as $prop) {
1313  if ($prop['alert'] == true) {
1314  $alert[] = $prop;
1315  }
1316  }
1317  return $alert;
1318  }
1319 
1323  public function getNoticeProperties()
1324  {
1325  $this->notice_prop = array();
1326  if ($infos = $this->ldap_mapping->getInfoStrings($this->obj_id, true)) {
1327  foreach ($infos as $info) {
1328  $this->notice_prop[] = array('value' => $info);
1329  }
1330  }
1331  return $this->notice_prop ? $this->notice_prop : array();
1332  }
1336  public function addCustomCommand($a_link, $a_lang_var, $a_frame = "", $onclick = "")
1337  {
1338  $this->cust_commands[] =
1339  array("link" => $a_link, "lang_var" => $a_lang_var,
1340  "frame" => $a_frame, "onclick" => $onclick);
1341  }
1342 
1347  public function forceVisibleOnly($a_stat)
1348  {
1349  $this->force_visible_only = $a_stat;
1350  }
1351 
1356  public function isVisibleOnlyForced()
1357  {
1359  }
1360 
1384  public function getCommands()
1385  {
1386  $ilAccess = $this->access;
1387  $ilUser = $this->user;
1388 
1389  $ref_commands = array();
1390  foreach ($this->commands as $command) {
1391  $permission = $command["permission"];
1392  $cmd = $command["cmd"];
1393  $lang_var = $command["lang_var"];
1394  $txt = "";
1395  $info_object = null;
1396 
1397  if (isset($command["txt"])) {
1398  $txt = $command["txt"];
1399  }
1400 
1401  // BEGIN WebDAV: Suppress commands that don't make sense for anonymous users.
1402  // Suppress commands that don't make sense for anonymous users
1403  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
1404  $command['enable_anonymous'] == 'false') {
1405  continue;
1406  }
1407  // END WebDAV: Suppress commands that don't make sense for anonymous users.
1408 
1409  // all access checking should be made within $ilAccess and
1410  // the checkAccess of the ilObj...Access classes
1411  //$access = $ilAccess->checkAccess($permission, $cmd, $this->ref_id, $this->type);
1412  $access = $this->checkCommandAccess($permission, $cmd, $this->ref_id, $this->type);
1413 
1414  if ($access) {
1415  $cmd_link = $this->getCommandLink($command["cmd"]);
1416  $cmd_frame = $this->getCommandFrame($command["cmd"]);
1417  $cmd_image = $this->getCommandImage($command["cmd"]);
1418  $access_granted = true;
1419  } else {
1420  $access_granted = false;
1421  $info_object = $ilAccess->getInfo();
1422  }
1423 
1424  if (!isset($command["default"])) {
1425  $command["default"] = "";
1426  }
1427  $ref_commands[] = array(
1428  "permission" => $permission,
1429  "cmd" => $cmd,
1430  "link" => $cmd_link,
1431  "frame" => $cmd_frame,
1432  "lang_var" => $lang_var,
1433  "txt" => $txt,
1434  "granted" => $access_granted,
1435  "access_info" => $info_object,
1436  "img" => $cmd_image,
1437  "default" => $command["default"]
1438  );
1439  }
1440 
1441  return $ref_commands;
1442  }
1443 
1444  // BEGIN WebDAV: Visualize object state in its icon.
1452  public function getIconImageType()
1453  {
1454  if ($this->type == "sahs" && $this->offline_mode) {
1455  return $this->type . "_offline";
1456  }
1457  return $this->type;
1458  }
1459  // END WebDAV: Visualize object state in its icon.
1460 
1468  public function insertTitle()
1469  {
1470  if ($this->restrict_to_goto) {
1471  $this->default_command = array("frame" => "",
1472  "link" => $this->buildGotoLink());
1473  }
1474  // begin-patch lok
1475  if (
1476  !$this->default_command ||
1477  (!$this->getCommandsStatus() && !$this->restrict_to_goto) ||
1478  $this->title_link_disabled
1479  ) {
1480  // end-patch lok
1481  $this->tpl->setCurrentBlock("item_title");
1482  $this->tpl->setVariable("TXT_TITLE", $this->getTitle());
1483  $this->tpl->parseCurrentBlock();
1484  } else {
1485  $this->default_command['link'] = $this->modifyTitleLink($this->default_command['link']);
1486 
1487  $this->default_command["link"] =
1488  $this->modifySAHSlaunch($this->default_command["link"], $this->default_command["frame"]);
1489 
1490  if ($this->default_command["frame"] != "") {
1491  $this->tpl->setCurrentBlock("title_linked_frame");
1492  $this->tpl->setVariable("TARGET_TITLE_LINKED", $this->default_command["frame"]);
1493  $this->tpl->parseCurrentBlock();
1494  }
1495 
1496  // workaround for repository frameset
1497  #var_dump("<pre>",$this->default_command['link'],"</pre>");
1498  $this->default_command["link"] =
1499  $this->appendRepositoryFrameParameter($this->default_command["link"]);
1500 
1501  #var_dump("<pre>",$this->default_command['link'],"</pre>");
1502 
1503 
1504  // the default command is linked with the title
1505  $this->tpl->setCurrentBlock("item_title_linked");
1506  $this->tpl->setVariable("TXT_TITLE_LINKED", $this->getTitle());
1507  $this->tpl->setVariable("HREF_TITLE_LINKED", $this->default_command["link"]);
1508 
1509  // has preview?
1510  include_once("./Services/Preview/classes/class.ilPreview.php");
1511  if (ilPreview::hasPreview($this->obj_id, $this->type)) {
1512  include_once("./Services/Preview/classes/class.ilPreviewGUI.php");
1513 
1514  // get context for access checks later on
1515  $access_handler = null;
1516  switch ($this->context) {
1517  case self::CONTEXT_WORKSPACE:
1518  case self::CONTEXT_WORKSPACE_SHARING:
1520  include_once("./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php");
1521  $access_handler = new ilWorkspaceAccessHandler();
1522  break;
1523 
1524  default:
1525  $ilAccess = $this->access;
1527  $access_handler = $ilAccess;
1528  break;
1529  }
1530 
1531  $preview = new ilPreviewGUI($this->ref_id, $context, $this->obj_id, $access_handler);
1532  $preview_status = ilPreview::lookupRenderStatus($this->obj_id);
1533  $preview_status_class = "";
1534  $preview_text_topic = "preview_show";
1535  if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
1536  $preview_status_class = "ilPreviewStatusNone";
1537  $preview_text_topic = "preview_none";
1538  }
1539  $this->tpl->setCurrentBlock("item_title_linked");
1540  $this->tpl->setVariable("PREVIEW_STATUS_CLASS", $preview_status_class);
1541  $this->tpl->setVariable("SRC_PREVIEW_ICON", ilUtil::getImagePath("preview.png", "Services/Preview"));
1542  $this->tpl->setVariable("ALT_PREVIEW_ICON", $this->lng->txt($preview_text_topic));
1543  $this->tpl->setVariable("TXT_PREVIEW", $this->lng->txt($preview_text_topic));
1544  $this->tpl->setVariable("SCRIPT_PREVIEW_CLICK", $preview->getJSCall($this->getUniqueItemId(true)));
1545  $this->tpl->parseCurrentBlock();
1546  }
1547 
1548  $this->tpl->parseCurrentBlock();
1549  }
1550 
1551  if ($this->bold_title == true) {
1552  $this->tpl->touchBlock('bold_title_start');
1553  $this->tpl->touchBlock('bold_title_end');
1554  }
1555  }
1556 
1557  protected function buildGotoLink()
1558  {
1559  switch ($this->context) {
1560  case self::CONTEXT_WORKSPACE_SHARING:
1561  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
1562  return ilWorkspaceAccessHandler::getGotoLink($this->ref_id, $this->obj_id);
1563 
1564  default:
1565  // not implemented yet
1566  break;
1567  }
1568  }
1569 
1576  public function insertSubstitutions()
1577  {
1578  $fields_shown = false;
1579  foreach ($this->substitutions->getParsedSubstitutions($this->ref_id, $this->obj_id) as $data) {
1580  if ($data['bold']) {
1581  $data['name'] = '<strong>' . $data['name'] . '</strong>';
1582  $data['value'] = '<strong>' . $data['value'] . '</strong>';
1583  }
1584  $this->tpl->touchBlock("std_prop");
1585  $this->tpl->setCurrentBlock('item_property');
1586  if ($data['show_field']) {
1587  $this->tpl->setVariable('TXT_PROP', $data['name']);
1588  }
1589  $this->tpl->setVariable('VAL_PROP', $data['value']);
1590  $this->tpl->parseCurrentBlock();
1591 
1592  if ($data['newline']) {
1593  $this->tpl->touchBlock('newline_prop');
1594  }
1595  $fields_shown = false;
1596  }
1597  if ($fields_shown) {
1598  $this->tpl->touchBlock('newline_prop');
1599  }
1600  }
1601 
1602 
1610  public function insertDescription()
1611  {
1612  if ($this->getSubstitutionStatus()) {
1613  $this->insertSubstitutions();
1614  if (!$this->substitutions->isDescriptionEnabled()) {
1615  return true;
1616  }
1617  }
1618 
1619  // see bug #16519
1620  $d = $this->getDescription();
1621  $d = strip_tags($d, "<b>");
1622  $this->tpl->setCurrentBlock("item_description");
1623  $this->tpl->setVariable("TXT_DESC", $d);
1624  $this->tpl->parseCurrentBlock();
1625  }
1626 
1631  public function insertSearchFragment()
1632  {
1633  if (strlen($this->getSearchFragment())) {
1634  $this->tpl->setCurrentBlock('search_fragment');
1635  $this->tpl->setVariable('TXT_SEARCH_FRAGMENT', $this->getSearchFragment() . ' ...');
1636  $this->tpl->parseCurrentBlock();
1637  }
1638  }
1639 
1645  public function insertRelevance()
1646  {
1647  if (!$this->enabledRelevance() or !(int) $this->getRelevance()) {
1648  return false;
1649  }
1650 
1651  include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
1652  $pbar = ilProgressBar::getInstance();
1653  $pbar->setCurrent($this->getRelevance());
1654 
1655  $this->tpl->setCurrentBlock('relevance');
1656  $this->tpl->setVariable('REL_PBAR', $pbar->render());
1657  $this->tpl->parseCurrentBlock();
1658  }
1659 
1665  public function setMode($a_mode)
1666  {
1667  $this->mode = $a_mode;
1668  }
1669 
1675  public function getMode()
1676  {
1677  return $this->mode;
1678  }
1679 
1683  public function setConditionDepth($a_depth)
1684  {
1685  $this->condition_depth = $a_depth;
1686  }
1687 
1695  public function isMode($a_mode)
1696  {
1697  if ($a_mode == $this->mode) {
1698  return true;
1699  } else {
1700  return false;
1701  }
1702  }
1703 
1708  public function determineProperties()
1709  {
1710  $ilAccess = $this->access;
1711  $lng = $this->lng;
1712  $ilUser = $this->user;
1713 
1714  $props = $this->getProperties();
1715  $props = $this->getCustomProperties($props);
1716 
1717  if ($this->context != self::CONTEXT_WORKSPACE && $this->context != self::CONTEXT_WORKSPACE_SHARING) {
1718  // add learning progress custom property
1719  include_once "Services/Tracking/classes/class.ilLPStatus.php";
1720  $lp = ilLPStatus::getListGUIStatus($this->obj_id);
1721  if ($lp) {
1722  $props[] = array("alert" => false,
1723  "property" => $lng->txt("learning_progress"),
1724  "value" => $lp,
1725  "newline" => true);
1726  }
1727 
1728  // add no item access note in public section
1729  // for items that are visible but not readable
1730  if ($ilUser->getId() == ANONYMOUS_USER_ID) {
1731  if (!$ilAccess->checkAccess("read", "", $this->ref_id, $this->type, $this->obj_id)) {
1732  $props[] = array("alert" => true,
1733  "value" => $lng->txt("no_access_item_public"),
1734  "newline" => true);
1735  }
1736  }
1737  }
1738 
1739  // reference objects have translated ids, revert to originals
1740  $note_ref_id = $this->ref_id;
1741  $note_obj_id = $this->obj_id;
1742  if ($this->reference_ref_id) {
1743  $note_ref_id = $this->reference_ref_id;
1744  $note_obj_id = $this->reference_obj_id;
1745  }
1746  $redraw_js = "il.Object.redrawListItem(" . $note_ref_id . ");";
1747 
1748  // add common properties (comments, notes, tags)
1749  require_once 'Services/Notes/classes/class.ilNote.php';
1750  if ((self::$cnt_notes[$note_obj_id][IL_NOTE_PRIVATE] > 0 ||
1751  self::$cnt_notes[$note_obj_id][IL_NOTE_PUBLIC] > 0 ||
1752  self::$cnt_tags[$note_obj_id] > 0 ||
1753  is_array(self::$tags[$note_obj_id])) &&
1754  ($ilUser->getId() != ANONYMOUS_USER_ID)) {
1755  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
1756  include_once("./Services/Tagging/classes/class.ilTaggingGUI.php");
1757 
1758  $nl = true;
1759  if ($this->isCommentsActivated($this->type, $this->ref_id, $this->obj_id, false, false)
1760  && self::$cnt_notes[$note_obj_id][IL_NOTE_PUBLIC] > 0) {
1761  $props[] = array("alert" => false,
1762  "property" => $lng->txt("notes_comments"),
1763  "value" => "<a href='#' onclick=\"return " .
1764  ilNoteGUI::getListCommentsJSCall($this->ajax_hash, $redraw_js) . "\">" .
1765  self::$cnt_notes[$note_obj_id][IL_NOTE_PUBLIC] . "</a>",
1766  "newline" => $nl);
1767  $nl = false;
1768  }
1769 
1770  if ($this->notes_enabled && self::$cnt_notes[$note_obj_id][IL_NOTE_PRIVATE] > 0) {
1771  $props[] = array("alert" => false,
1772  "property" => $lng->txt("notes"),
1773  "value" => "<a href='#' onclick=\"return " .
1774  ilNoteGUI::getListNotesJSCall($this->ajax_hash, $redraw_js) . "\">" .
1775  self::$cnt_notes[$note_obj_id][IL_NOTE_PRIVATE] . "</a>",
1776  "newline" => $nl);
1777  $nl = false;
1778  }
1779  if ($this->tags_enabled &&
1780  (self::$cnt_tags[$note_obj_id] > 0 ||
1781  is_array(self::$tags[$note_obj_id]))) {
1782  $tags_set = new ilSetting("tags");
1783  if ($tags_set->get("enable")) {
1784  $tags_url = ilTaggingGUI::getListTagsJSCall($this->ajax_hash, $redraw_js);
1785 
1786  // list object tags
1787  if (is_array(self::$tags[$note_obj_id])) {
1788  $tags_tmp = array();
1789  foreach (self::$tags[$note_obj_id] as $tag => $is_tag_owner) {
1790  if ($is_tag_owner) {
1791  $tags_tmp[] = "<a class=\"ilTag ilTagRelHigh\" href='#' onclick=\"return " .
1792  $tags_url . "\">" . $tag . "</a>";
1793  } else {
1794  $tags_tmp[] = "<span class=\"ilTag ilTagRelMiddle\">" . $tag . "</span>";
1795  }
1796  }
1797  $tags_value = implode(" ", $tags_tmp);
1798  $nl = true;
1799  $prop_text = "";
1800  } // tags counter
1801  else {
1802  $tags_value = "<a href='#' onclick=\"return " . $tags_url . "\">" .
1803  self::$cnt_tags[$note_obj_id] . "</a>";
1804  $prop_text = $lng->txt("tagging_tags");
1805  }
1806  $props[] = array("alert" => false,
1807  "property" => $prop_text,
1808  "value" => $tags_value,
1809  "newline" => $nl);
1810  $nl = false;
1811  }
1812  }
1813  }
1814  if (!is_array($props)) {
1815  return [];
1816  }
1817  return $props;
1818  }
1819 
1825  public function insertProperties()
1826  {
1827  $props = $this->determineProperties();
1828  $cnt = 1;
1829  if (is_array($props) && count($props) > 0) {
1830  foreach ($props as $prop) {
1831  // BEGIN WebDAV: Display a separator between properties.
1832  if ($cnt > 1) {
1833  $this->tpl->touchBlock("separator_prop");
1834  }
1835  // END WebDAV: Display a separator between properties.
1836 
1837  if ($prop["alert"] == true) {
1838  $this->tpl->touchBlock("alert_prop");
1839  } else {
1840  $this->tpl->touchBlock("std_prop");
1841  }
1842  if ($prop["newline"] == true && $cnt > 1) {
1843  $this->tpl->touchBlock("newline_prop");
1844  }
1845  //BEGIN WebDAV: Support hidden property names.
1846  if (isset($prop["property"]) && $prop['propertyNameVisible'] !== false && $prop["property"] != "") {
1847  //END WebDAV: Support hidden property names.
1848  $this->tpl->setCurrentBlock("prop_name");
1849  $this->tpl->setVariable("TXT_PROP", $prop["property"]);
1850  $this->tpl->parseCurrentBlock();
1851  }
1852  $this->tpl->setCurrentBlock("item_property");
1853  //BEGIN WebDAV: Support links in property values.
1854  if ($prop['link']) {
1855  $this->tpl->setVariable("LINK_PROP", $prop['link']);
1856  $this->tpl->setVariable("LINK_VAL_PROP", $prop["value"]);
1857  } else {
1858  $this->tpl->setVariable("VAL_PROP", $prop["value"]);
1859  }
1860  //END WebDAV: Support links in property values.
1861  $this->tpl->parseCurrentBlock();
1862 
1863  $cnt++;
1864  }
1865  $this->tpl->setCurrentBlock("item_properties");
1866  $this->tpl->parseCurrentBlock();
1867  }
1868  }
1869 
1870  public function insertNoticeProperties()
1871  {
1872  $this->getNoticeProperties();
1873  foreach ($this->notice_prop as $property) {
1874  $this->tpl->setCurrentBlock('notice_item');
1875  $this->tpl->setVariable('NOTICE_ITEM_VALUE', $property['value']);
1876  $this->tpl->parseCurrentBlock();
1877  }
1878  $this->tpl->setCurrentBlock('notice_property');
1879  $this->tpl->parseCurrentBlock();
1880  }
1881 
1882  protected function parseConditions($toggle_id, $conditions, $obligatory = true)
1883  {
1884  $lng = $this->lng;
1885  $objDefinition = $this->obj_definition;
1886  $tree = $this->tree;
1887 
1888  $num_required = ilConditionHandler::calculateEffectiveRequiredTriggers($this->ref_id, $this->obj_id);
1889  $num_optional_required =
1890  $num_required - count($conditions) + count(ilConditionHandler::getEffectiveOptionalConditionsOfTarget($this->ref_id, $this->obj_id));
1891 
1892  // Check if all conditions are fullfilled
1893  $visible_conditions = array();
1894  $passed_optional = 0;
1895  foreach ($conditions as $condition) {
1896  if ($obligatory and !$condition['obligatory']) {
1897  continue;
1898  }
1899  if (!$obligatory and $condition['obligatory']) {
1900  continue;
1901  }
1902 
1903  if ($tree->isDeleted($condition['trigger_ref_id'])) {
1904  continue;
1905  }
1906 
1907  include_once 'Services/Container/classes/class.ilMemberViewSettings.php';
1909  !ilMemberViewSettings::getInstance()->isActive();
1910 
1911  if (!$ok) {
1912  $visible_conditions[] = $condition['id'];
1913  }
1914 
1915  if (!$obligatory and $ok) {
1916  ++$passed_optional;
1917  // optional passed
1918  if ($passed_optional >= $num_optional_required) {
1919  return true;
1920  }
1921  }
1922  }
1923 
1924  foreach ($conditions as $condition) {
1925  if (!in_array($condition['id'], $visible_conditions)) {
1926  continue;
1927  }
1928 
1929  include_once './Services/Conditions/classes/class.ilConditionHandlerGUI.php';
1930  $cond_txt = ilConditionHandlerGUI::translateOperator($condition['trigger_obj_id'], $condition['operator']) . ' ' . $condition['value'];
1931 
1932  // display trigger item
1933  $class = $objDefinition->getClassName($condition["trigger_type"]);
1934  $location = $objDefinition->getLocation($condition["trigger_type"]);
1935  if ($class == "" && $location == "") {
1936  continue;
1937  }
1938  $missing_cond_exist = true;
1939 
1940  $full_class = "ilObj" . $class . "ListGUI";
1941  include_once($location . "/class." . $full_class . ".php");
1942  $item_list_gui = new $full_class($this);
1943  $item_list_gui->setMode(IL_LIST_AS_TRIGGER);
1944  $item_list_gui->enablePath(false);
1945  $item_list_gui->enableIcon(true);
1946  $item_list_gui->setConditionDepth($this->condition_depth + 1);
1947  $item_list_gui->setParentRefId($this->getUniqueItemId()); // yes we can
1948  $item_list_gui->addCustomProperty($this->lng->txt("precondition_required_itemlist"), $cond_txt, false, true);
1949 
1950  $item_list_gui->enableCommands($this->commands_enabled, $this->std_cmd_only);
1951  $item_list_gui->enableProperties($this->properties_enabled);
1952 
1953  $trigger_html = $item_list_gui->getListItemHTML(
1954  $condition['trigger_ref_id'],
1955  $condition['trigger_obj_id'],
1956  ilObject::_lookupTitle($condition["trigger_obj_id"]),
1957  ""
1958  );
1959  $this->tpl->setCurrentBlock("precondition");
1960  if ($trigger_html == "") {
1961  $trigger_html = $this->lng->txt("precondition_not_accessible");
1962  }
1963  $this->tpl->setVariable("TXT_CONDITION", trim($cond_txt));
1964  $this->tpl->setVariable("TRIGGER_ITEM", $trigger_html);
1965  $this->tpl->parseCurrentBlock();
1966  }
1967 
1968  if ($missing_cond_exist and $obligatory) {
1969  $this->tpl->setCurrentBlock("preconditions");
1970  $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_obl_" . $toggle_id);
1971  $this->tpl->setVariable("TXT_PRECONDITIONS", $lng->txt("preconditions_obligatory_hint"));
1972  $this->tpl->parseCurrentBlock();
1973  } elseif ($missing_cond_exist and !$obligatory) {
1974  $this->tpl->setCurrentBlock("preconditions");
1975  $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_opt_" . $toggle_id);
1976  $this->tpl->setVariable("TXT_PRECONDITIONS", sprintf($lng->txt("preconditions_optional_hint"), $num_optional_required));
1977  $this->tpl->parseCurrentBlock();
1978  }
1979 
1980  return !$missing_cond_exist;
1981  }
1982 
1986  public function insertPreconditions()
1987  {
1988  include_once("./Services/Conditions/classes/class.ilConditionHandler.php");
1989 
1990  // do not show multi level conditions (messes up layout)
1991  if ($this->condition_depth > 0) {
1992  return;
1993  }
1994 
1995  if ($this->condition_target) {
1996  $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget(
1997  $this->condition_target['ref_id'],
1998  $this->condition_target['obj_id'],
1999  $this->condition_target['target_type']
2000  );
2001  } else {
2002  $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($this->ref_id, $this->obj_id);
2003  }
2004 
2005  if (sizeof($conditions)) {
2006  for ($i = 0; $i < count($conditions); $i++) {
2007  $conditions[$i]['title'] = ilObject::_lookupTitle($conditions[$i]['trigger_obj_id']);
2008  }
2009  $conditions = ilUtil::sortArray($conditions, 'title', 'DESC');
2010 
2011  ++self::$js_unique_id;
2012 
2013  // Show obligatory and optional preconditions seperated
2014  $all_done_obl = $this->parseConditions(self::$js_unique_id, $conditions, true);
2015  $all_done_opt = $this->parseConditions(self::$js_unique_id, $conditions, false);
2016 
2017  if (!$all_done_obl || !$all_done_opt) {
2018  $this->tpl->setCurrentBlock("preconditions_toggle");
2019  $this->tpl->setVariable("PRECONDITION_TOGGLE_INTRO", $this->lng->txt("precondition_toggle"));
2020  $this->tpl->setVariable("PRECONDITION_TOGGLE_TRIGGER", $this->lng->txt("show"));
2021  $this->tpl->setVariable("PRECONDITION_TOGGLE_ID", self::$js_unique_id);
2022  $this->tpl->setVariable("TXT_PRECONDITION_SHOW", $this->lng->txt("show"));
2023  $this->tpl->setVariable("TXT_PRECONDITION_HIDE", $this->lng->txt("hide"));
2024  $this->tpl->parseCurrentBlock();
2025  }
2026  }
2027  }
2028 
2037  public function insertCommand($a_href, $a_text, $a_frame = "", $a_img = "", $a_cmd = "", $a_onclick = "")
2038  {
2039  // #11099
2040  $chksum = md5($a_href . $a_text);
2041  if ($a_href == "#" ||
2042  !in_array($chksum, $this->prevent_duplicate_commands)) {
2043  if ($a_href != "#") {
2044  $this->prevent_duplicate_commands[] = $chksum;
2045  }
2046 
2047  $prevent_background_click = false;
2048  if ($a_cmd == 'mount_webfolder') {
2049  $prevent_background_click = true;
2050  }
2051 
2052  if ($a_cmd == "downloadFolder") {
2053  include_once "Services/BackgroundTask/classes/class.ilFolderDownloadBackgroundTaskHandler.php";
2056  $a_href = "#";
2057  }
2058  }
2059 
2060  $this->current_selection_list->addItem(
2061  $a_text,
2062  "",
2063  $a_href,
2064  $a_img,
2065  $a_text,
2066  $a_frame,
2067  "",
2068  $prevent_background_click,
2069  $a_onclick
2070  );
2071  }
2072  }
2073 
2081  public function insertDeleteCommand()
2082  {
2083  if ($this->std_cmd_only) {
2084  return;
2085  }
2086 
2087  if (is_object($this->getContainerObject()) and
2089  if ($this->checkCommandAccess('delete', '', $this->ref_id, $this->type)) {
2090  $this->ctrl->setParameter($this->getContainerObject(), 'item_ref_id', $this->getCommandId());
2091  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "delete");
2092  $this->insertCommand($cmd_link, $this->lng->txt("delete"));
2093  $this->adm_commands_included = true;
2094  return true;
2095  }
2096  return false;
2097  }
2098 
2099  if ($this->checkCommandAccess('delete', '', $this->ref_id, $this->type)) {
2100  $this->ctrl->setParameter(
2101  $this->container_obj,
2102  "ref_id",
2103  $this->container_obj->object->getRefId()
2104  );
2105  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2106  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "delete");
2107  $this->insertCommand(
2108  $cmd_link,
2109  $this->lng->txt("delete"),
2110  "",
2111  ""
2112  );
2113  $this->adm_commands_included = true;
2114  }
2115  }
2116 
2124  public function insertLinkCommand()
2125  {
2126  $objDefinition = $this->obj_definition;
2127 
2128  if ($this->std_cmd_only) {
2129  return;
2130  }
2131 
2132  // #17307
2133  if (!$this->checkCommandAccess('delete', '', $this->ref_id, $this->type) or
2134  !$objDefinition->allowLink($this->type)) {
2135  return false;
2136  }
2137 
2138  // BEGIN PATCH Lucene search
2139 
2140  if (is_object($this->getContainerObject()) and
2142  $this->ctrl->setParameter($this->getContainerObject(), 'item_ref_id', $this->getCommandId());
2143  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "link");
2144  $this->insertCommand($cmd_link, $this->lng->txt("link"));
2145  $this->adm_commands_included = true;
2146  return true;
2147  }
2148  // END PATCH Lucene Search
2149 
2150  // if the permission is changed here, it has
2151  // also to be changed in ilContainerGUI, admin command check
2152  $this->ctrl->setParameter(
2153  $this->container_obj,
2154  "ref_id",
2155  $this->container_obj->object->getRefId()
2156  );
2157  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2158  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "link");
2159  $this->insertCommand(
2160  $cmd_link,
2161  $this->lng->txt("link"),
2162  "",
2163  ""
2164  );
2165  $this->adm_commands_included = true;
2166  return true;
2167  }
2168 
2175  public function insertCutCommand($a_to_repository = false)
2176  {
2177  if ($this->std_cmd_only) {
2178  return;
2179  }
2180  // BEGIN PATCH Lucene search
2181  if (is_object($this->getContainerObject()) and
2183  if ($this->checkCommandAccess('delete', '', $this->ref_id, $this->type)) {
2184  $this->ctrl->setParameter($this->getContainerObject(), 'item_ref_id', $this->getCommandId());
2185  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "cut");
2186  $this->insertCommand($cmd_link, $this->lng->txt("move"));
2187  $this->adm_commands_included = true;
2188  return true;
2189  }
2190  return false;
2191  }
2192  // END PATCH Lucene Search
2193 
2194  // if the permission is changed here, it has
2195  // also to be changed in ilContainerContentGUI, determineAdminCommands
2196  if ($this->checkCommandAccess('delete', '', $this->ref_id, $this->type) &&
2197  $this->container_obj->object) {
2198  $this->ctrl->setParameter(
2199  $this->container_obj,
2200  "ref_id",
2201  $this->container_obj->object->getRefId()
2202  );
2203  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2204 
2205  if (!$a_to_repository) {
2206  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "cut");
2207  $this->insertCommand(
2208  $cmd_link,
2209  $this->lng->txt("move"),
2210  "",
2211  ""
2212  );
2213  } else {
2214  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "cut_for_repository");
2215  $this->insertCommand(
2216  $cmd_link,
2217  $this->lng->txt("wsp_move_to_repository"),
2218  "",
2219  ""
2220  );
2221  }
2222 
2223  $this->adm_commands_included = true;
2224  }
2225  }
2226 
2232  public function insertCopyCommand($a_to_repository = false)
2233  {
2234  $objDefinition = $this->obj_definition;
2235 
2236  if ($this->std_cmd_only) {
2237  return;
2238  }
2239 
2240  if ($this->checkCommandAccess('copy', 'copy', $this->ref_id, $this->type) &&
2241  $objDefinition->allowCopy($this->type)) {
2242  if ($this->context != self::CONTEXT_WORKSPACE && $this->context != self::CONTEXT_WORKSPACE_SHARING) {
2243  $this->ctrl->setParameterByClass('ilobjectcopygui', 'source_id', $this->getCommandId());
2244  $cmd_copy = $this->ctrl->getLinkTargetByClass('ilobjectcopygui', 'initTargetSelection');
2245  $this->insertCommand($cmd_copy, $this->lng->txt('copy'));
2246  } else {
2247  $this->ctrl->setParameter(
2248  $this->container_obj,
2249  "ref_id",
2250  $this->container_obj->object->getRefId()
2251  );
2252  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2253 
2254  if (!$a_to_repository) {
2255  $cmd_copy = $this->ctrl->getLinkTarget($this->container_obj, 'copy');
2256  $this->insertCommand($cmd_copy, $this->lng->txt('copy'));
2257  } else {
2258  $cmd_copy = $this->ctrl->getLinkTarget($this->container_obj, 'copy_to_repository');
2259  $this->insertCommand($cmd_copy, $this->lng->txt('wsp_copy_to_repository'));
2260  }
2261  }
2262 
2263  $this->adm_commands_included = true;
2264  }
2265  return;
2266  }
2267 
2268 
2272  public function insertPasteCommand()
2273  {
2274  $objDefinition = $this->obj_definition;
2275 
2276  if ($this->std_cmd_only) {
2277  return;
2278  }
2279 
2280  if (!$objDefinition->isContainer(ilObject::_lookupType($this->obj_id))) {
2281  return false;
2282  }
2283 
2284  if (is_object($this->getContainerObject()) and
2286  isset($_SESSION['clipboard'])) {
2287  $this->ctrl->setParameter($this->getContainerObject(), 'item_ref_id', $this->getCommandId());
2288  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "paste");
2289  $this->insertCommand($cmd_link, $this->lng->txt("paste"));
2290  $this->adm_commands_included = true;
2291  return true;
2292  }
2293  return false;
2294  }
2295 
2303  public function insertSubscribeCommand()
2304  {
2306  $ilUser = $this->user;
2307 
2308  if ($this->std_cmd_only) {
2309  return;
2310  }
2311 
2312  if ((int) $ilSetting->get('disable_my_offers')) {
2313  return;
2314  }
2315 
2317 
2318  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
2319  // #17467 - add ref_id to link (in repository only!)
2320  if (is_object($this->container_obj) &&
2321  !($this->container_obj instanceof ilAdministrationCommandHandling) &&
2322  is_object($this->container_obj->object)) {
2323  $this->ctrl->setParameter($this->container_obj, "ref_id", $this->container_obj->object->getRefId());
2324  }
2325 
2326  if (!$ilUser->isDesktopItem($this->getCommandId(), $type)) {
2327  // Pass type and object ID to ilAccess to improve performance
2328  if ($this->checkCommandAccess("read", "", $this->ref_id, $this->type, $this->obj_id)) {
2329  if ($this->getContainerObject() instanceof ilDesktopItemHandling) {
2330  $this->ctrl->setParameter($this->container_obj, "type", $type);
2331  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2332  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "addToDesk");
2333  $this->insertCommand(
2334  $cmd_link,
2335  $this->lng->txt("to_desktop"),
2336  "",
2337  ""
2338  );
2339  }
2340  }
2341  } else {
2342  if ($this->getContainerObject() instanceof ilDesktopItemHandling) {
2343  $this->ctrl->setParameter($this->container_obj, "type", $type);
2344  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2345  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "removeFromDesk");
2346  $this->insertCommand(
2347  $cmd_link,
2348  $this->lng->txt("unsubscribe"),
2349  "",
2350  ""
2351  );
2352  }
2353  }
2354  }
2355  }
2356 
2360  public function insertInfoScreenCommand()
2361  {
2362  if ($this->std_cmd_only) {
2363  return;
2364  }
2365  $cmd_link = $this->getCommandLink("infoScreen");
2366  $cmd_frame = $this->getCommandFrame("infoScreen");
2367  $this->insertCommand(
2368  $cmd_link,
2369  $this->lng->txt("info_short"),
2370  $cmd_frame,
2371  ilUtil::getImagePath("icon_info.svg")
2372  );
2373  }
2374 
2381  public function insertCommonSocialCommands($a_header_actions = false)
2382  {
2383  $lng = $this->lng;
2384  $ilUser = $this->user;
2385 
2386  if ($this->std_cmd_only ||
2387  ($ilUser->getId() == ANONYMOUS_USER_ID)) {
2388  return;
2389  }
2390  $lng->loadLanguageModule("notes");
2391  $lng->loadLanguageModule("tagging");
2392  $cmd_frame = $this->getCommandFrame("infoScreen");
2393  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
2394 
2395  // reference objects have translated ids, revert to originals
2396  $note_ref_id = $this->ref_id;
2397  if ($this->reference_ref_id) {
2398  $note_ref_id = $this->reference_ref_id;
2399  }
2400 
2401  $js_updater = $a_header_actions
2402  ? "il.Object.redrawActionHeader();"
2403  : "il.Object.redrawListItem(" . $note_ref_id . ")";
2404 
2405  $comments_enabled = $this->isCommentsActivated($this->type, $this->ref_id, $this->obj_id, $a_header_actions, true);
2406  if ($comments_enabled) {
2407  $this->insertCommand(
2408  "#",
2409  $this->lng->txt("notes_comments"),
2410  $cmd_frame,
2411  "",
2412  "",
2413  ilNoteGUI::getListCommentsJSCall($this->ajax_hash, $js_updater)
2414  );
2415  }
2416 
2417  if ($this->notes_enabled) {
2418  $this->insertCommand(
2419  "#",
2420  $this->lng->txt("notes"),
2421  $cmd_frame,
2422  "",
2423  "",
2424  ilNoteGUI::getListNotesJSCall($this->ajax_hash, $js_updater)
2425  );
2426  }
2427 
2428  if ($this->tags_enabled) {
2429  include_once("./Services/Tagging/classes/class.ilTaggingGUI.php");
2430  //$this->insertCommand($cmd_tag_link, $this->lng->txt("tagging_set_tag"), $cmd_frame);
2431  $this->insertCommand(
2432  "#",
2433  $this->lng->txt("tagging_set_tag"),
2434  $cmd_frame,
2435  "",
2436  "",
2437  ilTaggingGUI::getListTagsJSCall($this->ajax_hash, $js_updater)
2438  );
2439  }
2440  }
2441 
2447  public function insertTimingsCommand()
2448  {
2449  if ($this->std_cmd_only || !$this->container_obj->object) {
2450  return;
2451  }
2452 
2453  $parent_ref_id = $this->container_obj->object->getRefId();
2454  $parent_type = $this->container_obj->object->getType();
2455 
2456  // #18737
2457  if ($this->reference_ref_id) {
2458  $this->ctrl->setParameterByClass('ilobjectactivationgui', 'ref_id', $this->reference_ref_id);
2459  }
2460 
2461  if ($this->checkCommandAccess('write', '', $parent_ref_id, $parent_type) ||
2462  $this->checkCommandAccess('write', '', $this->ref_id, $this->type)) {
2463  $this->ctrl->setParameterByClass(
2464  'ilobjectactivationgui',
2465  'cadh',
2466  $this->ajax_hash
2467  );
2468  $this->ctrl->setParameterByClass(
2469  'ilobjectactivationgui',
2470  'parent_id',
2472  );
2473  $cmd_lnk = $this->ctrl->getLinkTargetByClass(
2474  array($this->gui_class_name, 'ilcommonactiondispatchergui', 'ilobjectactivationgui'),
2475  'edit'
2476  );
2477 
2478  $this->insertCommand($cmd_lnk, $this->lng->txt('obj_activation_list_gui'));
2479  }
2480 
2481  if ($this->reference_ref_id) {
2482  $this->ctrl->setParameterByClass('ilobjectactivationgui', 'ref_id', $this->ref_id);
2483  }
2484  }
2485 
2493  public function insertCommands(
2494  $a_use_asynch = false,
2495  $a_get_asynch_commands = false,
2496  $a_asynch_url = "",
2497  $a_header_actions = false
2498  ) {
2499  $lng = $this->lng;
2500  $ilUser = $this->user;
2501 
2502  if (!$this->getCommandsStatus()) {
2503  return;
2504  }
2505 
2506  include_once("Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2507  $this->current_selection_list = new ilAdvancedSelectionListGUI();
2508  $this->current_selection_list->setAsynch($a_use_asynch && !$a_get_asynch_commands);
2509  $this->current_selection_list->setAsynchUrl($a_asynch_url);
2510  if ($a_header_actions) {
2511  $this->current_selection_list->setListTitle("<span class='hidden-xs'>" . $lng->txt("actions") . "</span>");
2512  } else {
2513  $this->current_selection_list->setListTitle("");
2514  }
2515  $this->current_selection_list->setId("act_" . $this->getUniqueItemId(false));
2516  $this->current_selection_list->setSelectionHeaderClass("small");
2517  $this->current_selection_list->setItemLinkClass("xsmall");
2518  $this->current_selection_list->setLinksMode("il_ContainerItemCommand2");
2519  $this->current_selection_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
2520  $this->current_selection_list->setUseImages(false);
2521  $this->current_selection_list->setAdditionalToggleElement($this->getUniqueItemId(true), "ilContainerListItemOuterHighlight");
2522 
2523  $this->ctrl->setParameterByClass($this->gui_class_name, "ref_id", $this->ref_id);
2524 
2525  // only standard command?
2526  $only_default = false;
2527  if ($a_use_asynch && !$a_get_asynch_commands) {
2528  $only_default = true;
2529  }
2530 
2531  $this->default_command = false;
2532  $this->prevent_duplicate_commands = array();
2533 
2534  // we only allow the following commands inside the header actions
2535  $valid_header_commands = array("mount_webfolder");
2536 
2537  $commands = $this->getCommands($this->ref_id, $this->obj_id);
2538  foreach ($commands as $command) {
2539  if ($a_header_actions && !in_array($command["cmd"], $valid_header_commands)) {
2540  continue;
2541  }
2542 
2543  if ($command["granted"] == true) {
2544  if (!$command["default"] === true) {
2545  if (!$this->std_cmd_only && !$only_default) {
2546  // workaround for repository frameset
2547  $command["link"] =
2548  $this->appendRepositoryFrameParameter($command["link"]);
2549 
2550  $cmd_link = $command["link"];
2551  $txt = ($command["lang_var"] == "")
2552  ? $command["txt"]
2553  : $this->lng->txt($command["lang_var"]);
2554  $this->insertCommand(
2555  $cmd_link,
2556  $txt,
2557  $command["frame"],
2558  $command["img"],
2559  $command["cmd"]
2560  );
2561  }
2562  } else {
2563  $this->default_command = $this->createDefaultCommand($command);
2564  //$this->default_command = $command;
2565  }
2566  }
2567  }
2568 
2569  if (!$only_default) {
2570  // custom commands
2571  if (is_array($this->cust_commands)) {
2572  foreach ($this->cust_commands as $command) {
2573  $this->insertCommand(
2574  $command["link"],
2575  $this->lng->txt($command["lang_var"]),
2576  $command["frame"],
2577  "",
2578  $command["cmd"],
2579  $command["onclick"]
2580  );
2581  }
2582  }
2583 
2584  // info screen commmand
2585  if ($this->getInfoScreenStatus()) {
2586  $this->insertInfoScreenCommand();
2587  }
2588 
2589  if (!$this->isMode(IL_LIST_AS_TRIGGER)) {
2590  // edit timings
2591  if ($this->timings_enabled) {
2592  $this->insertTimingsCommand();
2593  }
2594 
2595  // delete
2596  if ($this->delete_enabled) {
2597  $this->insertDeleteCommand();
2598  }
2599 
2600  // link
2601  if ($this->link_enabled) {
2602  $this->insertLinkCommand();
2603  }
2604 
2605  // cut
2606  if ($this->cut_enabled) {
2607  $this->insertCutCommand();
2608  }
2609 
2610  // copy
2611  if ($this->copy_enabled) {
2612  $this->insertCopyCommand();
2613  }
2614 
2615  // cut/copy from workspace to repository
2616  if ($this->repository_transfer_enabled) {
2617  $this->insertCutCommand(true);
2618  $this->insertCopyCommand(true);
2619  }
2620 
2621  // subscribe
2622  if ($this->subscribe_enabled) {
2623  $this->insertSubscribeCommand();
2624  }
2625 
2626  // multi download
2627  if ($this->multi_download_enabled && $a_header_actions) {
2628  $this->insertMultiDownloadCommand();
2629  }
2630 
2631  // BEGIN PATCH Lucene search
2632  if ($this->cut_enabled or $this->link_enabled) {
2633  $this->insertPasteCommand();
2634  }
2635  // END PATCH Lucene Search
2636  }
2637  }
2638 
2639  // common social commands (comment, notes, tags)
2640  if (!$only_default && !$this->isMode(IL_LIST_AS_TRIGGER)) {
2641  $this->insertCommonSocialCommands($a_header_actions);
2642  }
2643 
2644  if (!$a_header_actions) {
2645  $this->ctrl->clearParametersByClass($this->gui_class_name);
2646  }
2647 
2648  // fix bug #12417
2649  // there is one case, where no action menu should be displayed:
2650  // public area, category, no info tab
2651  // todo: make this faster and remove type specific implementation if possible
2652  if ($a_use_asynch && !$a_get_asynch_commands && !$a_header_actions) {
2653  if ($ilUser->getId() == ANONYMOUS_USER_ID && $this->checkInfoPageOnAsynchronousRendering()) {
2654  include_once("./Services/Container/classes/class.ilContainer.php");
2655  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
2657  $this->obj_id,
2659  true
2660  )) {
2661  return;
2662  }
2663  }
2664  }
2665 
2666  if ($a_use_asynch && $a_get_asynch_commands) {
2667  return $this->current_selection_list->getHTML(true);
2668  }
2669 
2670  return $this->current_selection_list->getHTML();
2671  }
2672 
2678  public function enableComments($a_value, $a_enable_comments_settings = true)
2679  {
2681 
2682  // global switch
2683  if ($ilSetting->get("disable_comments")) {
2684  $a_value = false;
2685  }
2686 
2687  $this->comments_enabled = (bool) $a_value;
2688  $this->comments_settings_enabled = (bool) $a_enable_comments_settings;
2689  }
2690 
2696  public function enableNotes($a_value)
2697  {
2699 
2700  // global switch
2701  if ($ilSetting->get("disable_notes")) {
2702  $a_value = false;
2703  }
2704 
2705  $this->notes_enabled = (bool) $a_value;
2706  }
2707 
2713  public function enableTags($a_value)
2714  {
2715  $tags_set = new ilSetting("tags");
2716  if (!$tags_set->get("enable")) {
2717  $a_value = false;
2718  }
2719  $this->tags_enabled = (bool) $a_value;
2720  }
2721 
2730  public function enableRating($a_value, $a_text = null, $a_categories = false, array $a_ctrl_path = null)
2731  {
2732  $this->rating_enabled = (bool) $a_value;
2733 
2734  if ($this->rating_enabled) {
2735  $this->rating_categories_enabled = (bool) $a_categories;
2736  $this->rating_text = $a_text;
2737  $this->rating_ctrl_path = $a_ctrl_path;
2738  }
2739  }
2740 
2746  public function enableMultiDownload($a_value)
2747  {
2748  $folder_set = new ilSetting("fold");
2749  if (!$folder_set->get("enable_multi_download")) {
2750  $a_value = false;
2751  }
2752  $this->multi_download_enabled = (bool) $a_value;
2753  }
2754 
2755  public function insertMultiDownloadCommand()
2756  {
2757  $objDefinition = $this->obj_definition;
2758 
2759  if ($this->std_cmd_only) {
2760  return;
2761  }
2762 
2763  if (!$objDefinition->isContainer(ilObject::_lookupType($this->obj_id))) {
2764  return false;
2765  }
2766 
2767  if (is_object($this->getContainerObject()) &&
2768  $this->getContainerObject() instanceof ilContainerGUI) {
2769  $this->ctrl->setParameter($this->getContainerObject(), "type", "");
2770  $this->ctrl->setParameter($this->getContainerObject(), "item_ref_id", "");
2771  $this->ctrl->setParameter($this->getContainerObject(), "active_node", "");
2772  // bugfix mantis 24559
2773  // undoing an erroneous change inside mantis 23516 by adding "Download Multiple Objects"-functionality for non-admins
2774  // as they don't have the possibility to use the multi-download-capability of the manage-tab
2775  $user_id = $this->user->getId();
2776  $hasAdminAccess = $this->access->checkAccessOfUser($user_id, "crs_admin", $this->ctrl->getCmd(), $_GET['ref_id']);
2777  // to still prevent duplicate download functions for admins the following if-else statement keeps the redirection for admins
2778  // while letting other course members access the original multi-download functionality
2779  if ($hasAdminAccess) {
2780  $cmd = $_GET["cmd"] == "enableAdministrationPanel" ? "render" : "enableAdministrationPanel";
2781  } else {
2782  $cmd = $_GET["cmd"] == "enableMultiDownload" ? "render" : "enableMultiDownload";
2783  }
2784  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), $cmd);
2785  $this->insertCommand($cmd_link, $this->lng->txt("download_multiple_objects"));
2786  return true;
2787  }
2788 
2789  return false;
2790  }
2791 
2792  public function enableDownloadCheckbox($a_ref_id, $a_value)
2793  {
2794  $ilAccess = $this->access;
2795 
2796  // TODO: delegate to list object class!
2797  if (!$this->getContainerObject()->isActiveAdministrationPanel() || $_SESSION["clipboard"]) {
2798  if (in_array($this->type, array("file", "fold")) &&
2799  $ilAccess->checkAccess("read", "", $a_ref_id, $this->type)) {
2800  $this->download_checkbox_state = self::DOWNLOAD_CHECKBOX_ENABLED;
2801  } else {
2802  $this->download_checkbox_state = self::DOWNLOAD_CHECKBOX_DISABLED;
2803  }
2804  } else {
2805  $this->download_checkbox_state = self::DOWNLOAD_CHECKBOX_NONE;
2806  }
2807  }
2808 
2809  public function getDownloadCheckboxState()
2810  {
2812  }
2813 
2817  public static function prepareJsLinks($a_redraw_url, $a_notes_url, $a_tags_url, $a_tpl = null)
2818  {
2819  global $DIC;
2820 
2821  $tpl = $DIC["tpl"];
2822 
2823  if (is_null($a_tpl)) {
2824  $a_tpl = $tpl;
2825  }
2826 
2827  if ($a_notes_url) {
2828  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
2829  ilNoteGUI::initJavascript($a_notes_url, IL_NOTE_PRIVATE, $a_tpl);
2830  }
2831 
2832  if ($a_tags_url) {
2833  include_once("./Services/Tagging/classes/class.ilTaggingGUI.php");
2834  ilTaggingGUI::initJavascript($a_tags_url, $a_tpl);
2835  }
2836 
2837  if ($a_redraw_url) {
2838  $a_tpl->addOnLoadCode("il.Object.setRedrawAHUrl('" .
2839  $a_redraw_url . "');");
2840  }
2841  }
2842 
2849  public function setHeaderSubObject($a_type, $a_id)
2850  {
2851  $this->sub_obj_type = $a_type;
2852  $this->sub_obj_id = (int) $a_id;
2853  }
2854 
2864  public function addHeaderIcon($a_id, $a_img, $a_tooltip = null, $a_onclick = null, $a_status_text = null, $a_href = null)
2865  {
2866  $this->header_icons[$a_id] = array("img" => $a_img,
2867  "tooltip" => $a_tooltip,
2868  "onclick" => $a_onclick,
2869  "status_text" => $a_status_text,
2870  "href" => $a_href);
2871  }
2872 
2878  public function addHeaderIconHTML($a_id, $a_html)
2879  {
2880  $this->header_icons[$a_id] = $a_html;
2881  }
2882 
2888  public function addHeaderGlyph($a_id, $a_glyph, $a_onclick = null)
2889  {
2890  $this->header_icons[$a_id] = array("glyph" => $a_glyph, "onclick" => $a_onclick);
2891  }
2892 
2893  public function setAjaxHash($a_hash)
2894  {
2895  $this->ajax_hash = $a_hash;
2896  }
2897 
2903  public function getHeaderAction(ilTemplate $a_main_tpl = null)
2904  {
2905  global $DIC;
2906 
2907  $ilUser = $this->user;
2908  $lng = $this->lng;
2909 
2910  if ($a_main_tpl == null) {
2911  $main_tpl = $DIC["tpl"];
2912  } else {
2913  $main_tpl = $a_main_tpl;
2914  }
2915 
2916  $htpl = new ilTemplate("tpl.header_action.html", true, true, "Services/Repository");
2917 
2918  $redraw_js = "il.Object.redrawActionHeader();";
2919 
2920  // tags
2921  if ($this->tags_enabled) {
2922  include_once("./Services/Tagging/classes/class.ilTagging.php");
2924  $this->obj_id,
2925  ilObject::_lookupType($this->obj_id),
2926  0,
2927  "",
2928  $ilUser->getId()
2929  );
2930  if (count($tags) > 0) {
2931  include_once("./Services/Tagging/classes/class.ilTaggingGUI.php");
2932  $lng->loadLanguageModule("tagging");
2933  /*$this->addHeaderIcon("tags",
2934  ilUtil::getImagePath("icon_tag.svg"),
2935  $lng->txt("tagging_tags").": ".count($tags),
2936  ilTaggingGUI::getListTagsJSCall($this->ajax_hash, $redraw_js),
2937  count($tags));*/
2938 
2939  $f = $this->ui->factory();
2940  $this->addHeaderGlyph(
2941  "tags",
2942  $f->glyph()->tag("#")
2943  ->withCounter($f->counter()->status((int) count($tags))),
2944  ilTaggingGUI::getListTagsJSCall($this->ajax_hash, $redraw_js)
2945  );
2946  }
2947  }
2948 
2949  // notes and comments
2950  $comments_enabled = $this->isCommentsActivated($this->type, $this->ref_id, $this->obj_id, true, false);
2951  if ($this->notes_enabled || $comments_enabled) {
2952  include_once("./Services/Notes/classes/class.ilNote.php");
2953  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
2954  $type = ($this->sub_obj_type == "")
2955  ? $this->type
2956  : $this->sub_obj_type;
2957  $cnt = ilNote::_countNotesAndComments($this->obj_id, $this->sub_obj_id, $type);
2958 
2959  if ($this->notes_enabled && $cnt[$this->obj_id][IL_NOTE_PRIVATE] > 0) {
2960  /*$this->addHeaderIcon("notes",
2961  ilUtil::getImagePath("note_unlabeled.svg"),
2962  $lng->txt("private_notes").": ".$cnt[$this->obj_id][IL_NOTE_PRIVATE],
2963  ilNoteGUI::getListNotesJSCall($this->ajax_hash, $redraw_js),
2964  $cnt[$this->obj_id][IL_NOTE_PRIVATE]
2965  );*/
2966 
2967  $f = $this->ui->factory();
2968  $this->addHeaderGlyph(
2969  "notes",
2970  $f->glyph()->note("#")
2971  ->withCounter($f->counter()->status((int) $cnt[$this->obj_id][IL_NOTE_PRIVATE])),
2972  ilNoteGUI::getListNotesJSCall($this->ajax_hash, $redraw_js)
2973  );
2974  }
2975 
2976  if ($comments_enabled && $cnt[$this->obj_id][IL_NOTE_PUBLIC] > 0) {
2977  $lng->loadLanguageModule("notes");
2978 
2979  /*$this->addHeaderIcon("comments",
2980  ilUtil::getImagePath("comment_unlabeled.svg"),
2981  $lng->txt("notes_public_comments").": ".$cnt[$this->obj_id][IL_NOTE_PUBLIC],
2982  ilNoteGUI::getListCommentsJSCall($this->ajax_hash, $redraw_js),
2983  $cnt[$this->obj_id][IL_NOTE_PUBLIC]);*/
2984 
2985  $f = $this->ui->factory();
2986  $this->addHeaderGlyph(
2987  "comments",
2988  $f->glyph()->comment("#")
2989  ->withCounter($f->counter()->status((int) $cnt[$this->obj_id][IL_NOTE_PUBLIC])),
2990  ilNoteGUI::getListCommentsJSCall($this->ajax_hash, $redraw_js)
2991  );
2992  }
2993  }
2994 
2995  // rating
2996  if ($this->rating_enabled) {
2997  include_once("./Services/Rating/classes/class.ilRatingGUI.php");
2998  $rating_gui = new ilRatingGUI();
2999  $rating_gui->enableCategories($this->rating_categories_enabled);
3000  // never rate sub objects from header action!
3001  $rating_gui->setObject($this->obj_id, $this->type);
3002  if ($this->rating_text) {
3003  $rating_gui->setYourRatingText($this->rating_text);
3004  }
3005 
3006  $this->ctrl->setParameterByClass("ilRatingGUI", "cadh", $this->ajax_hash);
3007  $this->ctrl->setParameterByClass("ilRatingGUI", "rnsb", true);
3008  if ($this->rating_ctrl_path) {
3009  $rating_gui->setCtrlPath($this->rating_ctrl_path);
3010  $ajax_url = $this->ctrl->getLinkTargetByClass($this->rating_ctrl_path, "saveRating", "", true, false);
3011  } else {
3012  // ???
3013  $ajax_url = $this->ctrl->getLinkTargetByClass("ilRatingGUI", "saveRating", "", true, false);
3014  }
3015  $main_tpl->addOnLoadCode("il.Object.setRatingUrl('" . $ajax_url . "');");
3016  $this->addHeaderIconHTML(
3017  "rating",
3018  $rating_gui->getHtml(
3019  true,
3020  $this->checkCommandAccess("read", "", $this->ref_id, $this->type),
3021  "il.Object.saveRating(%rating%);"
3022  )
3023  );
3024  }
3025 
3026  if ($this->header_icons) {
3027  include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
3028 
3029  $chunks = array();
3030  foreach ($this->header_icons as $id => $attr) {
3031  $id = "headp_" . $id;
3032 
3033  if (is_array($attr)) {
3034  if ($attr["glyph"]) {
3035  if ($attr["onclick"]) {
3036  $htpl->setCurrentBlock("prop_glyph_oc");
3037  $htpl->setVariable("GLYPH_ONCLICK", $attr["onclick"]);
3038  $htpl->parseCurrentBlock();
3039  }
3040  $renderer = $this->ui->renderer();
3041  $html = $renderer->render($attr["glyph"]);
3042  $htpl->setCurrentBlock("prop_glyph");
3043  $htpl->setVariable("GLYPH", $html);
3044  $htpl->parseCurrentBlock();
3045  } else {
3046  if ($attr["onclick"]) {
3047  $htpl->setCurrentBlock("onclick");
3048  $htpl->setVariable("PROP_ONCLICK", $attr["onclick"]);
3049  $htpl->parseCurrentBlock();
3050  }
3051 
3052  if ($attr["status_text"]) {
3053  $htpl->setCurrentBlock("status");
3054  $htpl->setVariable("PROP_TXT", $attr["status_text"]);
3055  $htpl->parseCurrentBlock();
3056  }
3057 
3058 
3059  $htpl->setCurrentBlock("prop");
3060  if ($attr["href"] || $attr["onclick"]) {
3061  $htpl->setVariable("TAG", "a");
3062  } else {
3063  $htpl->setVariable("TAG", "span");
3064  }
3065  $htpl->setVariable("PROP_ID", $id);
3066  $htpl->setVariable("IMG", ilUtil::img($attr["img"], $attr["tooltip"]));
3067  if ($attr["href"] != "") {
3068  $htpl->setVariable("PROP_HREF", ' href="' . $attr["href"] . '" ');
3069  }
3070  $htpl->parseCurrentBlock();
3071 
3072  if ($attr["tooltip"]) {
3073  ilTooltipGUI::addTooltip($id, $attr["tooltip"]);
3074  }
3075  }
3076  } else {
3077  $chunks[] = $attr;
3078  }
3079  }
3080 
3081  if (sizeof($chunks)) {
3082  $htpl->setVariable(
3083  "PROP_CHUNKS",
3084  implode("&nbsp;&nbsp;&nbsp;", $chunks) . "&nbsp;&nbsp;&nbsp;"
3085  );
3086  }
3087  }
3088 
3089  $htpl->setVariable(
3090  "ACTION_DROP_DOWN",
3091  $this->insertCommands(false, false, "", true)
3092  );
3093 
3094  return $htpl->get();
3095  }
3096 
3097 
3102  public function appendRepositoryFrameParameter($a_link)
3103  {
3104  // we should get rid of this nonsense with 4.4 (alex)
3105  if ((strtolower($_GET["baseClass"]) != "ilrepositorygui") &&
3106  is_int(strpos($a_link, "baseClass=ilRepositoryGUI"))) {
3107  if ($this->type != "frm") {
3108  $a_link =
3109  ilUtil::appendUrlParameterString($a_link, "rep_frame=1");
3110  }
3111  }
3112 
3113  return $a_link;
3114  }
3115 
3116  protected function modifyTitleLink($a_default_link)
3117  {
3118  if ($this->default_command_params) {
3119  $params = array();
3120  foreach ($this->default_command_params as $name => $value) {
3121  $params[] = $name . '=' . $value;
3122  }
3123  $params = implode('&', $params);
3124 
3125 
3126  // #12370
3127  if (!stristr($a_default_link, '?')) {
3128  $a_default_link = ($a_default_link . '?' . $params);
3129  } else {
3130  $a_default_link = ($a_default_link . '&' . $params);
3131  }
3132  }
3133  return $a_default_link;
3134  }
3135 
3139  public function modifySAHSlaunch($a_link, $wtarget)
3140  {
3141  global $DIC;
3142 
3143  if (strstr($a_link, 'ilSAHSPresentationGUI') && !$this->offline_mode) {
3144  include_once 'Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
3145  $sahs_obj = new ilObjSAHSLearningModule($this->ref_id);
3146  $om = $sahs_obj->getOpenMode();
3147  $width = $sahs_obj->getWidth();
3148  $height = $sahs_obj->getHeight();
3149  if (($om == 5 || $om == 1) && $width > 0 && $height > 0) {
3150  $om++;
3151  }
3152  if ($om != 0 && !$DIC['ilBrowser']->isMobile()) {
3153  $this->default_command["frame"] = "";
3154  $a_link = "javascript:void(0); onclick=startSAHS('" . $a_link . "','" . $wtarget . "'," . $om . "," . $width . "," . $height . ");";
3155  }
3156  }
3157  return $a_link;
3158  }
3159 
3163  public function insertPath()
3164  {
3165  $lng = $this->lng;
3166 
3167  if ($this->getPathStatus() != false) {
3168  if (!$this->path_gui instanceof \ilPathGUI) {
3169  $path_gui = new \ilPathGUI();
3170  } else {
3172  }
3173 
3174  $path_gui->enableTextOnly(!$this->path_linked);
3175  $path_gui->setUseImages(false);
3176 
3177  $start_node = $this->path_start_node
3178  ? $this->path_start_node
3179  : ROOT_FOLDER_ID;
3180 
3181  $this->tpl->setCurrentBlock("path_item");
3182  $this->tpl->setVariable('PATH_ITEM', $path_gui->getPath($start_node, $this->ref_id));
3183  $this->tpl->parseCurrentBlock();
3184 
3185  $this->tpl->setCurrentBlock("path");
3186  $this->tpl->setVariable("TXT_LOCATION", $lng->txt("locator"));
3187  $this->tpl->parseCurrentBlock();
3188  return true;
3189  }
3190  }
3191 
3198  public function insertProgressInfo()
3199  {
3200  return true;
3201  }
3202 
3203 
3207  public function insertIconsAndCheckboxes()
3208  {
3209  $lng = $this->lng;
3210  $objDefinition = $this->obj_definition;
3211 
3212  $cnt = 0;
3213  if ($this->getCheckboxStatus()) {
3214  $this->tpl->setCurrentBlock("check");
3215  $this->tpl->setVariable("VAL_ID", $this->getCommandId());
3216  $this->tpl->parseCurrentBlock();
3217  $cnt += 1;
3218  } elseif ($this->getDownloadCheckboxState() != self::DOWNLOAD_CHECKBOX_NONE) {
3219  $this->tpl->setCurrentBlock("check_download");
3220  if ($this->getDownloadCheckboxState() == self::DOWNLOAD_CHECKBOX_ENABLED) {
3221  $this->tpl->setVariable("VAL_ID", $this->getCommandId());
3222  } else {
3223  $this->tpl->setVariable("VAL_VISIBILITY", "visibility: hidden;\" disabled=\"disabled");
3224  }
3225  $this->tpl->parseCurrentBlock();
3226  $cnt += 1;
3227  } elseif ($this->getExpandStatus()) {
3228  $this->tpl->setCurrentBlock('expand');
3229 
3230  if ($this->isExpanded()) {
3231  $this->ctrl->setParameter($this->container_obj, 'expand', -1 * $this->obj_id);
3232  // "view" added, see #19922
3233  $this->tpl->setVariable('EXP_HREF', $this->ctrl->getLinkTarget($this->container_obj, 'view', $this->getUniqueItemId(true)));
3234  $this->ctrl->clearParameters($this->container_obj);
3235  $this->tpl->setVariable('EXP_IMG', ilUtil::getImagePath('tree_exp.svg'));
3236  $this->tpl->setVariable('EXP_ALT', $this->lng->txt('collapse'));
3237  } else {
3238  $this->ctrl->setParameter($this->container_obj, 'expand', $this->obj_id);
3239  // "view" added, see #19922
3240  $this->tpl->setVariable('EXP_HREF', $this->ctrl->getLinkTarget($this->container_obj, 'view', $this->getUniqueItemId(true)));
3241  $this->ctrl->clearParameters($this->container_obj);
3242  $this->tpl->setVariable('EXP_IMG', ilUtil::getImagePath('tree_col.svg'));
3243  $this->tpl->setVariable('EXP_ALT', $this->lng->txt('expand'));
3244  }
3245 
3246  $this->tpl->parseCurrentBlock();
3247  $cnt += 1;
3248  }
3249 
3250  if ($this->getIconStatus()) {
3251  if ($cnt == 1) {
3252  $this->tpl->touchBlock("i_1"); // indent
3253  }
3254 
3255  // icon link
3256  if ($this->title_link_disabled || !$this->default_command || (!$this->getCommandsStatus() && !$this->restrict_to_goto)) {
3257  } else {
3258  /* see #28926
3259  $this->tpl->setCurrentBlock("icon_link_s");
3260 
3261  if ($this->default_command["frame"] != "") {
3262  $this->tpl->setVariable("ICON_TAR", "target='" . $this->default_command["frame"] . "'");
3263  }
3264 
3265  $this->tpl->setVariable(
3266  "ICON_HREF",
3267  $this->default_command["link"]
3268  );
3269  $this->tpl->parseCurrentBlock();
3270  $this->tpl->touchBlock("icon_link_e");
3271  */
3272  }
3273 
3274  $this->tpl->setCurrentBlock("icon");
3275  if (!$objDefinition->isPlugin($this->getIconImageType())) {
3276  $this->tpl->setVariable("ALT_ICON", $lng->txt("obj_" . $this->getIconImageType()));
3277  } else {
3278  include_once("Services/Component/classes/class.ilPlugin.php");
3279  $this->tpl->setVariable("ALT_ICON",
3280  ilObjectPlugin::lookupTxtById($this->getIconImageType(), "obj_" . $this->getIconImageType()));
3281  }
3282 
3283  $this->tpl->setVariable(
3284  "SRC_ICON",
3285  $this->getTypeIcon()
3286  );
3287  $this->tpl->parseCurrentBlock();
3288  $cnt += 1;
3289  }
3290 
3291  $this->tpl->touchBlock("d_" . $cnt); // indent main div
3292  }
3293 
3298  public function getTypeIcon()
3299  {
3300  return ilObject::_getIcon(
3301  $this->obj_id,
3302  'small',
3303  $this->getIconImageType()
3304  );
3305  }
3306 
3310  public function insertSubItems()
3311  {
3312  foreach ($this->sub_item_html as $sub_html) {
3313  $this->tpl->setCurrentBlock("subitem");
3314  $this->tpl->setVariable("SUBITEM", $sub_html);
3315  $this->tpl->parseCurrentBlock();
3316  }
3317  }
3318 
3322  public function insertPositionField()
3323  {
3324  if ($this->position_enabled) {
3325  $this->tpl->setCurrentBlock("position");
3326  $this->tpl->setVariable("POS_ID", $this->position_field_index);
3327  $this->tpl->setVariable("POS_VAL", $this->position_value);
3328  $this->tpl->parseCurrentBlock();
3329  }
3330  }
3331 
3336  public function adminCommandsIncluded()
3337  {
3338  return $this->adm_commands_included;
3339  }
3340 
3344  public function storeAccessCache()
3345  {
3346  $ilUser = $this->user;
3347  if ($this->acache->getLastAccessStatus() == "miss" &&
3348  !$this->prevent_access_caching) {
3349  $this->acache->storeEntry(
3350  $ilUser->getId() . ":" . $this->ref_id,
3351  serialize($this->access_cache),
3353  );
3354  }
3355  }
3356 
3371  public function getListItemHTML(
3372  $a_ref_id,
3373  $a_obj_id,
3374  $a_title,
3375  $a_description,
3376  $a_use_asynch = false,
3377  $a_get_asynch_commands = false,
3378  $a_asynch_url = ""
3379  ) {
3380  $ilUser = $this->user;
3381 
3382  // this variable stores wheter any admin commands
3383  // are included in the output
3384  $this->adm_commands_included = false;
3385 
3386  // only for permformance exploration
3387  $type = ilObject::_lookupType($a_obj_id);
3388 
3389  // initialization
3390  $this->initItem($a_ref_id, $a_obj_id, $a_title, $a_description);
3391 
3392  // prepare ajax calls
3393  include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
3394  if ($this->context == self::CONTEXT_REPOSITORY) {
3396  } else {
3398  }
3399  $this->setAjaxHash(ilCommonActionDispatcherGUI::buildAjaxHash($node_type, $a_ref_id, $type, $a_obj_id));
3400 
3401  if ($a_use_asynch && $a_get_asynch_commands) {
3402  return $this->insertCommands(true, true);
3403  }
3404 
3405  if ($this->rating_enabled) {
3406  if (ilRating::hasRatingInListGUI($this->obj_id, $this->type)) {
3407  $may_rate = $this->checkCommandAccess("read", "", $this->ref_id, $this->type);
3408 
3409  $rating = new ilRatingGUI();
3410  $rating->setObject($this->obj_id, $this->type);
3411  /* $this->addCustomProperty(
3412  $this->lng->txt("rating_average_rating"),
3413  $rating->getListGUIProperty($this->ref_id, $may_rate, $this->ajax_hash, $this->parent_ref_id),
3414  false,
3415  true
3416  );*/
3417  $this->addCustomProperty(
3418  "",
3419  $rating->getListGUIProperty($this->ref_id, $may_rate, $this->ajax_hash, $this->parent_ref_id),
3420  false,
3421  true
3422  );
3423  }
3424  }
3425 
3426  // read from cache
3427  include_once("Services/Object/classes/class.ilListItemAccessCache.php");
3428  $this->acache = new ilListItemAccessCache();
3429  $cres = $this->acache->getEntry($ilUser->getId() . ":" . $a_ref_id);
3430  if ($this->acache->getLastAccessStatus() == "hit") {
3431  $this->access_cache = unserialize($cres);
3432  } else {
3433  // write to cache
3434  $this->storeAccessCache();
3435  }
3436 
3437  // visible check
3438  if (!$this->checkCommandAccess("visible", "", $a_ref_id, "", $a_obj_id)) {
3439  $this->resetCustomData();
3440  return "";
3441  }
3442 
3443  // BEGIN WEBDAV
3444  if ($type == 'file' and ilObjFileAccess::_isFileHidden($a_title)) {
3445  $this->resetCustomData();
3446  return "";
3447  }
3448  // END WEBDAV
3449 
3450 
3451  $this->tpl = new ilTemplate(
3452  static::$tpl_file_name,
3453  true,
3454  true,
3455  static::$tpl_component,
3456  "DEFAULT",
3457  false,
3458  true
3459  );
3460 
3461  if ($this->getCommandsStatus()) {
3462  if (!$this->getSeparateCommands()) {
3463  $this->tpl->setVariable(
3464  "COMMAND_SELECTION_LIST",
3465  $this->insertCommands($a_use_asynch, $a_get_asynch_commands, $a_asynch_url)
3466  );
3467  }
3468  }
3469 
3470  if ($this->getProgressInfoStatus()) {
3471  $this->insertProgressInfo();
3472  }
3473 
3474  // insert title and describtion
3475  $this->insertTitle();
3476  if (!$this->isMode(IL_LIST_AS_TRIGGER)) {
3477  if ($this->getDescriptionStatus()) {
3478  $this->insertDescription();
3479  }
3480  }
3481 
3482  if ($this->getSearchFragmentStatus()) {
3483  $this->insertSearchFragment();
3484  }
3485  if ($this->enabledRelevance()) {
3486  $this->insertRelevance();
3487  }
3488 
3489  // properties
3490  if ($this->getPropertiesStatus()) {
3491  $this->insertProperties();
3492  }
3493 
3494  // notice properties
3495  if ($this->getNoticePropertiesStatus()) {
3496  $this->insertNoticeProperties();
3497  }
3498 
3499  // preconditions
3500  if ($this->getPreconditionsStatus()) {
3501  $this->insertPreconditions();
3502  }
3503 
3504  // path
3505  $this->insertPath();
3506 
3507  if ($this->getItemDetailLinkStatus()) {
3508  $this->insertItemDetailLinks();
3509  }
3510 
3511  // icons and checkboxes
3512  $this->insertIconsAndCheckboxes();
3513 
3514  // input field for position
3515  $this->insertPositionField();
3516 
3517  // subitems
3518  $this->insertSubItems();
3519 
3520  // file upload
3521  if ($this->isFileUploadAllowed()) {
3522  $this->insertFileUpload();
3523  }
3524 
3525  $this->resetCustomData();
3526 
3527  $this->tpl->setVariable("DIV_CLASS", 'ilContainerListItemOuter');
3528  $this->tpl->setVariable("DIV_ID", 'data-list-item-id="' . $this->getUniqueItemId(true) . '" id = "' . $this->getUniqueItemId(true) . '"');
3529  $this->tpl->setVariable("ADDITIONAL", $this->getAdditionalInformation());
3530 
3531  // #11554 - make sure that internal ids are reset
3532  if (is_object($this->getContainerObject())) {
3533  $this->ctrl->setParameter($this->getContainerObject(), "item_ref_id", "");
3534  }
3535 
3536  return $this->tpl->get();
3537  }
3538 
3542  protected function resetCustomData()
3543  {
3544  // #15747
3545  $this->cust_prop = array();
3546  $this->cust_commands = array();
3547  $this->sub_item_html = array();
3548  $this->position_enabled = false;
3549  }
3550 
3556  public function setParentRefId($a_ref_id)
3557  {
3558  $this->parent_ref_id = $a_ref_id;
3559  }
3560 
3567  public function getUniqueItemId($a_as_div = false)
3568  {
3569  // use correct id for references
3570  $id_ref = ($this->reference_ref_id > 0)
3571  ? $this->reference_ref_id
3572  : $this->ref_id;
3573 
3574  // add unique identifier for preconditions (objects can appear twice in same container)
3575  if ($this->condition_depth) {
3576  $id_ref .= "_pc" . $this->condition_depth;
3577  }
3578 
3579  // unique
3580  $id_ref .= "_pref_" . $this->parent_ref_id;
3581 
3582  if (!$a_as_div) {
3583  return $id_ref;
3584  } else {
3585  // action menu [yellow] toggle
3586  return "lg_div_" . $id_ref;
3587  }
3588  }
3589 
3593  public function getCommandsHTML()
3594  {
3595  return $this->insertCommands();
3596  }
3597 
3601  public function isSideBlock()
3602  {
3603  return false;
3604  }
3605 
3611  public function setBoldTitle($a_bold_title)
3612  {
3613  $this->bold_title = $a_bold_title;
3614  }
3615 
3621  public function isTitleBold()
3622  {
3623  return $this->bold_title;
3624  }
3625 
3632  public static function preloadCommonProperties($a_obj_ids, $a_context)
3633  {
3634  global $DIC;
3635 
3636  $lng = $DIC->language();
3637  $ilSetting = $DIC->settings();
3638  $ilUser = $DIC->user();
3639 
3640  if ($a_context == self::CONTEXT_REPOSITORY) {
3641  $active_notes = !$ilSetting->get("disable_notes");
3642  $active_comments = !$ilSetting->get("disable_comments");
3643 
3644  if ($active_notes || $active_comments) {
3645  include_once("./Services/Notes/classes/class.ilNote.php");
3646  }
3647 
3648  if ($active_comments) {
3649  // needed for action
3650  self::$comments_activation = ilNote::getRepObjActivation($a_obj_ids);
3651  }
3652 
3653  // properties are optional
3654  if ($ilSetting->get('comments_tagging_in_lists')) {
3655  if ($active_notes || $active_comments) {
3656  self::$cnt_notes = ilNote::_countNotesAndCommentsMultiple($a_obj_ids, true);
3657 
3658  $lng->loadLanguageModule("notes");
3659  }
3660 
3661  $tags_set = new ilSetting("tags");
3662  if ($tags_set->get("enable")) {
3663  $all_users = $tags_set->get("enable_all_users");
3664 
3665  include_once("./Services/Tagging/classes/class.ilTagging.php");
3666  if (!$ilSetting->get('comments_tagging_in_lists_tags')) {
3667  self::$cnt_tags = ilTagging::_countTags($a_obj_ids, $all_users);
3668  } else {
3669  $tag_user_id = null;
3670  if (!$all_users) {
3671  $tag_user_id = $ilUser->getId();
3672  }
3673  self::$tags = ilTagging::_getListTagsForObjects($a_obj_ids, $tag_user_id);
3674  }
3675 
3676  $lng->loadLanguageModule("tagging");
3677  }
3678  }
3679 
3680  $lng->loadLanguageModule("rating");
3681  }
3682 
3683  self::$preload_done = true;
3684  }
3685 
3696  protected function isCommentsActivated($a_type, $a_ref_id, $a_obj_id, $a_header_actions, $a_check_write_access = true)
3697  {
3698  if ($this->comments_enabled) {
3699  if (!$this->comments_settings_enabled) {
3700  return true;
3701  }
3702  if ($a_check_write_access && $this->checkCommandAccess('write', '', $a_ref_id, $a_type)) {
3703  return true;
3704  }
3705  // fallback to single object check if no preloaded data
3706  // only the repository does preloadCommonProperties() yet
3707  if (!$a_header_actions && self::$preload_done) {
3708  if (self::$comments_activation[$a_obj_id][$a_type]) {
3709  return true;
3710  }
3711  } else {
3712  include_once("./Services/Notes/classes/class.ilNote.php");
3713  if (ilNote::commentsActivated($a_obj_id, 0, $a_type)) {
3714  return true;
3715  }
3716  }
3717  }
3718  return false;
3719  }
3720 
3728  public function enableTimings($a_status)
3729  {
3730  $this->timings_enabled = (bool) $a_status;
3731  }
3732 
3738  public function isFileUploadAllowed()
3739  {
3740  // check if file upload allowed
3741  include_once("./Services/FileUpload/classes/class.ilFileUploadUtil.php");
3742  return ilFileUploadUtil::isUploadAllowed($this->ref_id, $this->type);
3743  }
3744 
3748  public function insertFileUpload()
3749  {
3750  include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
3752 
3753  $upload = new ilFileUploadGUI($this->getUniqueItemId(true), $this->ref_id);
3754 
3755  $this->tpl->setCurrentBlock("fileupload");
3756  $this->tpl->setVariable("FILE_UPLOAD", $upload->getHTML());
3757  $this->tpl->parseCurrentBlock();
3758  }
3759 
3763  public function checkInfoPageOnAsynchronousRendering() : bool
3764  {
3765  return false;
3766  }
3767 }
parseConditions($toggle_id, $conditions, $obligatory=true)
getCommands()
get all current commands for a specific ref id (in the permission context of the current user) ...
getProgressInfoStatus()
get progress info status
static initFileUpload()
Initializes the file upload and loads the needed javascripts and styles.
insertTitle()
insert item title
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
Creates a path for a start and endnode.
insertIconsAndCheckboxes()
Insert icons and checkboxes.
enableInfoScreen($a_info_screen)
En/disable path.
insertSearchFragment()
Insert highlighted search fragment.
static addTooltip( $a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Adds a tooltip to an HTML element.
setConditionTarget($a_ref_id, $a_obj_id, $a_target_type)
getDescription()
getDescription overwritten in class.ilObjLinkResourceList.php
isMode($a_mode)
check current output mode
settings()
Definition: settings.php:2
getContainerObject()
get container object
init()
initialisation
insertLinkCommand()
insert link command
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id=0)
Are comments activated for object?
storeAccessCache()
Store access cache.
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
getIconStatus()
Are icons enabled?
getCommandLink($a_cmd)
Get command link url.
__construct($a_context=self::CONTEXT_REPOSITORY)
constructor
static lookupTxtById($plugin_id, $lang_var)
const IL_LIST_AS_TRIGGER
$_SESSION["AccountId"]
getTypeIcon()
Get object type specific type icon.
enableNotes($a_value)
Toogle notes action status.
static initJavascript($a_ajax_url, ilTemplate $a_main_tpl=null)
Init javascript.
global $DIC
Definition: saml.php:7
enableDelete($a_status)
En/disable delete.
insertCopyCommand($a_to_repository=false)
Insert copy command.
getCheckboxStatus()
Are checkboxes enabled?
$_GET["client_id"]
$location
Definition: buildRTE.php:44
addHeaderIcon($a_id, $a_img, $a_tooltip=null, $a_onclick=null, $a_status_text=null, $a_href=null)
static initJavascript($a_ajax_url, $a_type=IL_NOTE_PRIVATE, ilTemplate $a_main_tpl=null)
Init javascript.
insertPreconditions()
insert all missing preconditions
static translateOperator($a_obj_id, $a_operator)
Translate operator.
enableProperties($a_status)
En/disable properties.
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
$preview
addCustomCommand($a_link, $a_lang_var, $a_frame="", $onclick="")
add a custom command
getHeaderAction(ilTemplate $a_main_tpl=null)
Get header action.
resetCustomData()
reset properties and commands
getListItemHTML( $a_ref_id, $a_obj_id, $a_title, $a_description, $a_use_asynch=false, $a_get_asynch_commands=false, $a_asynch_url="")
Get all item information (title, commands, description) in HTML.
static _checkCondition($condition, $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
if(!array_key_exists('StateId', $_REQUEST)) $id
enableCut($a_status)
En/disable cut.
getAdditionalInformation()
Get additional information.
insertPasteCommand()
Insert paste command.
Access handler for personal workspace.
getItemDetailLinkStatus()
get item detail link status
getCommandsHTML()
Get commands HTML (must be called after get list item html)
static _lookupTitle($a_id)
lookup object title
createDefaultCommand($command)
Get default command link Overwritten for e.g categories,courses => they return a goto link If search ...
setBoldTitle($a_bold_title)
public boolean $a_bold_title set the item title bold
insertCommand($a_href, $a_text, $a_frame="", $a_img="", $a_cmd="", $a_onclick="")
insert command button
getSubstitutionStatus()
Get substitution status.
enablePath($a_path, $a_start_node=null, \ilPathGUI $path_gui=null)
En/disable path.
static _isActive()
Static getter.
enableSubstitutions($a_status)
Enable substitutions.
enableSearchFragments($a_status)
En/disable description.
enableMultiDownload($a_value)
Toggles whether multiple objects can be downloaded at once or not.
static _lookupUserIsOfflineMode($a_obj_id)
Checks offlineMode and returns false if.
const RENDER_STATUS_NONE
insertSubscribeCommand()
insert subscribe command
setContainerObject($container_obj)
set the container object (e.g categorygui) Used for link, delete ...
static preloadCommonProperties($a_obj_ids, $a_context)
Preload common properties.
static hasRatingInListGUI($a_obj_id, $a_obj_type)
user()
Definition: user.php:4
insertDeleteCommand()
insert cut command
static getListNotesJSCall($a_hash, $a_update_code=null)
Get list notes js call.
static lookupRenderStatus($a_obj_id)
Gets the render status for the object with the specified id.
isVisibleOnlyForced()
Force unreadable.
checkCommandAccess($a_permission, $a_cmd, $a_ref_id, $a_type, $a_obj_id="")
setDescription($a_description)
restrictToGoto($a_value)
Restrict all actions/links to goto.
enableLinkedPath($a_status)
Enable linked path.
getCommandFrame($a_cmd)
Get command target frame.
static _getInstance()
Get singleton instance of this class.
static calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='')
calculate number of obligatory items
enableRepositoryTransfer($a_value)
Enable copy/move to repository (from personal workspace)
$a_type
Definition: workflow.php:92
insertPositionField()
Insert field for positioning.
addCustomProperty( $a_property="", $a_value="", $a_alert=false, $a_newline=false)
add custom property
static getTagsForUserAndObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id)
Get tags for a user and an object.
setPositionInputField($a_field_index, $a_position_value)
Set position input field.
enableRating($a_value, $a_text=null, $a_categories=false, array $a_ctrl_path=null)
Toogle rating action status.
modifySAHSlaunch($a_link, $wtarget)
workaround: SAHS in new javavasript-created window or iframe
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static _getCommands()
get commands
getMode()
get output mode
getProperties()
Get item properties.
isFileUploadAllowed()
Gets a value indicating whether file uploads to this object are allowed or not.
Class ilRatingGUI.
getNoticeProperties()
get notice properties
static getInstance()
Factory.
enableSubscribe($a_status)
En/disable subscribe.
static hasPreview($a_obj_id, $a_type="")
Determines whether the object with the specified reference id has a preview.
getCommandId()
get command id Normally the ref id.
static getGotoLink($a_node_id, $a_obj_id, $a_additional=null)
static _countNotesAndComments( $a_rep_obj_id, $a_sub_obj_id=null, $a_obj_type="", $a_news_id=0)
Get all notes related to a specific object.
insertProgressInfo()
insert progress info
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:6
enablePreconditions($a_status)
En/disable preconditions.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
determineProperties()
Determine properties.
enableDownloadCheckbox($a_ref_id, $a_value)
insertProperties()
insert properties
static prepareJsLinks($a_redraw_url, $a_notes_url, $a_tags_url, $a_tpl=null)
Insert js/ajax links into template.
enableDescription($a_status)
En/disable description.
insertSubItems()
Insert subitems.
static lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.
$tags
Definition: croninfo.php:19
static _lookupObjId($a_id)
enabledRelevance()
enabled relevance
setAdditionalInformation($a_val)
Set additional information.
special template class to simplify handling of ITX/PEAR
Class ilObjectListGUI.
setSearchFragment($a_text)
set search fragment
static getListTagsJSCall($a_hash, $a_update_code=null)
Get tagging js call.
static getRepObjActivation($a_rep_obj_ids)
Get activation for repository objects.
insertInfoScreenCommand()
insert info screen command
static getListGUIStatus($a_obj_id, $a_image_only=true)
getSearchFragment()
get search fragment
$ilUser
Definition: imgupload.php:18
static isActive()
Is folder background download active?
enableProgressInfo($a_status)
enable progress info
getDetailsLevel()
Get current details level.
enableNoticeProperties($a_status)
En/disable notices.
const IL_LIST_FULL
getSearchFragmentStatus()
Show hide search result fragments.
getCommandImage($a_cmd)
Get command icon image.
getIconImageType()
Returns the icon image type.
insertItemDetailLinks()
insert item detail links
$txt
Definition: error.php:11
forceVisibleOnly($a_stat)
Force visible access only.
enableCommands($a_status, $a_std_only=false)
En/disable commands.
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static buildAjaxHash( $a_node_type, $a_node_id, $a_obj_type, $a_obj_id, $a_sub_type=null, $a_sub_id=null, $a_news_id=0)
Build ajax hash.
static _lookupType($a_id, $a_reference=false)
lookup object type
enableCopy($a_status)
En/disable copy.
static getListCommentsJSCall($a_hash, $a_update_code=null)
Get list comments js call.
setDetailsLevel($a_level)
Details level Currently used in Search which shows only limited properties of forums Currently used f...
Caches (check) access information on list items.
enableComments($a_value, $a_enable_comments_settings=true)
Toogle comments action status.
Class ilWebDAVLockBackend.
appendRepositoryFrameParameter($a_link)
workaround: all links into the repository (from outside) must tell repository to setup the frameset ...
getTitle()
getTitle overwritten in class.ilObjLinkResourceList.php
enableExpand($a_status)
En/Dis-able expand/collapse link.
User interface class for advanced drop-down selection lists.
setDefaultCommandParameters(array $a_params)
enableIcon($a_status)
En/Dis-able icons.
static _countTags($a_obj_ids, $a_all_users=false)
Count all tags for repository objects.
setRelevance($a_rel)
set relevance
static getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
setItemDetailLinks($a_detail_links, $a_intro_txt='')
set items detail links
enableItemDetailLinks($a_status)
enable item detail links E.g Direct links to chapters or pages
modifyTitleLink($a_default_link)
enableCheckbox($a_status)
En/Dis-able checkboxes.
static getInstance()
Get singleton instance.
setParentRefId($a_ref_id)
Set current parent ref id to enable unique js-ids (sessions, etc.)
addHeaderIconHTML($a_id, $a_html)
setConditionDepth($a_depth)
set depth for precondition output (stops at level 5)
getRelevance()
get relevance
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
enableTags($a_value)
Toogle tags action status.
static isUploadAllowed($a_ref_id, $a_type="")
Determines whether files can be uploaded to the object with the specified reference id...
isCommentsActivated($a_type, $a_ref_id, $a_obj_id, $a_header_actions, $a_check_write_access=true)
Check comments status against comments settings and context.
insertTimingsCommand()
insert edit timings command
global $ilSetting
Definition: privfeed.php:17
isSideBlock()
Returns whether current item is a block in a side column or not.
static getInstance()
Get instance.
getUniqueItemId($a_as_div=false)
Get unique item identifier (for js-actions)
setSeparateCommands($a_val)
Set separate commands.
enableLink($a_status)
En/disable link.
setMode($a_mode)
set output mode
addHeaderGlyph($a_id, $a_glyph, $a_onclick=null)
getSeparateCommands()
Get separate commands.
$i
Definition: disco.tpl.php:19
Class ilContainerGUI.
insertCommands( $a_use_asynch=false, $a_get_asynch_commands=false, $a_asynch_url="", $a_header_actions=false)
insert all commands into html code
getAlertProperties()
get all alert properties
static getObjectListAction($a_ref_id)
Get object list action.
insertCommonSocialCommands($a_header_actions=false)
Insert common social commands (comments, notes, tagging)
Interface for GUI classes (PDGUI, LuceneSearchGUI...) that have to handle administration commands (cu...
getExpandStatus()
Is expand/collapse enabled.
getDefaultCommand()
Get default command.
setHeaderSubObject($a_type, $a_id)
Set sub object identifier.
$info
Definition: index.php:5
initItem($a_ref_id, $a_obj_id, $a_title="", $a_description="")
inititialize new item (is called by getItemHTML())
static _getListTagsForObjects(array $a_obj_ids, $a_user_id=null)
Get tags for given object ids.
insertDescription()
insert item description
insertFileUpload()
Inserts a file upload component.
insertRelevance()
insert relevance
$html
Definition: example_001.php:87
getCustomProperties($a_prop)
get custom properties
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
Class ilObjSCORMLearningModule.
static _countNotesAndCommentsMultiple($a_rep_obj_ids, $a_no_sub_objs=false)
Get all notes related to multiple objcts.
enableRelevance($a_status)
enable relevance
adminCommandsIncluded()
returns whether any admin commands (link, delete, cut) are included in the output ...
addSubItemHTML($a_html)
Add HTML for subitem (used for sessions)
enableTimings($a_status)
enable timings link
insertCutCommand($a_to_repository=false)
insert cut command
$data
Definition: bench.php:6
insertSubstitutions()
Insert substitutions.