ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
7 
24 {
25  const DETAILS_MINIMAL = 10;
26  const DETAILS_SEARCH = 20 ;
27  const DETAILS_ALL = 30;
28 
29  const CONTEXT_REPOSITORY = 1;
30  const CONTEXT_WORKSPACE = 2;
31  const CONTEXT_SHOP = 3;
33 
34  var $ctrl;
37  var $properties_enabled = true;
39  var $commands_enabled = true;
40  var $cust_prop = array();
41  var $cust_commands = array();
42  var $info_screen_enabled = false;
44  var $std_cmd_only = false;
45  var $sub_item_html = array();
46 
47  protected $substitutions = null;
48  protected $substitutions_enabled = false;
49 
50  protected $icons_enabled = false;
51  protected $checkboxes_enabled = false;
52  protected $position_enabled = false;
53  protected $progress_enabled = false;
54  protected $item_detail_links_enabled = false;
55  protected $item_detail_links = array();
56  protected $item_detail_links_intro = '';
57 
58  protected $search_fragments_enabled = false;
59  protected $search_fragment = '';
60  protected $path_linked = false;
61 
62  protected $enabled_relevance = false;
63  protected $relevance = 0;
64 
65  protected $expand_enabled = false;
66  protected $is_expanded = true;
67  protected $bold_title = false;
68 
69  protected $copy_enabled = true;
70 
72 
73  protected $reference_ref_id = false;
74  protected $separate_commands = false;
75  protected $search_fragment_enabled = false;
76  protected $additional_information = false;
77  protected $static_link_enabled = false;
78 
79  protected $repository_transfer_enabled = false;
80  protected $shared = false;
81  protected $restrict_to_goto = false;
82 
83  protected $comments_enabled = false;
84  protected $comments_settings_enabled = false;
85  protected $notes_enabled = false;
86  protected $tags_enabled = false;
87 
88  protected $timings_enabled = true;
89 
90  protected $force_visible_only = false;
91 
92 
93  static protected $cnt_notes = array();
94  static protected $cnt_tags = array();
95  static protected $comments_activation = array();
96  static protected $preload_done = false;
97 
102  function ilObjectListGUI()
103  {
104  global $rbacsystem, $ilCtrl, $lng, $ilias;
105 
106  $this->rbacsystem = $rbacsystem;
107  $this->ilias = $ilias;
108  $this->ctrl = $ilCtrl;
109  $this->lng = $lng;
110  $this->mode = IL_LIST_FULL;
111  $this->path_enabled = false;
112 
113  $this->enableComments(false);
114  $this->enableNotes(false);
115  $this->enableTags(false);
116 
117 //echo "list";
118  $this->init();
119 
120  include_once('Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
121  $this->ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
122 
123  $lng->loadLanguageModule("obj");
124  }
125 
126 
133  function setContainerObject(&$container_obj)
134  {
135  $this->container_obj =& $container_obj;
136  }
137 
145  public function getContainerObject()
146  {
147  return $this->container_obj;
148  }
149 
150 
156  function init()
157  {
158  // Create static links for default command (linked title) or not
159  $this->static_link_enabled = true;
160  $this->delete_enabled = true;
161  $this->cut_enabled = true;
162  $this->subscribe_enabled = true;
163  $this->link_enabled = false;
164  $this->copy_enabled = false;
165  $this->payment_enabled = false;
166  $this->progress_enabled = false;
167  $this->notice_properties_enabled = true;
168  $this->info_screen_enabled = false;
169  $this->type = ""; // "cat", "course", ...
170  $this->gui_class_name = ""; // "ilobjcategorygui", "ilobjcoursegui", ...
171 
172  // general commands array, e.g.
173  include_once('./Services/Object/classes/class.ilObjectAccess.php');
174  $this->commands = ilObjectAccess::_getCommands();
175  }
176 
177  // Single get set methods
184  function enableProperties($a_status)
185  {
186  $this->properties_enabled = $a_status;
187 
188  return;
189  }
197  {
199  }
206  function enablePreconditions($a_status)
207  {
208  $this->preconditions_enabled = $a_status;
209 
210  return;
211  }
212 
214  {
216  }
217 
224  function enableNoticeProperties($a_status)
225  {
226  $this->notice_properties_enabled = $a_status;
227 
228  return;
229  }
237  {
239  }
246  function enableDescription($a_status)
247  {
248  $this->description_enabled = $a_status;
249 
250  return;
251  }
259  {
261  }
262 
270  {
272  }
273 
280  function enableSearchFragments($a_status)
281  {
282  $this->search_fragment_enabled = $a_status;
283 
284  return;
285  }
286 
292  public function enableLinkedPath($a_status)
293  {
294  $this->path_linked = $a_status;
295  }
296 
301  public function enabledRelevance()
302  {
304  }
305 
310  public function enableRelevance($a_status)
311  {
312  $this->enabled_relevance = $a_status;
313  }
314 
320  public function setRelevance($a_rel)
321  {
322  $this->relevance = $a_rel;
323  }
324 
330  public function getRelevance()
331  {
332  return $this->relevance;
333  }
334 
340  function enableIcon($a_status)
341  {
342  $this->icons_enabled = $a_status;
343  }
344 
350  function getIconStatus()
351  {
352  return $this->icons_enabled;
353  }
354 
360  function enableCheckbox($a_status)
361  {
362  $this->checkboxes_enabled = $a_status;
363  }
364 
370  function getCheckboxStatus()
371  {
373  }
374 
380  function enableExpand($a_status)
381  {
382  $this->expand_enabled = $a_status;
383  }
384 
390  function getExpandStatus()
391  {
392  return $this->expand_enabled;
393  }
394 
395  function setExpanded($a_status)
396  {
397  $this->is_expanded = $a_status;
398  }
399 
400  function isExpanded()
401  {
402  return $this->is_expanded;
403  }
410  function setPositionInputField($a_field_index, $a_position_value)
411  {
412  $this->position_enabled = true;
413  $this->position_field_index = $a_field_index;
414  $this->position_value = $a_position_value;
415  }
416 
423  function enableDelete($a_status)
424  {
425  $this->delete_enabled = $a_status;
426 
427  return;
428  }
435  function getDeleteStatus()
436  {
437  return $this->delete_enabled;
438  }
439 
446  function enableCut($a_status)
447  {
448  $this->cut_enabled = $a_status;
449 
450  return;
451  }
457  function getCutStatus()
458  {
459  return $this->cut_enabled;
460  }
461 
468  function enableCopy($a_status)
469  {
470  $this->copy_enabled = $a_status;
471 
472  return;
473  }
479  function getCopyStatus()
480  {
481  return $this->copy_enabled;
482  }
483 
490  function enableSubscribe($a_status)
491  {
492  $this->subscribe_enabled = $a_status;
493 
494  return;
495  }
502  {
503  return $this->subscribe_enabled;
504  }
511  function enablePayment($a_status)
512  {
513  $this->payment_enabled = $a_status;
514 
515  return;
516  }
522  function getPaymentStatus()
523  {
524  return $this->payment_enabled;
525  }
532  function enableLink($a_status)
533  {
534  $this->link_enabled = $a_status;
535 
536  return;
537  }
543  function getLinkStatus()
544  {
545  return $this->link_enabled;
546  }
547 
554  function enablePath($a_path)
555  {
556  $this->path_enabled = $a_path;
557  }
558 
564  function getPathStatus()
565  {
566  return $this->path_enabled;
567  }
568 
575  function enableCommands($a_status, $a_std_only = false)
576  {
577  $this->commands_enabled = $a_status;
578  $this->std_cmd_only = $a_std_only;
579  }
585  function getCommandsStatus()
586  {
588  }
589 
596  function enableInfoScreen($a_info_screen)
597  {
598  $this->info_screen_enabled = $a_info_screen;
599  }
600 
606  function addSubItemHTML($a_html)
607  {
608  $this->sub_item_html[] = $a_html;
609  }
610 
617  {
619  }
620 
628  public function enableProgressInfo($a_status)
629  {
630  $this->progress_enabled = $a_status;
631  }
632 
640  public function getProgressInfoStatus()
641  {
643  }
644 
652  public function enableSubstitutions($a_status)
653  {
654  $this->substitutions_enabled = $a_status;
655  }
656 
663  public function getSubstitutionStatus()
664  {
666  }
667 
676  public function enableItemDetailLinks($a_status)
677  {
678  $this->item_detail_links_enabled = $a_status;
679  }
680 
687  public function getItemDetailLinkStatus()
688  {
690  }
691 
699  public function setItemDetailLinks($a_detail_links,$a_intro_txt = '')
700  {
701  $this->item_detail_links = $a_detail_links;
702  $this->item_detail_links_intro = $a_intro_txt;
703  }
704 
712  public function insertItemDetailLinks()
713  {
714  if(!count($this->item_detail_links))
715  {
716  return true;
717  }
718  if(strlen($this->item_detail_links_intro))
719  {
720  $this->tpl->setCurrentBlock('item_detail_intro');
721  $this->tpl->setVariable('ITEM_DETAIL_INTRO_TXT',$this->item_detail_links_intro);
722  $this->tpl->parseCurrentBlock();
723  }
724 
725  foreach($this->item_detail_links as $info)
726  {
727  $this->tpl->setCurrentBlock('item_detail_link');
728  $this->tpl->setVariable('ITEM_DETAIL_LINK_TARGET',$info['target']);
729  $this->tpl->setVariable('ITEM_DETAIL_LINK_DESC',$info['desc']);
730  $this->tpl->setVariable('ITEM_DETAIL_LINK_HREF',$info['link']);
731  $this->tpl->setVariable('ITEM_DETAIL_LINK_NAME',$info['name']);
732  $this->tpl->parseCurrentBlock();
733  }
734  $this->tpl->setCurrentBlock('item_detail_links');
735  $this->tpl->parseCurrentBlock();
736  }
737 
738 
739 
744  function setTitle($a_title)
745  {
746  $this->title = $a_title;
747  }
748 
754  function getTitle()
755  {
756  return $this->title;
757  }
758 
763  function setDescription($a_description)
764  {
765  $this->description = $a_description;
766  }
767 
773  function getDescription()
774  {
775  return $this->description;
776  }
777 
783  public function setSearchFragment($a_text)
784  {
785  $this->search_fragment = $a_text;
786  }
787 
792  public function getSearchFragment()
793  {
794  return $this->search_fragment;
795  }
796 
802  function setSeparateCommands($a_val)
803  {
804  $this->separate_commands = $a_val;
805  }
806 
813  {
815  }
825  public function getCommandId()
826  {
827  return $this->ref_id;
828  }
829 
835  function setAdditionalInformation($a_val)
836  {
837  $this->additional_information = $a_val;
838  }
839 
846  {
848  }
849 
857  public function setDetailsLevel($a_level)
858  {
859  $this->details_level = $a_level;
860  }
861 
866  public function getDetailsLevel()
867  {
868  return $this->details_level;
869  }
870 
876  public function enableRepositoryTransfer($a_value)
877  {
878  $this->repository_transfer_enabled = (bool)$a_value;
879  }
880 
886  public function restrictToGoto($a_value)
887  {
888  $this->restrict_to_goto = (bool)$a_value;
889  }
890 
896  public function checkCommandAccess($a_permission,$a_cmd,$a_ref_id,$a_type,$a_obj_id="")
897  {
898  global $ilAccess;
899 
900  // e.g: subitems should not be readable since their parent sesssion is readonly.
901  if($a_permission != 'visible' and $this->isVisibleOnlyForced())
902  {
903  return false;
904  }
905 
906  $cache_prefix = null;
907  if($this->context == self::CONTEXT_WORKSPACE || $this->context == self::CONTEXT_WORKSPACE_SHARING)
908  {
909  $cache_prefix = "wsp";
910  if(!$this->ws_access)
911  {
912  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
913  $this->ws_access = new ilWorkspaceAccessHandler();
914  }
915  }
916 
917  if (isset($this->access_cache[$a_permission]["-".$a_cmd][$cache_prefix.$a_ref_id]))
918  {
919  return $this->access_cache[$a_permission]["-".$a_cmd][$cache_prefix.$a_ref_id];
920  }
921 
922  if($this->context == self::CONTEXT_REPOSITORY || $this->context == self::CONTEXT_SHOP)
923  {
924  $access = $ilAccess->checkAccess($a_permission,$a_cmd,$a_ref_id,$a_type,$a_obj_id);
925  if ($ilAccess->getPreventCachingLastResult())
926  {
927  $this->prevent_access_caching = true;
928  }
929  }
930  else
931  {
932  $access = $this->ws_access->checkAccess($a_permission,$a_cmd,$a_ref_id,$a_type);
933  }
934 
935  $this->access_cache[$a_permission]["-".$a_cmd][$cache_prefix.$a_ref_id] = $access;
936  return $access;
937  }
938 
948  function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "", $a_context = self::CONTEXT_REPOSITORY)
949  {
950  $this->access_cache = array();
951  $this->ref_id = $a_ref_id;
952  $this->obj_id = $a_obj_id;
953  $this->context = $a_context;
954  $this->setTitle($a_title);
955  $this->setDescription($a_description);
956  #$this->description = $a_description;
957 
958  // checks, whether any admin commands are included in the output
959  $this->adm_commands_included = false;
960  $this->prevent_access_caching = false;
961  }
962 
972  public function createDefaultCommand($command)
973  {
974  if($this->static_link_enabled)
975  {
976  include_once('./Services/Link/classes/class.ilLink.php');
977  if($link = ilLink::_getStaticLink($this->ref_id,$this->type,false))
978  {
979  $command['link'] = $link;
980  $command['frame'] = '_top';
981  }
982  }
983  return $command;
984  }
985 
986 
999  function getCommandLink($a_cmd)
1000  {
1001  if($this->context == self::CONTEXT_REPOSITORY || $this->context == self::CONTEXT_SHOP)
1002  {
1003  // BEGIN WebDAV Get mount webfolder link.
1004  require_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1005  if ($a_cmd == 'mount_webfolder' && ilDAVActivationChecker::_isActive())
1006  {
1007  require_once ('Services/WebDAV/classes/class.ilDAVServer.php');
1008  $davServer = ilDAVServer::getInstance();
1009 
1010  // XXX: The following is a very dirty, ugly trick.
1011  // To mount URI needs to be put into two attributes:
1012  // href and folder. This hack returns both attributes
1013  // like this: http://...mount_uri..." folder="http://...folder_uri...
1014  return $davServer->getMountURI($this->ref_id).
1015  '" folder="'.$davServer->getFolderURI($this->ref_id);
1016  }
1017  // END WebDAV Get mount webfolder link.
1018 
1019  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getCommandId());
1020  $cmd_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", $a_cmd);
1021  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
1022  return $cmd_link;
1023 
1024  /* separate method for this line
1025  $cmd_link = $this->ctrl->getLinkTargetByClass($this->gui_class_name,
1026  $a_cmd);
1027  return $cmd_link;
1028  */
1029  }
1030  else
1031  {
1032  $this->ctrl->setParameterByClass($this->gui_class_name, "ref_id", "");
1033  $this->ctrl->setParameterByClass($this->gui_class_name, "wsp_id", $this->ref_id);
1034  return $this->ctrl->getLinkTargetByClass($this->gui_class_name, $a_cmd);
1035  }
1036  }
1037 
1038 
1048  function getCommandFrame($a_cmd)
1049  {
1050  // BEGIN WebDAV Get mount webfolder link.
1051  require_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1052  if ($a_cmd == 'mount_webfolder' && ilDAVActivationChecker::_isActive())
1053  {
1054  return '_blank';
1055  }
1056  // begin-patch fm
1057  if($a_cmd == 'fileManagerLaunch')
1058  {
1059  return '_blank';
1060  }
1061  // end-patch fm
1062  return "";
1063  }
1064 
1074  function getCommandImage($a_cmd)
1075  {
1076  return "";
1077  }
1078 
1090  public function getProperties($a_item = '')
1091  {
1092  global $objDefinition;
1093 
1094  $props = array();
1095  // please list alert properties first
1096  // example (use $lng->txt instead of "Status"/"Offline" strings):
1097  // $props[] = array("alert" => true, "property" => "Status", "value" => "Offline");
1098  // $props[] = array("alert" => false, "property" => ..., "value" => ...);
1099  // ...
1100 
1101  // #8280: WebDav is only supported in repository
1102  if($this->context == self::CONTEXT_REPOSITORY)
1103  {
1104  // BEGIN WebDAV Display locking information
1105  require_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1107  {
1108  require_once ('Services/WebDAV/classes/class.ilDAVServer.php');
1109  global $ilias, $lng;
1110 
1111  // Show lock info
1112  require_once('Services/WebDAV/classes/class.ilDAVLocks.php');
1113  $davLocks = new ilDAVLocks();
1114  if ($ilias->account->getId() != ANONYMOUS_USER_ID)
1115  {
1116  $locks =& $davLocks->getLocksOnObjectObj($this->obj_id);
1117  if (count($locks) > 0)
1118  {
1119  $lockUser = new ilObjUser($locks[0]['ilias_owner']);
1120 
1121  $props[] = array(
1122  "alert" => false,
1123  "property" => $lng->txt("in_use_by"),
1124  "value" => $lockUser->getLogin(),
1125  "link" => "./ilias.php?user=".$locks[0]['ilias_owner'].'&cmd=showUserProfile&cmdClass=ilpersonaldesktopgui&cmdNode=1&baseClass=ilPersonalDesktopGUI',
1126  );
1127  }
1128  }
1129  // END WebDAV Display locking information
1130 
1131  if($this->getDetailsLevel() == self::DETAILS_SEARCH)
1132  {
1133  return $props;
1134  }
1135 
1136  // BEGIN WebDAV Display warning for invisible Unix files and files with special characters
1137  if (preg_match('/^(\\.|\\.\\.)$/', $this->title))
1138  {
1139  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1140  "value" => $lng->txt("filename_special_filename"),
1141  'propertyNameVisible' => false);
1142  }
1143  else if (preg_match('/^\\./', $this->title))
1144  {
1145  $props[] = array("alert" => false, "property" => $lng->txt("filename_visibility"),
1146  "value" => $lng->txt("filename_hidden_unix_file"),
1147  'propertyNameVisible' => false);
1148  }
1149  else if (preg_match('/~$/', $this->title))
1150  {
1151  $props[] = array("alert" => false, "property" => $lng->txt("filename_visibility"),
1152  "value" => $lng->txt("filename_hidden_backup_file"),
1153  'propertyNameVisible' => false);
1154  }
1155  else if (preg_match('/[\\/]/', $this->title))
1156  {
1157  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1158  "value" => $lng->txt("filename_special_characters"),
1159  'propertyNameVisible' => false);
1160  }
1161  else if (preg_match('/[\\\\\\/:*?"<>|]/', $this->title))
1162  {
1163  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1164  "value" => $lng->txt("filename_windows_special_characters"),
1165  'propertyNameVisible' => false);
1166  }
1167  else if (preg_match('/\\.$/', $this->title))
1168  {
1169  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1170  "value" => $lng->txt("filename_windows_empty_extension"),
1171  'propertyNameVisible' => false);
1172  }
1173  else if (preg_match('/^(\\.|\\.\\.)$/', $this->title))
1174  {
1175  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1176  "value" => $lng->txt("filename_special_filename"),
1177  'propertyNameVisible' => false);
1178  }
1179  else if (preg_match('/#/', $this->title))
1180  {
1181  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
1182  "value" => $lng->txt("filename_windows_webdav_issue"),
1183  'propertyNameVisible' => false);
1184  }
1185  }
1186  // END WebDAV Display warning for invisible files and files with special characters
1187 
1188  // BEGIN ChangeEvent: display changes.
1189  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1191  {
1192  global $ilias, $lng, $ilUser;
1193  if ($ilias->account->getId() != ANONYMOUS_USER_ID)
1194  {
1195  // Performance improvement: for container objects
1196  // we only display 'changed inside' events, for
1197  // leaf objects we only display 'object new/changed'
1198  // events
1199  $isContainer = in_array($this->type, array('cat', 'fold', 'crs', 'grp'));
1200  if($isContainer)
1201  {
1202  $state = ilChangeEvent::_lookupInsideChangeState($this->obj_id, $ilUser->getId());
1203  if($state > 0)
1204  {
1205  $props[] = array(
1206  "alert" => true,
1207  "value" => $lng->txt('state_changed_inside'),
1208  'propertyNameVisible' => false);
1209  }
1210  }
1211  /*
1212  * elseif(!$objDefinition->isAdministrationObject(ilObject::_lookupType($this->obj_id)))
1213  *
1214  * only files support write events properly
1215  */
1216  elseif($this->type == "file")
1217  {
1218  $state = ilChangeEvent::_lookupChangeState($this->obj_id, $ilUser->getId());
1219  if($state > 0)
1220  {
1221  $props[] = array(
1222  "alert" => true,
1223  "value" => $lng->txt(($state == 1) ? 'state_unread' : 'state_changed'),
1224  'propertyNameVisible' => false);
1225  }
1226  }
1227  }
1228  }
1229  // END ChangeEvent: display changes.
1230  }
1231 
1232  return $props;
1233  }
1234 
1238  function addCustomProperty($a_property = "", $a_value = "",
1239  $a_alert = false, $a_newline = false)
1240  {
1241  $this->cust_prop[] = array("property" => $a_property, "value" => $a_value,
1242  "alert" => $a_alert, "newline" => $a_newline);
1243  }
1244 
1248  function getCustomProperties($a_prop)
1249  {
1250  if (is_array($this->cust_prop))
1251  {
1252  foreach($this->cust_prop as $prop)
1253  {
1254  $a_prop[] = $prop;
1255  }
1256  }
1257  return $a_prop;
1258  }
1259 
1264  public function getAlertProperties()
1265  {
1266  $alert = array();
1267  foreach((array)$this->getProperties() as $prop)
1268  {
1269  if($prop['alert'] == true)
1270  {
1271  $alert[] = $prop;
1272  }
1273  }
1274  return $alert;
1275  }
1276 
1281  {
1282  $this->notice_prop = array();
1283  if($infos = $this->ldap_mapping->getInfoStrings($this->obj_id,true))
1284  {
1285  foreach($infos as $info)
1286  {
1287  $this->notice_prop[] = array('value' => $info);
1288  }
1289  }
1290  return $this->notice_prop ? $this->notice_prop : array();
1291  }
1295  public function addCustomCommand($a_link, $a_lang_var, $a_frame = "", $onclick = "")
1296  {
1297  $this->cust_commands[] =
1298  array("link" => $a_link, "lang_var" => $a_lang_var,
1299  "frame" => $a_frame, "onclick" => $onclick);
1300  }
1301 
1306  public function forceVisibleOnly($a_stat)
1307  {
1308  $this->force_visible_only = $a_stat;
1309  }
1310 
1315  public function isVisibleOnlyForced()
1316  {
1318  }
1319 
1343  public function getCommands()
1344  {
1345  global $ilAccess, $ilBench;
1346 
1347  $ref_commands = array();
1348  foreach($this->commands as $command)
1349  {
1350  $permission = $command["permission"];
1351  $cmd = $command["cmd"];
1352  $lang_var = $command["lang_var"];
1353  $txt = "";
1354  $info_object = null;
1355 
1356  if (isset($command["txt"]))
1357  {
1358  $txt = $command["txt"];
1359  }
1360 
1361  // BEGIN WebDAV: Suppress commands that don't make sense for anonymous users.
1362  // Suppress commands that don't make sense for anonymous users
1363  global $ilias;
1364  if ($ilias->account->getId() == ANONYMOUS_USER_ID &&
1365  $command['enable_anonymous'] == 'false')
1366  {
1367  continue;
1368  }
1369  // END WebDAV: Suppress commands that don't make sense for anonymous users.
1370 
1371  // all access checking should be made within $ilAccess and
1372  // the checkAccess of the ilObj...Access classes
1373  $ilBench->start("ilObjectListGUI", "4110_get_commands_check_access");
1374  //$access = $ilAccess->checkAccess($permission, $cmd, $this->ref_id, $this->type);
1375  $access = $this->checkCommandAccess($permission,$cmd,$this->ref_id,$this->type);
1376  $ilBench->stop("ilObjectListGUI", "4110_get_commands_check_access");
1377 
1378  if ($access)
1379  {
1380  $cmd_link = $this->getCommandLink($command["cmd"]);
1381  $cmd_frame = $this->getCommandFrame($command["cmd"]);
1382  $cmd_image = $this->getCommandImage($command["cmd"]);
1383  $access_granted = true;
1384  }
1385  else
1386  {
1387  $access_granted = false;
1388  $info_object = $ilAccess->getInfo();
1389  }
1390 
1391  if (!isset($command["default"]))
1392  {
1393  $command["default"] = "";
1394  }
1395  $ref_commands[] = array(
1396  "permission" => $permission,
1397  "cmd" => $cmd,
1398  "link" => $cmd_link,
1399  "frame" => $cmd_frame,
1400  "lang_var" => $lang_var,
1401  "txt" => $txt,
1402  "granted" => $access_granted,
1403  "access_info" => $info_object,
1404  "img" => $cmd_image,
1405  "default" => $command["default"]
1406  );
1407  }
1408 
1409  return $ref_commands;
1410  }
1411 
1412  // BEGIN WebDAV: Visualize object state in its icon.
1420  public function getIconImageType()
1421  {
1422  return $this->type;
1423  }
1424  // END WebDAV: Visualize object state in its icon.
1425 
1433  public function insertTitle()
1434  {
1435  if($this->restrict_to_goto)
1436  {
1437  $this->default_command = array("frame" => "",
1438  "link" => $this->buildGotoLink());
1439  }
1440 
1441  if (!$this->default_command || (!$this->getCommandsStatus() && !$this->restrict_to_goto))
1442  {
1443  $this->tpl->setCurrentBlock("item_title");
1444  $this->tpl->setVariable("TXT_TITLE", $this->getTitle());
1445  $this->tpl->parseCurrentBlock();
1446  }
1447  else
1448  {
1449  $this->default_command["link"] =
1450  $this->modifySAHSlaunch($this->default_command["link"],$this->default_command["frame"]);
1451 
1452  if ($this->default_command["frame"] != "")
1453  {
1454  $this->tpl->setCurrentBlock("title_linked_frame");
1455  $this->tpl->setVariable("TARGET_TITLE_LINKED", $this->default_command["frame"]);
1456  $this->tpl->parseCurrentBlock();
1457  }
1458 
1459  // workaround for repository frameset
1460  #var_dump("<pre>",$this->default_command['link'],"</pre>");
1461  $this->default_command["link"] =
1462  $this->appendRepositoryFrameParameter($this->default_command["link"]);
1463 
1464  #var_dump("<pre>",$this->default_command['link'],"</pre>");
1465 
1466 
1467  // the default command is linked with the title
1468  $this->tpl->setCurrentBlock("item_title_linked");
1469  $this->tpl->setVariable("TXT_TITLE_LINKED", $this->getTitle());
1470  $this->tpl->setVariable("HREF_TITLE_LINKED", $this->default_command["link"]);
1471  $this->tpl->parseCurrentBlock();
1472  }
1473 
1474  if ($this->bold_title == true)
1475  {
1476  $this->tpl->touchBlock('bold_title_start');
1477  $this->tpl->touchBlock('bold_title_end');
1478  }
1479  }
1480 
1481  protected function buildGotoLink()
1482  {
1483  switch($this->context)
1484  {
1485  case self::CONTEXT_WORKSPACE_SHARING:
1486  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
1487  return ilWorkspaceAccessHandler::getGotoLink($this->ref_id, $this->obj_id);
1488 
1489  default:
1490  // not implemented yet
1491  break;
1492  }
1493  }
1494 
1501  public function insertSubstitutions()
1502  {
1503  $fields_shown = false;
1504  foreach($this->substitutions->getParsedSubstitutions($this->ref_id,$this->obj_id) as $data)
1505  {
1506  if($data['bold'])
1507  {
1508  $data['name'] = '<strong>'.$data['name'].'</strong>';
1509  $data['value'] = '<strong>'.$data['value'].'</strong>';
1510  }
1511  $this->tpl->touchBlock("std_prop");
1512  $this->tpl->setCurrentBlock('item_property');
1513  if($data['show_field'])
1514  {
1515  $this->tpl->setVariable('TXT_PROP',$data['name']);
1516  }
1517  $this->tpl->setVariable('VAL_PROP',$data['value']);
1518  $this->tpl->parseCurrentBlock();
1519 
1520  if($data['newline'])
1521  {
1522  $this->tpl->touchBlock('newline_prop');
1523  }
1524  $fields_shown = false;
1525 
1526  }
1527  if($fields_shown)
1528  {
1529  $this->tpl->touchBlock('newline_prop');
1530  }
1531  }
1532 
1533 
1542  {
1543  if($this->getSubstitutionStatus())
1544  {
1545  $this->insertSubstitutions();
1546  if(!$this->substitutions->isDescriptionEnabled())
1547  {
1548  return true;
1549  }
1550  }
1551 
1552  $this->tpl->setCurrentBlock("item_description");
1553  $this->tpl->setVariable("TXT_DESC", $this->getDescription());
1554  $this->tpl->parseCurrentBlock();
1555  }
1556 
1561  public function insertSearchFragment()
1562  {
1563  if(strlen($this->getSearchFragment()))
1564  {
1565  $this->tpl->setCurrentBlock('search_fragment');
1566  $this->tpl->setVariable('TXT_SEARCH_FRAGMENT',$this->getSearchFragment().' ...');
1567  $this->tpl->parseCurrentBlock();
1568  }
1569  }
1570 
1576  public function insertRelevance()
1577  {
1578  global $lng;
1579 
1580  if(!$this->enabledRelevance() or !(int) $this->getRelevance())
1581  {
1582  return false;
1583  }
1584 
1585  $width1 = (int) $this->getRelevance();
1586  $width2 = (int) (100 - $width1);
1587 
1588  $this->tpl->setCurrentBlock('relevance');
1589  #$this->tpl->setVariable('TXT_RELEVANCE',$lng->txt('search_relevance'));
1590  $this->tpl->setVariable('VAL_REL',sprintf("%.02f %%",$this->getRelevance()));
1591  $this->tpl->setVariable('WIDTH_A',$width1);
1592  $this->tpl->setVariable('WIDTH_B',$width2);
1593  $this->tpl->setVariable('IMG_A',ilUtil::getImagePath("relevance_blue.png"));
1594  $this->tpl->setVariable('IMG_B',ilUtil::getImagePath("relevance_dark.png"));
1595  $this->tpl->parseCurrentBlock();
1596 
1597  }
1598 
1604  function setMode($a_mode)
1605  {
1606  $this->mode = $a_mode;
1607  }
1608 
1614  function getMode()
1615  {
1616  return $this->mode;
1617  }
1618 
1622  function setConditionDepth($a_depth)
1623  {
1624  $this->condition_depth = $a_depth;
1625  }
1626 
1634  function isMode($a_mode)
1635  {
1636  if ($a_mode == $this->mode)
1637  {
1638  return true;
1639  }
1640  else
1641  {
1642  return false;
1643  }
1644  }
1645 
1651  function insertProperties($a_item = '')
1652  {
1653  global $ilAccess, $lng, $ilUser;
1654 
1655  $props = $this->getProperties($a_item);
1656  $props = $this->getCustomProperties($props);
1657 
1658  // add no item access note in public section
1659  // for items that are visible but not readable
1660  if ($this->ilias->account->getId() == ANONYMOUS_USER_ID)
1661  {
1662  if (!$ilAccess->checkAccess("read", "", $this->ref_id, $this->type, $this->obj_id))
1663  {
1664  $props[] = array("alert" => true,
1665  "value" => $lng->txt("no_access_item_public"),
1666  "newline" => true);
1667  }
1668  }
1669 
1670  // reference objects have translated ids, revert to originals
1671  $note_ref_id = $this->ref_id;
1672  $note_obj_id = $this->obj_id;
1673  if($this->reference_ref_id)
1674  {
1675  $note_ref_id = $this->reference_ref_id;
1676  $note_obj_id = $this->reference_obj_id;
1677  }
1678 
1679  $redraw_js = "il.Object.redrawListItem(".$note_ref_id.");";
1680 
1681  // add common properties (comments, notes, tags)
1682  if ((self::$cnt_notes[$note_obj_id][IL_NOTE_PRIVATE] > 0 ||
1683  self::$cnt_notes[$note_obj_id][IL_NOTE_PUBLIC] > 0 ||
1684  self::$cnt_tags[$note_obj_id] > 0) &&
1685  ($ilUser->getId() != ANONYMOUS_USER_ID))
1686  {
1687  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
1688  include_once("./Services/Tagging/classes/class.ilTaggingGUI.php");
1689 
1690  $nl = true;
1691  if ($this->isCommentsActivated($this->type, $this->ref_id, $this->obj_id, false, false)
1692  && self::$cnt_notes[$note_obj_id][IL_NOTE_PUBLIC] > 0)
1693  {
1694  $props[] = array("alert" => false,
1695  "property" => $lng->txt("notes_comments"),
1696  "value" => "<a href='#' onclick=\"return ".
1697  ilNoteGUI::getListCommentsJSCall($this->ajax_hash, $redraw_js).";\">".
1698  self::$cnt_notes[$note_obj_id][IL_NOTE_PUBLIC]."</a>",
1699  "newline" => $nl);
1700  $nl = false;
1701  }
1702 
1703  if ($this->notes_enabled && self::$cnt_notes[$note_obj_id][IL_NOTE_PRIVATE] > 0)
1704  {
1705  $props[] = array("alert" => false,
1706  "property" => $lng->txt("notes"),
1707  "value" => "<a href='#' onclick=\"return ".
1708  ilNoteGUI::getListNotesJSCall($this->ajax_hash, $redraw_js).";\">".
1709  self::$cnt_notes[$note_obj_id][IL_NOTE_PRIVATE]."</a>",
1710  "newline" => $nl);
1711  $nl = false;
1712  }
1713  if ($this->tags_enabled && self::$cnt_tags[$note_obj_id] > 0)
1714  {
1715  $tags_set = new ilSetting("tags");
1716  if ($tags_set->get("enable"))
1717  {
1718  $props[] = array("alert" => false,
1719  "property" => $lng->txt("tagging_tags"),
1720  "value" => "<a href='#' onclick=\"return ".
1721  ilTaggingGUI::getListTagsJSCall($this->ajax_hash, $redraw_js).";\">".
1722  self::$cnt_tags[$note_obj_id]."</a>",
1723  "newline" => $nl);
1724  $nl = false;
1725  }
1726  }
1727  }
1728 
1729  $cnt = 1;
1730  if (is_array($props) && count($props) > 0)
1731  {
1732  foreach($props as $prop)
1733  {
1734  // BEGIN WebDAV: Display a separator between properties.
1735  if ($cnt > 1)
1736  {
1737  $this->tpl->touchBlock("separator_prop");
1738  }
1739  // END WebDAV: Display a separator between properties.
1740 
1741  if ($prop["alert"] == true)
1742  {
1743  $this->tpl->touchBlock("alert_prop");
1744  }
1745  else
1746  {
1747  $this->tpl->touchBlock("std_prop");
1748  }
1749  if ($prop["newline"] == true && $cnt > 1)
1750  {
1751  $this->tpl->touchBlock("newline_prop");
1752  }
1753  //BEGIN WebDAV: Support hidden property names.
1754  if (isset($prop["property"]) && $prop['propertyNameVisible'] !== false)
1755  //END WebDAV: Support hidden property names.
1756  {
1757  $this->tpl->setCurrentBlock("prop_name");
1758  $this->tpl->setVariable("TXT_PROP", $prop["property"]);
1759  $this->tpl->parseCurrentBlock();
1760  }
1761  $this->tpl->setCurrentBlock("item_property");
1762  //BEGIN WebDAV: Support links in property values.
1763  if ($prop['link'])
1764  {
1765  $this->tpl->setVariable("LINK_PROP", $prop['link']);
1766  $this->tpl->setVariable("LINK_VAL_PROP", $prop["value"]);
1767  }
1768  else
1769  {
1770  $this->tpl->setVariable("VAL_PROP", $prop["value"]);
1771  }
1772  //END WebDAV: Support links in property values.
1773  $this->tpl->parseCurrentBlock();
1774 
1775  $cnt++;
1776  }
1777  $this->tpl->setCurrentBlock("item_properties");
1778  $this->tpl->parseCurrentBlock();
1779  }
1780  }
1781 
1783  {
1784  $this->getNoticeProperties();
1785  foreach($this->notice_prop as $property)
1786  {
1787  $this->tpl->setCurrentBlock('notice_item');
1788  $this->tpl->setVariable('NOTICE_ITEM_VALUE',$property['value']);
1789  $this->tpl->parseCurrentBlock();
1790  }
1791  $this->tpl->setCurrentBlock('notice_property');
1792  $this->tpl->parseCurrentBlock();
1793  }
1794 
1795 
1801  function insertPayment()
1802  {
1803  global $ilAccess,$ilObjDataCache,$ilUser;
1804 
1805  if(IS_PAYMENT_ENABLED && $this->payment_enabled)
1806  {
1807  include_once './Services/Payment/classes/class.ilPaymentObject.php';
1808  include_once './Services/Payment/classes/class.ilPaymentBookings.php';
1809 
1810  if(ilPaymentobject::_requiresPurchaseToAccess($this->ref_id))
1811  {
1812  if(ilPaymentBookings::_hasAccess(ilPaymentObject::_lookupPobjectId($a_ref_id), $ilUser->getId()))
1813  {
1814  // get additional information about order_date and duration
1815 
1816  $order_infos = array();
1818 
1819  if(count($order_infos) > 0)
1820  {
1821  global $lng;
1822  $pay_lang = $lng;
1823  $pay_lang->loadLanguageModule('payment');
1824  $alert = true;
1825  $a_newline = true;
1826  $a_property = $pay_lang->txt('object_purchased_date');
1827  $a_value = ilDatePresentation::formatDate(new ilDateTime($order_infos["order_date"],IL_CAL_UNIX));
1828 
1829  $this->addCustomProperty($a_property, $a_value, $alert, $a_newline);
1830 
1831  $alert = true;
1832  $a_newline = true;
1833  $a_property = $this->lng->txt('object_duration');
1834  if($order_infos['duration'] == 0)
1835  $a_value = $pay_lang->txt('unlimited_duration');
1836  else
1837  $a_value = $order_infos['duration'] .' '.$this->lng->txt('months');
1838  $this->addCustomProperty($a_property, $a_value, $alert, $a_newline);
1839  }
1840 
1841  // check for extension prices
1842  if(ilPaymentObject::_hasExtensions($this->ref_id))
1843  {
1844  $has_extension_prices = true;
1845  $this->insertPaymentCommand($has_extension_prices);
1846  }
1847 
1848  }
1849  else
1850  {
1851  // only relevant and needed for the shop content page
1852 
1853  $this->ctpl = new ilTemplate("tpl.container_list_item_commands.html", true, true,
1854  "Services/Container", "DEFAULT", false, true);
1855  $this->ctpl->setCurrentBlock('payment');
1856  $this->ctpl->setVariable('PAYMENT_TYPE_IMG', ilUtil::getImagePath('icon_pays.png'));
1857  $this->ctpl->setVariable('PAYMENT_ALT_IMG', $this->lng->txt('payment_system') . ': ' . $this->lng->txt('payment_buyable'));
1858  $this->ctpl->parseCurrentBlock();
1859 
1860  $this->insertPaymentCommand();
1861  }
1862  }
1863  }
1864  }
1865 
1866  protected function insertPaymentCommand($has_extension_prices = false)
1867  {
1868  $commands = $this->getCommands($this->ref_id, $this->obj_id);
1869  foreach($commands as $command)
1870  {
1871  if($command['default'] === true)
1872  {
1873  $command = $this->createDefaultCommand($command);
1874 // if(is_null($command['link']) )
1875 // {
1876  switch($this->type)
1877  {
1878  case 'sahs':
1879  $command['link'] = 'ilias.php?baseClass=ilSAHSPresentationGUI&ref_id='.$this->ref_id;
1880  break;
1881 
1882  case 'lm':
1883  $command['link'] = 'ilias.php?baseClass=ilLMPresentationGUI&ref_id='.$this->ref_id;
1884  break;
1885  case 'exc':
1886  default:
1887  $command['link'] = 'ilias.php?baseClass=ilShopController&cmdClass=ilshoppurchasegui&ref_id='.$this->ref_id;
1888  break;
1889  }
1890 // }
1891 
1892  $type = $this->type;
1893  if(strpos($command['link'], '_'.$type.'_') !== false)
1894  {
1895  $demo_link = str_replace('_'.$type.'_', '_'.$type.'purchasetypedemo_', $command['link']);
1896  $buy_link = str_replace('_'.$type.'_', '_'.$type.'purchasetypebuy_', $command['link']);
1897  }
1898  else
1899  {
1900  $demo_link = $command['link'].(strpos($command['link'], '?') === false ? '?' : '&').'purchasetype=demo';
1901  $buy_link = $command['link'].(strpos($command['link'], '?') === false ? '?' : '&').'purchasetype=buy';
1902  }
1903 
1904  $this->current_selection_list->addItem($this->lng->txt('payment_demo'), "", $demo_link, $a_img, $this->lng->txt('payment_demo'), $command['frame']);
1905  if($has_extension_prices == true)
1906  {
1907  $this->current_selection_list->addItem($this->lng->txt('buy_extension'), "", $buy_link, $a_img, $this->lng->txt('buy_extension'), $command['frame']);
1908  }
1909  else
1910  $this->current_selection_list->addItem($this->lng->txt('buy'), "", $buy_link, $a_img, $this->lng->txt('buy'), $command['frame']);
1911 
1912  }
1913  }
1914  }
1915 
1916  protected function parseConditions($toggle_id,$conditions,$obligatory = true)
1917  {
1918  global $ilAccess, $lng, $objDefinition,$tree;
1919 
1920  $num_required = ilConditionHandler::calculateRequiredTriggers($this->ref_id, $this->obj_id);
1921  $num_optional_required =
1922  $num_required - count($conditions) + count(ilConditionHandler::getOptionalConditionsOfTarget($this->ref_id, $this->obj_id));
1923 
1924  // Check if all conditions are fullfilled
1925  $visible_conditions = array();
1926  $passed_optional = 0;
1927  foreach($conditions as $condition)
1928  {
1929  if($obligatory and !$condition['obligatory'])
1930  {
1931  continue;
1932  }
1933  if(!$obligatory and $condition['obligatory'])
1934  {
1935  continue;
1936  }
1937 
1938  if($tree->isDeleted($condition['trigger_ref_id']))
1939  {
1940  continue;
1941  }
1942 
1943  include_once 'Services/Container/classes/class.ilMemberViewSettings.php';
1944  $ok = ilConditionHandler::_checkCondition($condition['id']) and
1945  !ilMemberViewSettings::getInstance()->isActive();
1946 
1947  if(!$ok)
1948  {
1949  $visible_conditions[] = $condition['id'];
1950  }
1951 
1952  if(!$obligatory and $ok)
1953  {
1954  ++$passed_optional;
1955  // optional passed
1956  if($passed_optional >= $num_optional_required)
1957  {
1958  return true;
1959  }
1960  }
1961  }
1962 
1963  foreach($conditions as $condition)
1964  {
1965  if(!in_array($condition['id'], $visible_conditions))
1966  {
1967  continue;
1968  }
1969 
1970  $cond_txt = $lng->txt("condition_".$condition["operator"])." ".
1971  $condition["value"];
1972 
1973  // display trigger item
1974  $class = $objDefinition->getClassName($condition["trigger_type"]);
1975  $location = $objDefinition->getLocation($condition["trigger_type"]);
1976  if ($class == "" && $location == "")
1977  {
1978  continue;
1979  }
1980  $missing_cond_exist = true;
1981 
1982  $full_class = "ilObj".$class."ListGUI";
1983  include_once($location."/class.".$full_class.".php");
1984  $item_list_gui = new $full_class($this);
1985  $item_list_gui->setMode(IL_LIST_AS_TRIGGER);
1986  $item_list_gui->enablePath(false);
1987  $item_list_gui->enableIcon(true);
1988  $item_list_gui->setConditionDepth($this->condition_depth + 1);
1989  $item_list_gui->addCustomProperty($this->lng->txt("precondition_required_itemlist"), $cond_txt, false, true);
1990  $trigger_html = $item_list_gui->getListItemHTML($condition['trigger_ref_id'],
1991  $condition['trigger_obj_id'], ilObject::_lookupTitle($condition["trigger_obj_id"]),
1992  "");
1993  $this->tpl->setCurrentBlock("precondition");
1994  if ($trigger_html == "")
1995  {
1996  $trigger_html = $this->lng->txt("precondition_not_accessible");
1997  }
1998  $this->tpl->setVariable("TXT_CONDITION", trim($cond_txt));
1999  $this->tpl->setVariable("TRIGGER_ITEM", $trigger_html);
2000  $this->tpl->parseCurrentBlock();
2001  }
2002 
2003  if ($missing_cond_exist and $obligatory)
2004  {
2005  $this->tpl->setCurrentBlock("preconditions");
2006  $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_obl_".$toggle_id);
2007  $this->tpl->setVariable("TXT_PRECONDITIONS", $lng->txt("preconditions_obligatory_hint"));
2008  $this->tpl->parseCurrentBlock();
2009 
2010  }
2011  elseif($missing_cond_exist and !$obligatory)
2012  {
2013  $this->tpl->setCurrentBlock("preconditions");
2014  $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_opt_".$toggle_id);
2015  $this->tpl->setVariable("TXT_PRECONDITIONS", sprintf($lng->txt("preconditions_optional_hint"),$num_optional_required));
2016  $this->tpl->parseCurrentBlock();
2017  }
2018 
2019  return !$missing_cond_exist;
2020  }
2021 
2026  {
2027  global $ilAccess, $lng, $objDefinition,$tree;
2028 
2029  include_once("./Services/AccessControl/classes/class.ilConditionHandler.php");
2030 
2031  $missing_cond_exist = false;
2032 
2033  // do not show multi level conditions (messes up layout)
2034  if ($this->condition_depth > 0)
2035  {
2036  return;
2037  }
2038 
2039  // Sort by title
2040  /*
2041  foreach(ilConditionHandler::_getConditionsOfTarget($this->ref_id, $this->obj_id) as $condition)
2042  {
2043  $condition['title'] = ilObject::_lookupTitle($condition['trigger_obj_id']);
2044  }
2045  */
2046 
2047  $conditions = ilConditionHandler::_getConditionsOfTarget($this->ref_id, $this->obj_id);
2048  if(sizeof($conditions))
2049  {
2050  for($i = 0; $i < count($conditions); $i++)
2051  {
2052  $conditions[$i]['title'] = ilObject::_lookupTitle($conditions[$i]['trigger_obj_id']);
2053  }
2054  $conditions = ilUtil::sortArray($conditions,'title','DESC');
2055 
2056  // revert to reference original id
2057  $div_id = $this->reference_ref_id;
2058  if(!$div_id)
2059  {
2060  $div_id = $this->ref_id;
2061  }
2062 
2063  // Show obligatory and optional preconditions seperated
2064  $all_done_obl = $this->parseConditions($div_id,$conditions,true);
2065  $all_done_opt = $this->parseConditions($div_id,$conditions,false);
2066 
2067  if(!$all_done_obl || !$all_done_opt)
2068  {
2069  $this->tpl->setCurrentBlock("preconditions_toggle");
2070  $this->tpl->setVariable("PRECONDITION_TOGGLE_INTRO", $this->lng->txt("precondition_toggle"));
2071  $this->tpl->setVariable("PRECONDITION_TOGGLE_TRIGGER", $this->lng->txt("show"));
2072  $this->tpl->setVariable("PRECONDITION_TOGGLE_ID", $div_id);
2073  $this->tpl->setVariable("TXT_PRECONDITION_SHOW", $this->lng->txt("show"));
2074  $this->tpl->setVariable("TXT_PRECONDITION_HIDE", $this->lng->txt("hide"));
2075  $this->tpl->parseCurrentBlock();
2076  }
2077  }
2078  }
2079 
2088  function insertCommand($a_href, $a_text, $a_frame = "", $a_img = "", $a_cmd = "", $a_onclick = "")
2089  {
2090  $prevent_background_click = false;
2091  if ($a_cmd =='mount_webfolder')
2092  {
2093  $prevent_background_click = true;
2094  }
2095  $this->current_selection_list->addItem($a_text, "", $a_href, $a_img, $a_text, $a_frame,
2096  "", $prevent_background_click, $a_onclick);
2097  }
2098 
2107  {
2108  if ($this->std_cmd_only)
2109  {
2110  return;
2111  }
2112 
2113  if(is_object($this->getContainerObject()) and
2115  {
2116  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type))
2117  {
2118  $this->ctrl->setParameter($this->getContainerObject(),'item_ref_id',$this->getCommandId());
2119  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "delete");
2120  $this->insertCommand($cmd_link, $this->lng->txt("delete"));
2121  $this->adm_commands_included = true;
2122  return true;
2123  }
2124  return false;
2125  }
2126 
2127  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type))
2128  {
2129  $this->ctrl->setParameter($this->container_obj, "ref_id",
2130  $this->container_obj->object->getRefId());
2131  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2132  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "delete");
2133  $this->insertCommand($cmd_link, $this->lng->txt("delete"), "",
2134  ilUtil::getImagePath("cmd_delete_s.png"));
2135  $this->adm_commands_included = true;
2136  }
2137  }
2138 
2147  {
2148  global $ilAccess;
2149 
2150  if ($this->std_cmd_only)
2151  {
2152  return;
2153  }
2154  // BEGIN PATCH Lucene search
2155 
2156  if(is_object($this->getContainerObject()) and
2158  {
2159  global $objDefinition;
2160 
2161  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type) and
2162  $objDefinition->allowLink(ilObject::_lookupType($this->obj_id)))
2163  {
2164  $this->ctrl->setParameter($this->getContainerObject(),'item_ref_id',$this->getCommandId());
2165  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "link");
2166  $this->insertCommand($cmd_link, $this->lng->txt("link"));
2167  $this->adm_commands_included = true;
2168  return true;
2169  }
2170  return false;
2171  }
2172  // END PATCH Lucene Search
2173 
2174  // if the permission is changed here, it has
2175  // also to be changed in ilContainerGUI, admin command check
2176  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type))
2177  {
2178  $this->ctrl->setParameter($this->container_obj, "ref_id",
2179  $this->container_obj->object->getRefId());
2180  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2181  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "link");
2182  $this->insertCommand($cmd_link, $this->lng->txt("link"), "",
2183  ilUtil::getImagePath("cmd_link_s.png"));
2184  $this->adm_commands_included = true;
2185  }
2186  }
2187 
2194  function insertCutCommand($a_to_repository = false)
2195  {
2196  global $ilAccess;
2197 
2198  if ($this->std_cmd_only)
2199  {
2200  return;
2201  }
2202  // BEGIN PATCH Lucene search
2203  if(is_object($this->getContainerObject()) and
2205  {
2206  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type))
2207  {
2208  $this->ctrl->setParameter($this->getContainerObject(),'item_ref_id',$this->getCommandId());
2209  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "cut");
2210  $this->insertCommand($cmd_link, $this->lng->txt("move"));
2211  $this->adm_commands_included = true;
2212  return true;
2213  }
2214  return false;
2215  }
2216  // END PATCH Lucene Search
2217 
2218  // if the permission is changed here, it has
2219  // also to be changed in ilContainerContentGUI, determineAdminCommands
2220  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type) &&
2221  $this->container_obj->object)
2222  {
2223  $this->ctrl->setParameter($this->container_obj, "ref_id",
2224  $this->container_obj->object->getRefId());
2225  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2226 
2227  if(!$a_to_repository)
2228  {
2229  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "cut");
2230  $this->insertCommand($cmd_link, $this->lng->txt("move"), "",
2231  ilUtil::getImagePath("cmd_move_s.png"));
2232  }
2233  else
2234  {
2235  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "cut_for_repository");
2236  $this->insertCommand($cmd_link, $this->lng->txt("wsp_move_to_repository"), "",
2237  ilUtil::getImagePath("cmd_move_s.png"));
2238  }
2239 
2240  $this->adm_commands_included = true;
2241  }
2242  }
2243 
2249  public function insertCopyCommand($a_to_repository = false)
2250  {
2251  if($this->std_cmd_only)
2252  {
2253  return;
2254  }
2255 
2256  if($this->checkCommandAccess('copy', 'copy', $this->ref_id, $this->type))
2257  {
2258  if($this->context != self::CONTEXT_WORKSPACE && $this->context != self::CONTEXT_WORKSPACE_SHARING)
2259  {
2260  $this->ctrl->setParameterByClass('ilobjectcopygui','source_id',$this->getCommandId());
2261  $cmd_copy = $this->ctrl->getLinkTargetByClass('ilobjectcopygui','initTargetSelection');
2262  $this->insertCommand($cmd_copy, $this->lng->txt('copy'));
2263  }
2264  else
2265  {
2266  $this->ctrl->setParameter($this->container_obj, "ref_id",
2267  $this->container_obj->object->getRefId());
2268  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2269 
2270  if(!$a_to_repository)
2271  {
2272  $cmd_copy = $this->ctrl->getLinkTarget($this->container_obj, 'copy');
2273  $this->insertCommand($cmd_copy, $this->lng->txt('copy'));
2274  }
2275  else
2276  {
2277  $cmd_copy = $this->ctrl->getLinkTarget($this->container_obj, 'copy_to_repository');
2278  $this->insertCommand($cmd_copy, $this->lng->txt('wsp_copy_to_repository'));
2279  }
2280  }
2281 
2282  $this->adm_commands_included = true;
2283  }
2284  return;
2285  }
2286 
2287 
2292  {
2293  global $ilAccess, $objDefinition;
2294 
2295  if ($this->std_cmd_only)
2296  {
2297  return;
2298  }
2299 
2300  if(!$objDefinition->isContainer(ilObject::_lookupType($this->obj_id)))
2301  {
2302  return false;
2303  }
2304 
2305  if(is_object($this->getContainerObject()) and
2306  $this->getContainerObject() instanceof ilAdministrationCommandHandling and
2307  isset($_SESSION['clipboard']))
2308  {
2309  $this->ctrl->setParameter($this->getContainerObject(),'item_ref_id',$this->getCommandId());
2310  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "paste");
2311  $this->insertCommand($cmd_link, $this->lng->txt("paste"));
2312  $this->adm_commands_included = true;
2313  return true;
2314  }
2315  return false;
2316  }
2317 
2326  {
2327  global $ilSetting;
2328 
2329  if ($this->std_cmd_only)
2330  {
2331  return;
2332  }
2333 
2334  if((int)$ilSetting->get('disable_my_offers'))
2335  {
2336  return;
2337  }
2338 
2340 
2341  if ($this->ilias->account->getId() != ANONYMOUS_USER_ID)
2342  {
2343  // BEGIN WebDAV: Lock/Unlock objects
2344  /* This code section is temporarily commented out.
2345  I will reactivate it at a later point, when I get the
2346  the backend working properly. - Werner Randelshofer 2008-04-17
2347  if (is_object($this->container_obj) && $this->rbacsystem->checkAccess("write", $this->ref_id))
2348  {
2349  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
2350  if (ilDAVServer::_isActive() && ilDAVServer::_isActionsVisible())
2351  {
2352  $this->ctrl->setParameter($this->container_obj, "ref_id",
2353  $this->container_obj->object->getRefId());
2354  $this->ctrl->setParameter($this->container_obj, "type", $this->type);
2355  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->ref_id);
2356  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "lock");
2357  $this->insertCommand($cmd_link, $this->lng->txt("lock"));
2358 
2359  $this->ctrl->setParameter($this->container_obj, "ref_id",
2360  $this->container_obj->object->getRefId());
2361  $this->ctrl->setParameter($this->container_obj, "type", $this->type);
2362  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->ref_id);
2363  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "unlock");
2364  $this->insertCommand($cmd_link, $this->lng->txt("unlock"));
2365  }
2366  }
2367  */
2368  // END WebDAV: Lock/Unlock objects
2369 
2370  if (!$this->ilias->account->isDesktopItem($this->getCommandId(), $type))
2371  {
2372  // Pass type and object ID to ilAccess to improve performance
2373  global $ilAccess;
2374  if ($this->checkCommandAccess("read", "", $this->ref_id, $this->type, $this->obj_id))
2375  {
2376  if($this->getContainerObject() instanceof ilDesktopItemHandling)
2377  {
2378  $this->ctrl->setParameter($this->container_obj, "type", $type);
2379  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2380  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "addToDesk");
2381  $this->insertCommand($cmd_link, $this->lng->txt("to_desktop"), "",
2382  ilUtil::getImagePath("cmd_pd_put_s.png"));
2383  }
2384  }
2385  }
2386  else
2387  {
2388  if ($this->getContainerObject() instanceof ilDesktopItemHandling)
2389  {
2390  $this->ctrl->setParameter($this->container_obj, "type", $type);
2391  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2392  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "removeFromDesk");
2393  $this->insertCommand($cmd_link, $this->lng->txt("unsubscribe"), "",
2394  ilUtil::getImagePath("cmd_pd_rem_s.png"));
2395  }
2396  }
2397  }
2398  }
2399 
2404  {
2405  if ($this->std_cmd_only)
2406  {
2407  return;
2408  }
2409  $cmd_link = $this->getCommandLink("infoScreen");
2410  $cmd_frame = $this->getCommandFrame("infoScreen");
2411  $this->insertCommand($cmd_link, $this->lng->txt("info_short"), $cmd_frame,
2412  ilUtil::getImagePath("cmd_info_s.png"));
2413  }
2414 
2421  function insertCommonSocialCommands($a_header_actions = false)
2422  {
2423  global $ilSetting, $lng, $ilUser, $tpl;
2424 
2425  if ($this->std_cmd_only ||
2426  ($ilUser->getId() == ANONYMOUS_USER_ID))
2427  {
2428  return;
2429  }
2430  $lng->loadLanguageModule("notes");
2431  $lng->loadLanguageModule("tagging");
2432  $cmd_link = $this->getCommandLink("infoScreen")."#notes_top";
2433  $cmd_tag_link = $this->getCommandLink("infoScreen");
2434  $cmd_frame = $this->getCommandFrame("infoScreen");
2435  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
2436 
2437  // reference objects have translated ids, revert to originals
2438  $note_ref_id = $this->ref_id;
2439  if($this->reference_ref_id)
2440  {
2441  $note_ref_id = $this->reference_ref_id;
2442  }
2443 
2444  $js_updater = $a_header_actions
2445  ? "il.Object.redrawActionHeader();"
2446  : "il.Object.redrawListItem(".$note_ref_id.")";
2447 
2448  $comments_enabled = $this->isCommentsActivated($this->type, $this->ref_id, $this->obj_id, $a_header_actions, true);
2449  if($comments_enabled)
2450  {
2451  $this->insertCommand("#", $this->lng->txt("notes_comments"), $cmd_frame,
2452  "", "", ilNoteGUI::getListCommentsJSCall($this->ajax_hash, $js_updater));
2453  }
2454 
2455  if($this->notes_enabled)
2456  {
2457  $this->insertCommand("#", $this->lng->txt("notes"), $cmd_frame,
2458  "", "", ilNoteGUI::getListNotesJSCall($this->ajax_hash, $js_updater));
2459  }
2460 
2461  if ($this->tags_enabled)
2462  {
2463  include_once("./Services/Tagging/classes/class.ilTaggingGUI.php");
2464  //$this->insertCommand($cmd_tag_link, $this->lng->txt("tagging_set_tag"), $cmd_frame);
2465  $this->insertCommand("#", $this->lng->txt("tagging_set_tag"), $cmd_frame,
2466  "", "", ilTaggingGUI::getListTagsJSCall($this->ajax_hash, $js_updater));
2467  }
2468  }
2469 
2476  {
2477  if ($this->std_cmd_only || !$this->container_obj->object)
2478  {
2479  return;
2480  }
2481 
2482  $parent_ref_id = $this->container_obj->object->getRefId();
2483  $parent_type = $this->container_obj->object->getType();
2484 
2485  if($this->checkCommandAccess('write','',$parent_ref_id,$parent_type) ||
2486  $this->checkCommandAccess('write','',$this->ref_id,$this->type))
2487  {
2488  $this->ctrl->setParameterByClass('ilobjectactivationgui','cadh',
2489  $this->ajax_hash);
2490  $this->ctrl->setParameterByClass('ilobjectactivationgui','parent_id',
2491  $parent_ref_id);
2492  $cmd_lnk = $this->ctrl->getLinkTargetByClass(array($this->gui_class_name, 'ilcommonactiondispatchergui', 'ilobjectactivationgui'),
2493  'edit');
2494 
2495  $this->insertCommand($cmd_lnk, $this->lng->txt('activation'));
2496  }
2497  }
2498 
2506  function insertCommands($a_use_asynch = false, $a_get_asynch_commands = false,
2507  $a_asynch_url = "", $a_header_actions = false)
2508  {
2509  global $lng;
2510 
2511  if (!$this->getCommandsStatus())
2512  {
2513  return;
2514  }
2515 
2516  include_once("Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2517  $this->current_selection_list = new ilAdvancedSelectionListGUI();
2518  $this->current_selection_list->setAsynch($a_use_asynch && !$a_get_asynch_commands);
2519  $this->current_selection_list->setAsynchUrl($a_asynch_url);
2520  $this->current_selection_list->setListTitle($lng->txt("actions"));
2521  $this->current_selection_list->setId("act_".$this->getUniqueItemId());
2522  $this->current_selection_list->setSelectionHeaderClass("small");
2523  $this->current_selection_list->setItemLinkClass("xsmall");
2524  $this->current_selection_list->setLinksMode("il_ContainerItemCommand2");
2525  $this->current_selection_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
2526  $this->current_selection_list->setUseImages(false);
2527  $this->current_selection_list->setAdditionalToggleElement($this->getUniqueItemId(true), "ilContainerListItemOuterHighlight");
2528 
2529  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
2530 
2531  $this->ctrl->setParameterByClass($this->gui_class_name, "ref_id", $this->ref_id);
2532 
2533  // only standard command?
2534  $only_default = false;
2535  if ($a_use_asynch && !$a_get_asynch_commands)
2536  {
2537  $only_default = true;
2538  }
2539 
2540  $this->default_command = false;
2541 
2542  // we only allow the following commands inside the header actions
2543  $valid_header_commands = array("mount_webfolder");
2544 
2545  $commands = $this->getCommands($this->ref_id, $this->obj_id);
2546  foreach($commands as $command)
2547  {
2548  if($a_header_actions && !in_array($command["cmd"], $valid_header_commands))
2549  {
2550  continue;
2551  }
2552 
2553  if ($command["granted"] == true )
2554  {
2555  if (!$command["default"] === true)
2556  {
2557  if (!$this->std_cmd_only && !$only_default)
2558  {
2559  // workaround for repository frameset
2560  $command["link"] =
2561  $this->appendRepositoryFrameParameter($command["link"]);
2562 
2563  // standard edit icon
2564  if ($command["lang_var"] == "edit" && $command["img"] == "")
2565  {
2566  $command["img"] = ilUtil::getImagePath("cmd_edit_s.png");
2567  }
2568 
2569  $cmd_link = $command["link"];
2570  $txt = ($command["lang_var"] == "")
2571  ? $command["txt"]
2572  : $this->lng->txt($command["lang_var"]);
2573  $this->insertCommand($cmd_link, $txt,
2574  $command["frame"], $command["img"], $command["cmd"]);
2575  }
2576  }
2577  else
2578  {
2579  $this->default_command = $this->createDefaultCommand($command);
2580  //$this->default_command = $command;
2581  }
2582  }
2583  elseif($command["default"] === true)
2584  {
2585  $items =& $command["access_info"];
2586  foreach ($items as $item)
2587  {
2588  if ($item["type"] == IL_NO_LICENSE)
2589  {
2590  $this->addCustomProperty($this->lng->txt("license"),$item["text"],true);
2591  $this->enableProperties(true);
2592  break;
2593  }
2594  }
2595  }
2596  }
2597 
2598  if (!$only_default)
2599  {
2600  // custom commands
2601  if (is_array($this->cust_commands))
2602  {
2603  foreach ($this->cust_commands as $command)
2604  {
2605  $this->insertCommand($command["link"], $this->lng->txt($command["lang_var"]),
2606  $command["frame"], "", $command["cmd"], $command["onclick"]);
2607  }
2608  }
2609 
2610  // info screen commmand
2611  if ($this->getInfoScreenStatus())
2612  {
2613  $this->insertInfoScreenCommand();
2614  }
2615 
2616  if (!$this->isMode(IL_LIST_AS_TRIGGER))
2617  {
2618  // edit timings
2619  if($this->timings_enabled)
2620  {
2621  $this->insertTimingsCommand();
2622  }
2623 
2624  // delete
2625  if ($this->delete_enabled)
2626  {
2627  $this->insertDeleteCommand();
2628  }
2629 
2630  // link
2631  if ($this->link_enabled)
2632  {
2633  $this->insertLinkCommand();
2634  }
2635 
2636  // cut
2637  if ($this->cut_enabled)
2638  {
2639  $this->insertCutCommand();
2640  }
2641 
2642  // copy
2643  if ($this->copy_enabled)
2644  {
2645  $this->insertCopyCommand();
2646  }
2647 
2648  // cut/copy from workspace to repository
2649  if ($this->repository_transfer_enabled)
2650  {
2651  $this->insertCutCommand(true);
2652  $this->insertCopyCommand(true);
2653  }
2654 
2655  // subscribe
2656  if ($this->subscribe_enabled)
2657  {
2658  $this->insertSubscribeCommand();
2659  }
2660 
2661  // BEGIN PATCH Lucene search
2662  if($this->cut_enabled or $this->link_enabled)
2663  {
2664  $this->insertPasteCommand();
2665  }
2666  // END PATCH Lucene Search
2667 
2668  if(IS_PAYMENT_ENABLED)
2669  {
2670  $this->insertPayment();
2671  }
2672  }
2673  }
2674 
2675  // common social commands (comment, notes, tags)
2676  if (!$only_default && !$this->isMode(IL_LIST_AS_TRIGGER))
2677  {
2678  $this->insertCommonSocialCommands($a_header_actions);
2679  }
2680 
2681  if(!$a_header_actions)
2682  {
2683  $this->ctrl->clearParametersByClass($this->gui_class_name);
2684  }
2685 
2686  if ($a_use_asynch && $a_get_asynch_commands)
2687  {
2688  return $this->current_selection_list->getHTML(true);
2689  }
2690 
2691  return $this->current_selection_list->getHTML();
2692  }
2693 
2699  function enableComments($a_value, $a_enable_comments_settings = true)
2700  {
2701  global $ilSetting;
2702 
2703  // global switch
2704  if($ilSetting->get("disable_comments"))
2705  {
2706  $a_value = false;
2707  }
2708 
2709  $this->comments_enabled = (bool)$a_value;
2710  $this->comments_settings_enabled = (bool)$a_enable_comments_settings;
2711  }
2712 
2718  function enableNotes($a_value)
2719  {
2720  global $ilSetting;
2721 
2722  // global switch
2723  if($ilSetting->get("disable_notes"))
2724  {
2725  $a_value = false;
2726  }
2727 
2728  $this->notes_enabled = (bool)$a_value;
2729  }
2730 
2736  function enableTags($a_value)
2737  {
2738  $tags_set = new ilSetting("tags");
2739  if (!$tags_set->get("enable"))
2740  {
2741  $a_value = false;
2742  }
2743  $this->tags_enabled = (bool)$a_value;
2744  }
2745 
2749  static function prepareJsLinks($a_redraw_url, $a_notes_url, $a_tags_url, $a_tpl = null)
2750  {
2751  global $tpl;
2752 
2753  if (is_null($a_tpl))
2754  {
2755  $a_tpl = $tpl;
2756  }
2757 
2758  if($a_notes_url)
2759  {
2760  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
2761  ilNoteGUI::initJavascript($a_notes_url);
2762  }
2763 
2764  if($a_tags_url)
2765  {
2766  include_once("./Services/Tagging/classes/class.ilTaggingGUI.php");
2767  ilTaggingGUI::initJavascript($a_tags_url);
2768  }
2769 
2770  if($a_redraw_url)
2771  {
2772  $a_tpl->addOnLoadCode("il.Object.setRedrawAHUrl('".
2773  $a_redraw_url."');");
2774  }
2775  }
2776 
2783  function setHeaderSubObject($a_type, $a_id)
2784  {
2785  $this->sub_obj_type = $a_type;
2786  $this->sub_obj_id = (int)$a_id;
2787  }
2788 
2798  function addHeaderIcon($a_id, $a_img, $a_tooltip = null, $a_onclick = null, $a_status_text = null, $a_href = null)
2799  {
2800  $this->header_icons[$a_id] = array("img" => $a_img,
2801  "tooltip" => $a_tooltip,
2802  "onclick" => $a_onclick,
2803  "status_text" => $a_status_text,
2804  "href" => $a_href);
2805  }
2806 
2812  function addHeaderIconHTML($a_id, $a_html)
2813  {
2814  $this->header_icons[$a_id] = $a_html;
2815  }
2816 
2817  function setAjaxHash($a_hash)
2818  {
2819  $this->ajax_hash = $a_hash;
2820  }
2821 
2827  function getHeaderAction()
2828  {
2829  global $ilAccess, $ilBench, $ilUser, $ilCtrl, $lng;
2830 
2831  $htpl = new ilTemplate("tpl.header_action.html", true, true, "Services/Repository");
2832 
2833  $redraw_js = "il.Object.redrawActionHeader();";
2834 
2835  // tags
2836  if($this->tags_enabled)
2837  {
2838  include_once("./Services/Tagging/classes/class.ilTagging.php");
2839  $tags = ilTagging::getTagsForUserAndObject($this->obj_id,
2840  ilObject::_lookupType($this->obj_id), 0, "", $ilUser->getId());
2841  if (count($tags) > 0)
2842  {
2843  include_once("./Services/Tagging/classes/class.ilTaggingGUI.php");
2844  $lng->loadLanguageModule("tagging");
2845  $this->addHeaderIcon("tags",
2846  ilUtil::getImagePath("icon_tags_s.png"),
2847  $lng->txt("tagging_tags").": ".count($tags),
2848  ilTaggingGUI::getListTagsJSCall($this->ajax_hash, $redraw_js),
2849  count($tags));
2850  }
2851  }
2852 
2853  // notes and comments
2854  $comments_enabled = $this->isCommentsActivated($this->type, $this->ref_id, $this->obj_id, true, false);
2855  if($this->notes_enabled || $comments_enabled)
2856  {
2857  include_once("./Services/Notes/classes/class.ilNote.php");
2858  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
2859  $cnt = ilNote::_countNotesAndComments($this->obj_id, $this->sub_obj_id);
2860 
2861  if($this->notes_enabled && $cnt[$this->obj_id][IL_NOTE_PRIVATE] > 0)
2862  {
2863  $this->addHeaderIcon("notes",
2864  ilUtil::getImagePath("note_unlabeled.png"),
2865  $lng->txt("private_notes").": ".$cnt[$this->obj_id][IL_NOTE_PRIVATE],
2866  ilNoteGUI::getListNotesJSCall($this->ajax_hash, $redraw_js),
2867  $cnt[$this->obj_id][IL_NOTE_PRIVATE]
2868  );
2869  }
2870 
2871  if($comments_enabled && $cnt[$this->obj_id][IL_NOTE_PUBLIC] > 0)
2872  {
2873  $lng->loadLanguageModule("notes");
2874 
2875  $this->addHeaderIcon("comments",
2876  ilUtil::getImagePath("comment_unlabeled.png"),
2877  $lng->txt("notes_public_comments").": ".$cnt[$this->obj_id][IL_NOTE_PUBLIC],
2878  ilNoteGUI::getListCommentsJSCall($this->ajax_hash, $redraw_js),
2879  $cnt[$this->obj_id][IL_NOTE_PUBLIC]);
2880  }
2881  }
2882 
2883  if($this->header_icons)
2884  {
2885  include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
2886 
2887  $chunks = array();
2888  foreach($this->header_icons as $id => $attr)
2889  {
2890  $id = "headp_".$id;
2891 
2892  if(is_array($attr))
2893  {
2894  if($attr["onclick"])
2895  {
2896  $htpl->setCurrentBlock("onclick");
2897  $htpl->setVariable("PROP_ONCLICK", $attr["onclick"]);
2898  $htpl->parseCurrentBlock();
2899  }
2900 
2901  if($attr["status_text"])
2902  {
2903  $htpl->setCurrentBlock("status");
2904  $htpl->setVariable("PROP_TXT", $attr["status_text"]);
2905  $htpl->parseCurrentBlock();
2906  }
2907 
2908  if(!$attr["href"])
2909  {
2910  $attr["href"] = "#";
2911  }
2912 
2913  $htpl->setCurrentBlock("prop");
2914  $htpl->setVariable("PROP_ID", $id);
2915  $htpl->setVariable("IMG", ilUtil::img($attr["img"]));
2916  $htpl->setVariable("PROP_HREF", $attr["href"]);
2917  $htpl->parseCurrentBlock();
2918 
2919  if($attr["tooltip"])
2920  {
2921  ilTooltipGUI::addTooltip($id, $attr["tooltip"]);
2922  }
2923  }
2924  else
2925  {
2926  $chunks[] = $attr;
2927  }
2928  }
2929 
2930  if(sizeof($chunks))
2931  {
2932  $htpl->setVariable("PROP_CHUNKS",
2933  implode("&nbsp;&nbsp;&nbsp;", $chunks)."&nbsp;&nbsp;&nbsp;");
2934  }
2935  }
2936 
2937  $htpl->setVariable("ACTION_DROP_DOWN",
2938  $this->insertCommands(false, false, "", true));
2939 
2940  return $htpl->get();
2941  }
2942 
2943 
2949  {
2950  $script = substr(strrchr($_SERVER["PHP_SELF"],"/"),1);
2951 
2952  // we should get rid of this nonsense with 4.4 (alex)
2953  if ((strtolower($_GET["baseClass"]) != "ilrepositorygui") &&
2954  is_int(strpos($a_link,"baseClass=ilRepositoryGUI")))
2955  {
2956  if ($this->type != "frm")
2957  {
2958  $a_link =
2959  ilUtil::appendUrlParameterString($a_link, "rep_frame=1");
2960  }
2961  }
2962 
2963  return $a_link;
2964  }
2965 
2969  function modifySAHSlaunch($a_link,$wtarget)
2970  {
2971  if (strstr($a_link, 'ilSAHSPresentationGUI'))
2972  {
2973  include_once 'Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php';
2974  $sahs_obj = new ilObjSAHSLearningModule($this->ref_id);
2975  $om = $sahs_obj->getOpenMode();
2976  $width = $sahs_obj->getWidth();
2977  $height = $sahs_obj->getHeight();
2978  if ($om != 0 && !ilBrowser::isMobile())
2979  {
2980  $this->default_command["frame"]="";
2981  $a_link = "javascript:void(0); onclick=startSAHS('".$a_link."','".$wtarget."',".$om.",".$width.",".$height.");";
2982  }
2983  }
2984  return $a_link;
2985  }
2986 
2990  function insertPath()
2991  {
2992  global $tree, $lng;
2993 
2994  if($this->getPathStatus() != false)
2995  {
2996  include_once 'Services/Tree/classes/class.ilPathGUI.php';
2997  $path_gui = new ilPathGUI();
2998  $path_gui->enableTextOnly(!$this->path_linked);
2999  $path_gui->setUseImages(false);
3000 
3001  $this->tpl->setCurrentBlock("path_item");
3002  $this->tpl->setVariable('PATH_ITEM',$path_gui->getPath(ROOT_FOLDER_ID,$this->ref_id));
3003  $this->tpl->parseCurrentBlock();
3004 
3005  $this->tpl->setCurrentBlock("path");
3006  $this->tpl->setVariable("TXT_LOCATION", $lng->txt("locator"));
3007  $this->tpl->parseCurrentBlock();
3008  return true;
3009  }
3010  }
3011 
3018  public function insertProgressInfo()
3019  {
3020  return true;
3021  }
3022 
3023 
3028  {
3029  global $lng, $objDefinition;
3030 
3031  $cnt = 0;
3032  if ($this->getCheckboxStatus())
3033  {
3034  $this->tpl->setCurrentBlock("check");
3035  $this->tpl->setVariable("VAL_ID", $this->getCommandId());
3036  $this->tpl->parseCurrentBlock();
3037  $cnt += 1;
3038  }
3039  elseif($this->getExpandStatus())
3040  {
3041  $this->tpl->setCurrentBlock('expand');
3042 
3043  if($this->isExpanded())
3044  {
3045  $this->ctrl->setParameter($this->container_obj,'expand',-1 * $this->obj_id);
3046  $this->tpl->setVariable('EXP_HREF',$this->ctrl->getLinkTarget($this->container_obj,'',$this->getUniqueItemId(true)));
3047  $this->ctrl->clearParameters($this->container_obj);
3048  #$this->tpl->setVariable('EXP_IMG',ilUtil::getImagePath('browser/minus.png'));
3049  $this->tpl->setVariable('EXP_IMG',ilUtil::getImagePath('tree_exp.png'));
3050  $this->tpl->setVariable('EXP_ALT',$this->lng->txt('collapse'));
3051  }
3052  else
3053  {
3054  $this->ctrl->setParameter($this->container_obj,'expand',$this->obj_id);
3055  $this->tpl->setVariable('EXP_HREF',$this->ctrl->getLinkTarget($this->container_obj,'',$this->getUniqueItemId(true)));
3056  $this->ctrl->clearParameters($this->container_obj);
3057  #$this->tpl->setVariable('EXP_IMG',ilUtil::getImagePath('browser/plus.png'));
3058  $this->tpl->setVariable('EXP_IMG',ilUtil::getImagePath('tree_col.png'));
3059  $this->tpl->setVariable('EXP_ALT',$this->lng->txt('expand'));
3060  }
3061 
3062  $this->tpl->parseCurrentBlock();
3063  $cnt += 1;
3064  }
3065 
3066  if ($this->getIconStatus())
3067  {
3068  if ($cnt == 1)
3069  {
3070  $this->tpl->touchBlock("i_1"); // indent
3071  }
3072 
3073  // icon link
3074  if (!$this->default_command || (!$this->getCommandsStatus() && !$this->restrict_to_goto))
3075  {
3076  }
3077  else
3078  {
3079  $this->tpl->setCurrentBlock("icon_link_s");
3080 
3081  if ($this->default_command["frame"] != "")
3082  {
3083  $this->tpl->setVariable("ICON_TAR", "target='".$this->default_command["frame"]."'");
3084  }
3085 
3086  $this->tpl->setVariable("ICON_HREF",
3087  $this->default_command["link"]);
3088  $this->tpl->parseCurrentBlock();
3089  $this->tpl->touchBlock("icon_link_e");
3090  }
3091 
3092  $this->tpl->setCurrentBlock("icon");
3093  if (!$objDefinition->isPlugin($this->getIconImageType()))
3094  {
3095  $this->tpl->setVariable("ALT_ICON", $lng->txt("icon")." ".$lng->txt("obj_".$this->getIconImageType()));
3096  }
3097  else
3098  {
3099  include_once("Services/Component/classes/class.ilPlugin.php");
3100  $this->tpl->setVariable("ALT_ICON", $lng->txt("icon")." ".
3101  ilPlugin::lookupTxt("rep_robj", $this->getIconImageType(), "obj_".$this->getIconImageType()));
3102  }
3103 
3104  $this->tpl->setVariable("SRC_ICON",
3105  ilObject::_getIcon($this->obj_id, "small", $this->getIconImageType()));
3106  $this->tpl->parseCurrentBlock();
3107  $cnt += 1;
3108  }
3109 
3110  $this->tpl->touchBlock("d_".$cnt); // indent main div
3111  }
3112 
3116  function insertSubItems()
3117  {
3118  foreach ($this->sub_item_html as $sub_html)
3119  {
3120  $this->tpl->setCurrentBlock("subitem");
3121  $this->tpl->setVariable("SUBITEM", $sub_html);
3122  $this->tpl->parseCurrentBlock();
3123  }
3124  }
3125 
3130  {
3131  if ($this->position_enabled)
3132  {
3133  $this->tpl->setCurrentBlock("position");
3134  $this->tpl->setVariable("POS_ID", $this->position_field_index);
3135  $this->tpl->setVariable("POS_VAL", $this->position_value);
3136  $this->tpl->parseCurrentBlock();
3137  }
3138  }
3139 
3145  {
3146  return $this->adm_commands_included;
3147  }
3148 
3152  function storeAccessCache()
3153  {
3154  global $ilUser;
3155  if($this->acache->getLastAccessStatus() == "miss" &&
3156  !$this->prevent_access_caching)
3157  {
3158  $this->acache->storeEntry($ilUser->getId().":".$this->ref_id,
3159  serialize($this->access_cache), $this->ref_id);
3160  }
3161  }
3162 
3177  function getListItemHTML($a_ref_id, $a_obj_id, $a_title, $a_description,
3178  $a_use_asynch = false, $a_get_asynch_commands = false, $a_asynch_url = "", $a_context = self::CONTEXT_REPOSITORY)
3179  {
3180  global $ilAccess, $ilBench, $ilUser, $ilCtrl;
3181 
3182  // this variable stores wheter any admin commands
3183  // are included in the output
3184  $this->adm_commands_included = false;
3185 
3186  // only for permformance exploration
3187  $type = ilObject::_lookupType($a_obj_id);
3188 
3189  // initialization
3190  $ilBench->start("ilObjectListGUI", "1000_getListHTML_init$type");
3191  $this->initItem($a_ref_id, $a_obj_id, $a_title, $a_description, $a_context);
3192  $ilBench->stop("ilObjectListGUI", "1000_getListHTML_init$type");
3193 
3194  // prepare ajax calls
3195  include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
3196  if($a_context == self::CONTEXT_REPOSITORY)
3197  {
3199  }
3200  else
3201  {
3203  }
3204  $this->setAjaxHash(ilCommonActionDispatcherGUI::buildAjaxHash($node_type, $a_ref_id, $type, $a_obj_id));
3205 
3206  if ($a_use_asynch && $a_get_asynch_commands)
3207  {
3208  return $this->insertCommands(true, true);
3209  }
3210 
3211  // read from cache
3212  include_once("Services/Object/classes/class.ilListItemAccessCache.php");
3213  $this->acache = new ilListItemAccessCache();
3214  $cres = $this->acache->getEntry($ilUser->getId().":".$a_ref_id);
3215  if($this->acache->getLastAccessStatus() == "hit")
3216  {
3217  $this->access_cache = unserialize($cres);
3218  }
3219  else
3220  {
3221  // write to cache
3222  $this->storeAccessCache();
3223  }
3224 
3225  // visible check
3226  if (!$this->checkCommandAccess("visible", "", $a_ref_id, "", $a_obj_id))
3227  {
3228  $ilBench->stop("ilObjectListGUI", "2000_getListHTML_check_visible");
3229  return "";
3230  }
3231 
3232  // BEGIN WEBDAV
3233  if($type=='file' AND ilObjFileAccess::_isFileHidden($a_title))
3234  {
3235  return "";
3236  }
3237  // END WEBDAV
3238 
3239 
3240  $this->tpl = new ilTemplate("tpl.container_list_item.html", true, true,
3241  "Services/Container", "DEFAULT", false, true);
3242 
3243  if ($this->getCommandsStatus() ||
3244  ($this->payment_enabled && IS_PAYMENT_ENABLED))
3245  {
3246  if (!$this->getSeparateCommands())
3247  {
3248  $this->tpl->setVariable("COMMAND_SELECTION_LIST",
3249  $this->insertCommands($a_use_asynch, $a_get_asynch_commands, $a_asynch_url));
3250  }
3251  }
3252 
3253  if($this->getProgressInfoStatus())
3254  {
3255  $this->insertProgressInfo();
3256  }
3257 
3258  // insert title and describtion
3259  $this->insertTitle();
3260  if (!$this->isMode(IL_LIST_AS_TRIGGER))
3261  {
3262  if ($this->getDescriptionStatus())
3263  {
3264  $this->insertDescription();
3265  }
3266  }
3267 
3268  if($this->getSearchFragmentStatus())
3269  {
3270  $this->insertSearchFragment();
3271  }
3272  if($this->enabledRelevance())
3273  {
3274  $this->insertRelevance();
3275  }
3276 
3277  // properties
3278  $ilBench->start("ilObjectListGUI", "6000_insert_properties$type");
3279  if ($this->getPropertiesStatus())
3280  {
3281  $this->insertProperties();
3282  }
3283  $ilBench->stop("ilObjectListGUI", "6000_insert_properties$type");
3284 
3285  // notice properties
3286  $ilBench->start("ilObjectListGUI", "6500_insert_notice_properties$type");
3287  if($this->getNoticePropertiesStatus())
3288  {
3289  $this->insertNoticeProperties();
3290  }
3291  $ilBench->stop("ilObjectListGUI", "6500_insert_notice_properties$type");
3292 
3293  // preconditions
3294  $ilBench->start("ilObjectListGUI", "7000_insert_preconditions");
3295  if ($this->getPreconditionsStatus())
3296  {
3297  $this->insertPreconditions();
3298  }
3299  $ilBench->stop("ilObjectListGUI", "7000_insert_preconditions");
3300 
3301  // path
3302  $ilBench->start("ilObjectListGUI", "8000_insert_path");
3303  $this->insertPath();
3304  $ilBench->stop("ilObjectListGUI", "8000_insert_path");
3305 
3306  $ilBench->start("ilObjectListGUI", "8500_item_detail_links");
3307  if($this->getItemDetailLinkStatus())
3308  {
3309  $this->insertItemDetailLinks();
3310  }
3311  $ilBench->stop("ilObjectListGUI", "8500_item_detail_links");
3312 
3313  // icons and checkboxes
3314  $this->insertIconsAndCheckboxes();
3315 
3316  // input field for position
3317  $this->insertPositionField();
3318 
3319  // subitems
3320  $this->insertSubItems();
3321 
3322  // reset properties and commands
3323  $this->cust_prop = array();
3324  $this->cust_commands = array();
3325  $this->sub_item_html = array();
3326  $this->position_enabled = false;
3327 
3328  $this->tpl->setVariable("DIV_CLASS",'ilContainerListItemOuter');
3329  $this->tpl->setVariable("DIV_ID", 'id = "'.$this->getUniqueItemId(true).'"');
3330  $this->tpl->setVariable("ADDITIONAL", $this->getAdditionalInformation());
3331 
3332  return $this->tpl->get();
3333  }
3334 
3341  protected function getUniqueItemId($a_as_div = false)
3342  {
3343  // use correct id for references
3344  $id_ref = ($this->reference_ref_id > 0)
3345  ? $this->reference_ref_id
3346  : $this->ref_id;
3347 
3348  // add unique identifier for preconditions (objects can appear twice in same container)
3349  if($this->condition_depth)
3350  {
3351  $id_ref .= "_pc".$this->condition_depth;
3352  }
3353 
3354  if(!$a_as_div)
3355  {
3356  return $id_ref;
3357  }
3358  else
3359  {
3360  // action menu [yellow] toggle
3361  return "lg_div_".$id_ref;
3362  }
3363  }
3364 
3368  function getCommandsHTML()
3369  {
3370  return $this->insertCommands();
3371  }
3372 
3376  function isSideBlock()
3377  {
3378  return false;
3379  }
3380 
3386  public function setBoldTitle($a_bold_title)
3387  {
3388  $this->bold_title = $a_bold_title;
3389 
3390  }
3391 
3397  public function isTitleBold()
3398  {
3399  return $this->bold_title;
3400  }
3401 
3408  static function preloadCommonProperties($a_obj_ids)
3409  {
3410  global $lng;
3411 
3412  $lng->loadLanguageModule("notes");
3413  $lng->loadLanguageModule("tagging");
3414 
3415  include_once("./Services/Tagging/classes/class.ilTagging.php");
3416  self::$cnt_tags = ilTagging::_countTags($a_obj_ids);
3417 
3418  include_once("./Services/Notes/classes/class.ilNote.php");
3419  self::$cnt_notes = ilNote::_countNotesAndCommentsMultiple($a_obj_ids, true);
3420  self::$comments_activation = ilNote::getRepObjActivation($a_obj_ids);
3421 
3422  self::$preload_done = true;
3423  }
3424 
3435  protected function isCommentsActivated($a_type, $a_ref_id, $a_obj_id, $a_header_actions, $a_check_write_access = true)
3436  {
3437  if($this->comments_enabled)
3438  {
3439  if(!$this->comments_settings_enabled)
3440  {
3441  return true;
3442  }
3443  if($a_check_write_access && $this->checkCommandAccess('write','', $a_ref_id, $a_type))
3444  {
3445  return true;
3446  }
3447  // fallback to single object check if no preloaded data
3448  // only the repository does preloadCommonProperties() yet
3449  if(!$a_header_actions && self::$preload_done)
3450  {
3451  if(self::$comments_activation[$a_obj_id][$a_type])
3452  {
3453  return true;
3454  }
3455  }
3456  else
3457  {
3458  include_once("./Services/Notes/classes/class.ilNote.php");
3459  if(ilNote::commentsActivated($a_obj_id, 0, $a_type))
3460  {
3461  return true;
3462  }
3463  }
3464  }
3465  return false;
3466  }
3467 
3475  public function enableTimings($a_status)
3476  {
3477  $this->timings_enabled = (bool)$a_status;
3478  }
3479 }
3480 
3481 ?>