ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilContainer.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 // note: the values are derived from ilObjCourse constants
25 // to enable easy migration from course view setting to container view setting
26 
27 require_once "./Services/Object/classes/class.ilObject.php";
28 
39 class ilContainer extends ilObject
40 {
44  protected $news;
48  protected $db;
49 
53  protected $log;
54 
58  protected $access;
59 
63  protected $error;
64 
68  protected $rbacsystem;
69 
73  protected $tree;
74 
78  protected $user;
79 
83  protected $obj_definition;
84 
85  protected $order_type = 0;
86  protected $hiddenfilesfound = false;
87  protected $news_timeline = false;
88  protected $news_timeline_auto_entries = false;
89 
90  // container view constants
91  const VIEW_SESSIONS = 0;
92  const VIEW_OBJECTIVE = 1;
93  const VIEW_TIMING = 2;
94  const VIEW_ARCHIVE = 3;
95  const VIEW_SIMPLE = 4;
96  const VIEW_BY_TYPE = 5;
97  const VIEW_INHERIT = 6;
98 
99  const VIEW_DEFAULT = self::VIEW_BY_TYPE;
100 
101 
102  const SORT_TITLE = 0;
103  const SORT_MANUAL = 1;
104  const SORT_ACTIVATION = 2;
105  const SORT_INHERIT = 3;
106  const SORT_CREATION = 4;
107 
110 
113 
117 
118  public static $data_preloaded = false;
119 
123  protected $setting;
124 
128  protected $obj_trans = null;
129 
134 
135  public function __construct($a_id = 0, $a_reference = true)
136  {
137  global $DIC;
138 
139  $this->db = $DIC->database();
140  $this->log = $DIC["ilLog"];
141  $this->access = $DIC->access();
142  $this->error = $DIC["ilErr"];
143  $this->rbacsystem = $DIC->rbac()->system();
144  $this->tree = $DIC->repositoryTree();
145  $this->user = $DIC->user();
146  $this->obj_definition = $DIC["objDefinition"];
147  $this->news = $DIC->news();
148 
149 
150  $this->setting = $DIC["ilSetting"];
151  parent::__construct($a_id, $a_reference);
152  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
153 
154  if ($this->getId() > 0) {
155  $this->obj_trans = ilObjectTranslation::getInstance($this->getId());
156  }
157  $this->recommended_content_manager = new ilRecommendedContentManager();
158  }
159 
164  public function getObjectTranslation()
165  {
166  return $this->obj_trans;
167  }
168 
174  {
175  $this->obj_trans = $obj_trans;
176  }
177 
182  public function createContainerDirectory()
183  {
184  $webspace_dir = ilUtil::getWebspaceDir();
185  $cont_dir = $webspace_dir . "/container_data";
186  if (!is_dir($cont_dir)) {
187  ilUtil::makeDir($cont_dir);
188  }
189  $obj_dir = $cont_dir . "/obj_" . $this->getId();
190  if (!is_dir($obj_dir)) {
191  ilUtil::makeDir($obj_dir);
192  }
193  }
194 
200  public function getContainerDirectory()
201  {
202  return $this->_getContainerDirectory($this->getId());
203  }
204 
210  public static function _getContainerDirectory($a_id)
211  {
212  return ilUtil::getWebspaceDir() . "/container_data/obj_" . $a_id;
213  }
214 
220  public function setHiddenFilesFound($a_hiddenfilesfound)
221  {
222  $this->hiddenfilesfound = $a_hiddenfilesfound;
223  }
224 
230  public function getHiddenFilesFound()
231  {
233  }
234 
238  public function getStyleSheetId()
239  {
240  return $this->style_id;
241  }
242 
246  public function setStyleSheetId($a_style_id)
247  {
248  $this->style_id = $a_style_id;
249  }
250 
256  public function setNewsTimeline($a_val)
257  {
258  $this->news_timeline = $a_val;
259  }
260 
266  public function getNewsTimeline()
267  {
268  return $this->news_timeline;
269  }
270 
276  public function setNewsTimelineAutoEntries($a_val)
277  {
278  $this->news_timeline_auto_entries = $a_val;
279  }
280 
286  public function getNewsTimelineAutoEntries()
287  {
289  }
290 
296  public function setNewsTimelineLandingPage($a_val)
297  {
298  $this->news_timeline_landing_page = $a_val;
299  }
300 
306  public function getNewsTimelineLandingPage()
307  {
308  return $this->news_timeline_landing_page;
309  }
310 
316  public function isNewsTimelineEffective()
317  {
318  if (!$this->news->isGloballyActivated()) {
319  return false;
320  }
321  if ($this->getUseNews()) {
322  if ($this->getNewsTimeline()) {
323  return true;
324  }
325  }
326  return false;
327  }
328 
335  {
336  if ($this->getUseNews()) {
337  if ($this->getNewsTimeline()) {
338  if ($this->getNewsTimelineLandingPage()) {
339  return true;
340  }
341  }
342  }
343  return false;
344  }
345 
346 
352  public function setNewsBlockActivated($a_val)
353  {
354  $this->news_block_activated = $a_val;
355  }
356 
362  public function getNewsBlockActivated()
363  {
364  return $this->news_block_activated;
365  }
366 
372  public function setUseNews($a_val)
373  {
374  $this->use_news = $a_val;
375  }
376 
382  public function getUseNews()
383  {
384  return $this->use_news;
385  }
386 
395  public static function _lookupContainerSetting($a_id, $a_keyword, $a_default_value = null)
396  {
397  global $DIC;
398 
399  $ilDB = $DIC->database();
400 
401  $q = "SELECT * FROM container_settings WHERE " .
402  " id = " . $ilDB->quote($a_id, 'integer') . " AND " .
403  " keyword = " . $ilDB->quote($a_keyword, 'text');
404  $set = $ilDB->query($q);
405  $rec = $set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
406 
407  if (isset($rec['value'])) {
408  return $rec["value"];
409  }
410  if ($a_default_value === null) {
411  return '';
412  }
413  return $a_default_value;
414  }
415 
421  public static function _writeContainerSetting($a_id, $a_keyword, $a_value)
422  {
423  global $DIC;
424 
425  $ilDB = $DIC->database();
426 
427  $query = "DELETE FROM container_settings WHERE " .
428  "id = " . $ilDB->quote($a_id, 'integer') . " " .
429  "AND keyword = " . $ilDB->quote($a_keyword, 'text');
430  $res = $ilDB->manipulate($query);
431 
433  $log->debug("Write container setting, id: " . $a_id . ", keyword: " . $a_keyword . ", value: " . $a_value);
434 
435  $query = "INSERT INTO container_settings (id, keyword, value) VALUES (" .
436  $ilDB->quote($a_id, 'integer') . ", " .
437  $ilDB->quote($a_keyword, 'text') . ", " .
438  $ilDB->quote($a_value, 'text') .
439  ")";
440 
441  $res = $ilDB->manipulate($query);
442  }
443 
444  public static function _getContainerSettings($a_id)
445  {
446  global $DIC;
447 
448  $ilDB = $DIC->database();
449 
450  $res = array();
451 
452  $sql = "SELECT * FROM container_settings WHERE " .
453  " id = " . $ilDB->quote($a_id, 'integer');
454  $set = $ilDB->query($sql);
455  while ($row = $ilDB->fetchAssoc($set)) {
456  $res[$row["keyword"]] = $row["value"];
457  }
458 
459  return $res;
460  }
461 
462  public static function _deleteContainerSettings($a_id, $a_keyword = null, $a_keyword_like = false)
463  {
464  global $DIC;
465 
466  $ilDB = $DIC->database();
467 
468  if (!$a_id) {
469  return;
470  }
471 
472  $sql = "DELETE FROM container_settings WHERE " .
473  " id = " . $ilDB->quote($a_id, 'integer');
474  if ($a_keyword) {
475  if (!$a_keyword_like) {
476  $sql .= " AND keyword = " . $ilDB->quote($a_keyword, "text");
477  } else {
478  $sql .= " AND " . $ilDB->like("keyword", "text", $a_keyword);
479  }
480  }
481  $ilDB->manipulate($sql);
482  }
483 
484  public static function _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
485  {
486  // container settings
487  $settings = self::_getContainerSettings($a_obj_id);
488  if (sizeof($settings)) {
489  $a_xml->xmlStartTag("ContainerSettings");
490 
491  foreach ($settings as $keyword => $value) {
492  // :TODO: proper custom icon export/import
493  if (stristr($keyword, "icon")) {
494  continue;
495  }
496 
497  $a_xml->xmlStartTag(
498  'ContainerSetting',
499  array(
500  'id' => $keyword,
501  )
502  );
503 
504  $a_xml->xmlData($value);
505  $a_xml->xmlEndTag("ContainerSetting");
506  }
507 
508  $a_xml->xmlEndTag("ContainerSettings");
509  }
510  }
511 
520  public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
521  {
523  $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
524 
525  // translations
526  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
527  $ot = ilObjectTranslation::getInstance($this->getId());
528  $ot->copy($new_obj->getId());
529 
530  include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
531  #18624 - copy all sorting settings
532  ilContainerSortingSettings::_cloneSettings($this->getId(), $new_obj->getId());
533 
534  // copy content page
535  include_once("./Services/Container/classes/class.ilContainerPage.php");
537  "cont",
538  $this->getId()
539  )) {
540  $orig_page = new ilContainerPage($this->getId());
541  $orig_page->copy($new_obj->getId(), "cont", $new_obj->getId());
542  }
543 
544  // #20614 - copy style
545  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
546  $style_id = $this->getStyleSheetId();
547  if ($style_id > 0) {
548  if (!ilObjStyleSheet::_lookupStandard($style_id)) {
549  $style_obj = ilObjectFactory::getInstanceByObjId($style_id);
550  $new_id = $style_obj->ilClone();
551  $new_obj->setStyleSheetId($new_id);
552  $new_obj->update();
553  } else {
554  $new_obj->setStyleSheetId($this->getStyleSheetId());
555  $new_obj->update();
556  }
557  }
558 
559  // #10271 - copy start objects page
560  include_once("./Services/Container/classes/class.ilContainerStartObjectsPage.php");
562  "cstr",
563  $this->getId()
564  )) {
565  $orig_page = new ilContainerStartObjectsPage($this->getId());
566  $orig_page->copy($new_obj->getId(), "cstr", $new_obj->getId());
567  }
568 
569  // #10271
570  foreach (self::_getContainerSettings($this->getId()) as $keyword => $value) {
571  self::_writeContainerSetting($new_obj->getId(), $keyword, $value);
572  }
573 
574  $new_obj->setNewsTimeline($this->getNewsTimeline());
575  $new_obj->setNewsBlockActivated($this->getNewsBlockActivated());
576  $new_obj->setUseNews($this->getUseNews());
577  $new_obj->setNewsTimelineAutoEntries($this->getNewsTimelineAutoEntries());
578  $new_obj->setNewsTimelineLandingPage($this->getNewsTimelineLandingPage());
579  ilBlockSetting::cloneSettingsOfBlock("news", $this->getId(), $new_obj->getId());
580  $mom_noti = new ilMembershipNotifications($this->getRefId());
581  $mom_noti->cloneSettings($new_obj->getRefId());
582 
583  return $new_obj;
584  }
585 
594  public function cloneDependencies($a_target_id, $a_copy_id)
595  {
596  $ilLog = $this->log;
597 
598  parent::cloneDependencies($a_target_id, $a_copy_id);
599 
600  include_once('./Services/Container/classes/class.ilContainerSorting.php');
601  ilContainerSorting::_getInstance($this->getId())->cloneSorting($a_target_id, $a_copy_id);
602 
603  // fix internal links to other objects
604  ilContainer::fixInternalLinksAfterCopy($a_target_id, $a_copy_id, $this->getRefId());
605 
606  // fix item group references in page content
607  include_once("./Modules/ItemGroup/classes/class.ilObjItemGroup.php");
609 
610  include_once('Services/Object/classes/class.ilObjectLP.php');
611  $olp = ilObjectLP::getInstance($this->getId());
612  $collection = $olp->getCollectionInstance();
613  if ($collection) {
614  $collection->cloneCollection($a_target_id, $a_copy_id);
615  }
616 
617  return true;
618  }
619 
634  public function cloneAllObject($session_id, $client_id, $new_type, $ref_id, $clone_source, $options, $soap_call = false, $a_submode = 1)
635  {
636  $ilLog = $this->log;
637 
638  include_once('./Services/Link/classes/class.ilLink.php');
639  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
640 
641  $ilAccess = $this->access;
644  $tree = $this->tree;
646 
647  // Save wizard options
649  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
650  $wizard_options->saveOwner($ilUser->getId());
651  $wizard_options->saveRoot($clone_source);
652 
653  // add entry for source container
654  $wizard_options->initContainer($clone_source, $ref_id);
655 
656  foreach ($options as $source_id => $option) {
657  $wizard_options->addEntry($source_id, $option);
658  }
659  $wizard_options->read();
660  $wizard_options->storeTree($clone_source);
661 
662  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
663  if ($a_submode == ilObjectCopyGUI::SUBMODE_CONTENT_ONLY) {
664  ilLoggerFactory::getLogger('obj')->info('Copy content only...');
665  ilLoggerFactory::getLogger('obj')->debug('Added mapping, source ID: ' . $clone_source . ', target ID: ' . $ref_id);
666  $wizard_options->read();
667  $wizard_options->dropFirstNode();
668  $wizard_options->appendMapping($clone_source, $ref_id);
669  }
670 
671 
672  #print_r($options);
673  // Duplicate session to avoid logout problems with backgrounded SOAP calls
674  $new_session_id = ilSession::_duplicate($session_id);
675  // Start cloning process using soap call
676  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
677 
678  $soap_client = new ilSoapClient();
679  $soap_client->setResponseTimeout($soap_client->getResponseTimeout());
680  $soap_client->enableWSDL(true);
681 
682  $ilLog->write(__METHOD__ . ': Trying to call Soap client...');
683  if ($soap_client->init()) {
684  ilLoggerFactory::getLogger('obj')->info('Calling soap clone method');
685  $res = $soap_client->call('ilClone', array($new_session_id . '::' . $client_id, $copy_id));
686  } else {
687  ilLoggerFactory::getLogger('obj')->warning('SOAP clone call failed. Calling clone method manually');
688  $wizard_options->disableSOAP();
689  $wizard_options->read();
690  include_once('./webservice/soap/include/inc.soap_functions.php');
691  $res = ilSoapFunctions::ilClone($new_session_id . '::' . $client_id, $copy_id);
692  }
693  return array(
694  'copy_id' => $copy_id,
695  'ref_id' => (int) $res
696  );
697  }
698 
704  public function delete()
705  {
706  // always call parent delete function first!!
707  if (!parent::delete()) {
708  return false;
709  }
710  // delete translations
711  $this->obj_trans->delete();
712 
713  return true;
714  }
715 
719  public function getViewMode()
720  {
722  }
723 
727  public function getOrderType()
728  {
729  return $this->order_type ? $this->order_type : ilContainer::SORT_TITLE;
730  }
731 
732  public function setOrderType($a_value)
733  {
734  $this->order_type = $a_value;
735  }
736 
741  public function isClassificationFilterActive() : bool
742  {
743  // apply container classification filters
744  $repo = new ilClassificationSessionRepository($this->getRefId());
745  foreach (ilClassificationProvider::getValidProviders($this->getRefId(), $this->getId(), $this->getType()) as $class_provider) {
746  $id = get_class($class_provider);
747  $current = $repo->getValueForProvider($id);
748  if ($current) {
749  return true;
750  }
751  }
752  return false;
753  }
754 
760  public function filteredSubtree() : bool
761  {
762  if ($this->isClassificationFilterActive() && in_array($this->getType(), ["grp", "crs"])) {
763  return true;
764  }
765  return false;
766  }
767 
773  protected function getInitialSubitems() : array
774  {
775  $tree = $this->tree;
776  if ($this->filteredSubtree()) {
777  $objects = $tree->getSubTree($tree->getNodeData($this->getRefId()));
778  } else {
779  $objects = $tree->getChilds($this->getRefId(), "title");
780  }
781  return $objects;
782  }
783 
792  public function getSubItems(
793  $a_admin_panel_enabled = false,
794  $a_include_side_block = false,
795  $a_get_single = 0,
796  \ilContainerUserFilter $container_user_filter = null
797  ) {
799 
800  // Caching
801  if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) &&
802  !$a_get_single) {
803  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
804  }
805 
806  $objects = $this->getInitialSubitems();
807  $objects = $this->applyContainerUserFilter($objects, $container_user_filter);
808  $objects = self::getCompleteDescriptions($objects);
809 
810  // apply container classification filters
811  $repo = new ilClassificationSessionRepository($this->getRefId());
812  foreach (ilClassificationProvider::getValidProviders($this->getRefId(), $this->getId(), $this->getType()) as $class_provider) {
813  $id = get_class($class_provider);
814  $current = $repo->getValueForProvider($id);
815  if ($current) {
816  $class_provider->setSelection($current);
817  $filtered = $class_provider->getFilteredObjects();
818  $objects = array_filter($objects, function ($i) use ($filtered) {
819  return (is_array($filtered) && in_array($i["obj_id"], $filtered));
820  });
821  //if (count($filtered) > 0) {
822  // var_dump($filtered);
823  // echo "<br><br>";
824  // var_dump($objects);
825  // exit;
826  //}
827  }
828  }
829 
830  $found = false;
831  $all_ref_ids = array();
832 
833  if (!self::$data_preloaded) {
834  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
836  }
837 
838  include_once('Services/Container/classes/class.ilContainerSorting.php');
839  $sort = ilContainerSorting::_getInstance($this->getId());
840 
841  // TODO: check this
842  // get items attached to a session
843  include_once './Modules/Session/classes/class.ilEventItems.php';
844  //$event_items = ilEventItems::_getItemsOfContainer($this->getRefId());
845 
846  $classification_filter_active = $this->isClassificationFilterActive();
847  foreach ($objects as $key => $object) {
848  if ($a_get_single > 0 && $object["child"] != $a_get_single) {
849  continue;
850  }
851 
852  // hide object types in devmode
853  if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm"
854  || $object["type"] == "rolf") {
855  continue;
856  }
857 
858  // remove inactive plugins
859  if ($objDefinition->isInactivePlugin($object["type"])) {
860  continue;
861  }
862 
863  // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
864  if (in_array($object['type'], array('file','fold','cat'))) {
865  include_once 'Modules/File/classes/class.ilObjFileAccess.php';
866  if (ilObjFileAccess::_isFileHidden($object['title'])) {
867  $this->setHiddenFilesFound(true);
868  if (!$a_admin_panel_enabled) {
869  continue;
870  }
871  }
872  }
873  // END WebDAV: Don't display hidden Files, Folders and Categories
874 
875  // including event items!
876  if (!self::$data_preloaded) {
877  $preloader->addItem($object["obj_id"], $object["type"], $object["child"]);
878  }
879 
880  // filter out items that are attached to an event
881  // no, see #34701
882  /*if (in_array($object['ref_id'], $event_items) && !$classification_filter_active) {
883  continue;
884  }*/
885 
886  // filter side block items
887  if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) {
888  continue;
889  }
890 
891  $all_ref_ids[] = $object["child"];
892  }
893 
894  // data preloader
895  if (!self::$data_preloaded) {
896  $preloader->preload();
897  unset($preloader);
898 
899  self::$data_preloaded = true;
900  }
901 
902  foreach ($objects as $key => $object) {
903  // see above, objects were filtered
904  if (!in_array($object["child"], $all_ref_ids)) {
905  continue;
906  }
907 
908  // group object type groups together (e.g. learning resources)
909  $type = $objDefinition->getGroupOfObj($object["type"]);
910  if ($type == "") {
911  $type = $object["type"];
912  }
913 
914  // this will add activation properties
915  $this->addAdditionalSubItemInformation($object);
916 
917  $this->items[$type][$key] = $object;
918 
919  $this->items["_all"][$key] = $object;
920  if ($object["type"] != "sess") {
921  $this->items["_non_sess"][$key] = $object;
922  }
923  }
924  $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]
925  = $sort->sortItems($this->items);
926 
927  return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
928  }
929 
933  public function gotItems()
934  {
935  if (is_array($this->items["_all"]) && count($this->items["_all"]) > 0) {
936  return true;
937  }
938  return false;
939  }
940 
945  public function addAdditionalSubItemInformation(&$object)
946  {
947  }
948 
954  public function getGroupedObjTypes()
955  {
957 
958  if (empty($this->type_grps)) {
959  $this->type_grps = $objDefinition->getGroupedRepositoryObjectTypes($this->getType());
960  }
961  return $this->type_grps;
962  }
963 
967  public function enablePageEditing()
968  {
970 
971  // @todo: this will need a more general approach
972  if ($ilSetting->get("enable_cat_page_edit")) {
973  return true;
974  }
975  }
976 
980  public function create()
981  {
982  global $DIC;
983 
984  $lng = $DIC->language();
985 
986  $ret = parent::create();
987 
988  // set translation object, since we have an object id now
989  $this->obj_trans = ilObjectTranslation::getInstance($this->getId());
990 
991  // add default translation
992  $this->addTranslation(
993  $this->getTitle(),
994  $this->getDescription(),
995  $lng->getDefaultLanguage(),
996  true
997  );
998 
999  if (((int) $this->getStyleSheetId()) > 0) {
1000  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1002  }
1003 
1004  $log = ilLoggerFactory::getLogger("cont");
1005  $log->debug("Create Container, id: " . $this->getId());
1006 
1007  self::_writeContainerSetting($this->getId(), "news_timeline", (int) $this->getNewsTimeline());
1008  self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (int) $this->getNewsTimelineAutoEntries());
1009  self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (int) $this->getNewsTimelineLandingPage());
1010  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
1011  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (int) $this->getNewsBlockActivated());
1012  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (int) $this->getUseNews());
1013 
1014  return $ret;
1015  }
1016 
1020  public function putInTree($a_parent_ref)
1021  {
1022  parent::putInTree($a_parent_ref);
1023 
1024  // copy title, icon actions visibilities
1025  if (self::_lookupContainerSetting(ilObject::_lookupObjId($a_parent_ref), "hide_header_icon_and_title")) {
1026  self::_writeContainerSetting($this->getId(), "hide_header_icon_and_title", true);
1027  }
1028  if (self::_lookupContainerSetting(ilObject::_lookupObjId($a_parent_ref), "hide_top_actions")) {
1029  self::_writeContainerSetting($this->getId(), "hide_top_actions", true);
1030  }
1031  }
1032 
1036  public function update()
1037  {
1038  $ret = parent::update();
1039 
1040  $trans = $this->getObjectTranslation();
1041  $trans->setDefaultTitle($this->getTitle());
1042  $trans->setDefaultDescription($this->getLongDescription());
1043  $trans->save();
1044 
1045  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1047 
1048  $log = ilLoggerFactory::getLogger("cont");
1049  $log->debug("Update Container, id: " . $this->getId());
1050 
1051  self::_writeContainerSetting($this->getId(), "news_timeline", (int) $this->getNewsTimeline());
1052  self::_writeContainerSetting($this->getId(), "news_timeline_incl_auto", (int) $this->getNewsTimelineAutoEntries());
1053  self::_writeContainerSetting($this->getId(), "news_timeline_landing_page", (int) $this->getNewsTimelineLandingPage());
1054  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
1055  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::NEWS_VISIBILITY, (int) $this->getNewsBlockActivated());
1056  self::_writeContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, (int) $this->getUseNews());
1057 
1058  return $ret;
1059  }
1060 
1061 
1069  public function read()
1070  {
1071  parent::read();
1072 
1073  include_once("./Services/Container/classes/class.ilContainerSortingSettings.php");
1075 
1076  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1078 
1079  $this->readContainerSettings();
1080  $this->obj_trans = ilObjectTranslation::getInstance($this->getId());
1081  }
1082 
1089  public function readContainerSettings()
1090  {
1091  $this->setNewsTimeline(self::_lookupContainerSetting($this->getId(), "news_timeline"));
1092  $this->setNewsTimelineAutoEntries(self::_lookupContainerSetting($this->getId(), "news_timeline_incl_auto"));
1093  $this->setNewsTimelineLandingPage(self::_lookupContainerSetting($this->getId(), "news_timeline_landing_page"));
1094  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
1095  $this->setNewsBlockActivated(self::_lookupContainerSetting(
1096  $this->getId(),
1098  $this->setting->get('block_activated_news', true)
1099  ));
1100  $this->setUseNews(
1101  self::_lookupContainerSetting($this->getId(), ilObjectServiceSettingsGUI::USE_NEWS, true)
1102  && $this->news->isGloballyActivated()
1103  );
1104  }
1105 
1106 
1114  public static function getCompleteDescriptions(array $objects)
1115  {
1116  global $DIC;
1117 
1118  $ilSetting = $DIC->settings();
1119  $ilObjDataCache = $DIC["ilObjDataCache"];
1120  // using long descriptions?
1121  $short_desc = $ilSetting->get("rep_shorten_description");
1122  $short_desc_max_length = $ilSetting->get("rep_shorten_description_length");
1123  if (!$short_desc || $short_desc_max_length > 0) {
1124  // using (part of) shortened description
1125  if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::DESC_LENGTH) {
1126  foreach ($objects as $key => $object) {
1127  $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true);
1128  }
1129  }
1130  // using (part of) long description
1131  else {
1132  $obj_ids = array();
1133  foreach ($objects as $key => $object) {
1134  $obj_ids[] = $object["obj_id"];
1135  }
1136  if (sizeof($obj_ids)) {
1138  foreach ($objects as $key => $object) {
1139  // #12166 - keep translation, ignore long description
1140  if ($ilObjDataCache->isTranslatedDescription($object["obj_id"])) {
1141  $long_desc[$object["obj_id"]] = $object["description"];
1142  }
1143  if ($short_desc && $short_desc_max_length) {
1144  $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true);
1145  }
1146  $objects[$key]["description"] = $long_desc[$object["obj_id"]];
1147  }
1148  }
1149  }
1150  }
1151  return $objects;
1152  }
1153 
1160  protected static function fixInternalLinksAfterCopy($a_target_id, $a_copy_id, $a_source_ref_id)
1161  {
1162  global $DIC;
1163 
1165  $obj_definition = $DIC["objDefinition"];
1166 
1167  $obj_id = ilObject::_lookupObjId($a_target_id);
1168  include_once("./Services/Container/classes/class.ilContainerPage.php");
1169 
1170  include_once("./Services/CopyWizard/classes/class.ilCopyWizardOptions.php");
1171  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1172  $mapping = $cwo->getMappings();
1173 
1174  if (ilContainerPage::_exists("cont", $obj_id)) {
1175  $pg = new ilContainerPage($obj_id);
1176  $pg->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1177  $pg->update(true, true);
1178  }
1179 
1180  foreach ($mapping as $old_ref_id => $new_ref_id) {
1181  if (!is_numeric($old_ref_id) || !is_numeric($new_ref_id)) {
1182  continue;
1183  }
1184 
1185  $type = ilObject::_lookupType($new_ref_id, true);
1186  $class = 'il' . $obj_definition->getClassName($type) . 'PageCollector';
1187  $loc = $obj_definition->getLocation($type);
1188  $file = $loc . '/class.' . $class . '.php';
1189 
1190  if (is_file($file)) {
1192  $coll = new $class();
1193  foreach ($coll->getAllPageIds(ilObject::_lookupObjId($new_ref_id)) as $page_id) {
1194  if (ilPageObject::_exists($page_id['parent_type'], $page_id['id'], $page_id['lang'])) {
1196  $page = ilPageObjectFactory::getInstance($page_id['parent_type'], $page_id['id'], 0, $page_id['lang']);
1197  $page->handleRepositoryLinksOnCopy($mapping, $a_source_ref_id);
1198  $page->update(true, true);
1199  }
1200  }
1201  }
1202  }
1203  }
1204 
1208  public function removeTranslations()
1209  {
1210  $this->obj_trans->delete();
1211  }
1212 
1218  public function deleteTranslation($a_lang)
1219  {
1220  $this->obj_trans->removeLanguage($a_lang);
1221  $this->obj_trans->save();
1222  }
1223 
1233  public function addTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
1234  {
1235  if (empty($a_title)) {
1236  $a_title = "NO TITLE";
1237  }
1238 
1239  $this->obj_trans->addLanguage($a_lang, $a_title, $a_desc, $a_lang_default, true);
1240  $this->obj_trans->save();
1241 
1242  return true;
1243  }
1244 
1256  protected function applyContainerUserFilter($objects, ilContainerUserFilter $container_user_filter = null)
1257  {
1258  global $DIC;
1259  $db = $DIC->database();
1260 
1261  if (is_null($container_user_filter)) {
1262  return $objects;
1263  }
1264 
1265  if ($container_user_filter->isEmpty() && !ilContainer::_lookupContainerSetting($this->getId(), "filter_show_empty", false)) {
1266  return [];
1267  }
1268 
1269 
1270  $obj_ids = array_map(function ($i) {
1271  return $i["obj_id"];
1272  }, $objects);
1273  $filter_data = $container_user_filter->getData();
1274  if (is_array($filter_data)) {
1275  foreach ($filter_data as $key => $val) {
1276  if (count($obj_ids) == 0) { // stop if no object ids are left
1277  continue;
1278  }
1279  if (!in_array(substr($key, 0, 4), ["adv_", "std_"])) {
1280  continue;
1281  }
1282  if ($val == "") {
1283  continue;
1284  }
1285  $field_id = substr($key, 4);
1286  $val = ilUtil::stripSlashes($val);
1287  $query_parser = new ilQueryParser($val);
1288  if (substr($key, 0, 4) == "std_") {
1289  // object type
1291  $result = null;
1292  $set = $db->queryF(
1293  "SELECT obj_id FROM object_data " .
1294  " WHERE " . $db->in("obj_id", $obj_ids, false, "integer") .
1295  " AND type = %s",
1296  array("text"),
1297  array($val)
1298  );
1299  $result_obj_ids = [];
1300  while ($rec = $db->fetchAssoc($set)) {
1301  $result_obj_ids[] = $rec["obj_id"];
1302  }
1303  $obj_ids = array_intersect($obj_ids, $result_obj_ids);
1304  } elseif ($field_id == ilContainerFilterField::STD_FIELD_ONLINE) {
1305  if (in_array($val, [1, 2])) {
1306  $online_where = ($val == 1)
1307  ? " (offline <> " . $db->quote(1, "integer") . " OR offline IS NULL) "
1308  : " offline = " . $db->quote(1, "integer") . " ";
1309  $result = null;
1310  $set = $db->queryF(
1311  "SELECT obj_id FROM object_data " .
1312  " WHERE " . $db->in("obj_id", $obj_ids, false, "integer") .
1313  " AND " . $online_where,
1314  [],
1315  []
1316  );
1317  $result_obj_ids = [];
1318  while ($rec = $db->fetchAssoc($set)) {
1319  $result_obj_ids[] = $rec["obj_id"];
1320  }
1321  $obj_ids = array_intersect($obj_ids, $result_obj_ids);
1322  $obj_ids = $this->legacyOnlineFilter($obj_ids, $objects, $val);
1323  }
1324  } elseif ($field_id == ilContainerFilterField::STD_FIELD_TUTORIAL_SUPPORT) {
1325  $result = null;
1326  $set = $db->queryF(
1327  "SELECT DISTINCT(obj_id) FROM obj_members m JOIN usr_data u ON (u.usr_id = m.usr_id) " .
1328  " WHERE " . $db->in("m.obj_id", $obj_ids, false, "integer") .
1329  " AND " . $db->like("u.lastname", "text", $val) .
1330  " AND m.contact = %s",
1331  array("integer"),
1332  array(1)
1333  );
1334  $result_obj_ids = [];
1335  while ($rec = $db->fetchAssoc($set)) {
1336  $result_obj_ids[] = $rec["obj_id"];
1337  }
1338  $obj_ids = array_intersect($obj_ids, $result_obj_ids);
1339  } elseif ($field_id == ilContainerFilterField::STD_FIELD_COPYRIGHT) {
1340  $result = null;
1341  $set = $db->queryF(
1342  "SELECT DISTINCT(rbac_id) FROM il_meta_rights " .
1343  " WHERE " . $db->in("rbac_id", $obj_ids, false, "integer") .
1344  " AND description = %s ",
1345  array("text"),
1346  array('il_copyright_entry__' . IL_INST_ID . '__' . $val)
1347  );
1348  $result_obj_ids = [];
1349  while ($rec = $db->fetchAssoc($set)) {
1350  $result_obj_ids[] = $rec["rbac_id"];
1351  }
1352  $obj_ids = array_intersect($obj_ids, $result_obj_ids);
1353  } else {
1354  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
1355  include_once 'Services/Search/classes/class.ilQueryParser.php';
1356 
1357  #$query_parser->setCombination($this->options['title_ao']);
1358  $query_parser->setCombination(QP_COMBINATION_OR);
1359  $query_parser->parse();
1360  $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser);
1361 
1362  //$meta_search->setFilter($this->filter); // object types ['lm', ...]
1363  switch ($field_id) {
1367  $meta_search->setMode('title_description');
1368  break;
1370  $meta_search->setMode('keyword_all');
1371  break;
1373  $meta_search->setMode('contribute');
1374  break;
1375 
1376  }
1377  //$meta_search->setOptions($this->options);
1378  $result = $meta_search->performSearch();
1379  }
1380  } else { // advanced metadata search
1381  $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
1382 
1383  $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance(
1384  $field->getADTDefinition(),
1385  true,
1386  false
1387  );
1388  $field_form->setElementId("query[" . $key . "]");
1389  $field_form->validate();
1390 
1401  if ($field instanceof ilAdvancedMDFieldDefinitionSelectMulti) {
1402  $field_form->getADT()->setSelections([$val - 1]);
1403  }
1404  if ($field instanceof ilAdvancedMDFieldDefinitionSelect) {
1405  $adt = $field_form->getADT();
1406  if ($adt instanceof ilADTMultiEnumText) {
1407  $field_form->getADT()->setSelections([$val - 1]);
1408  } else {
1409  $field_form->getADT()->setSelection($val - 1);
1410  }
1411  }
1412  if ($field instanceof ilAdvancedMDFieldDefinitionInteger) {
1413  $field_form->getADT()->setNumber((int) $val);
1414  }
1415 
1416  include_once 'Services/Search/classes/class.ilQueryParser.php';
1417  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
1418  $adv_md_search = ilObjectSearchFactory::_getAdvancedMDSearchInstance($query_parser);
1419  //$adv_md_search->setFilter($this->filter); // this could be set to an array of object types
1420  $adv_md_search->setDefinition($field); // e.g. ilAdvancedMDFieldDefinitionSelectMulti
1421  $adv_md_search->setIdFilter(array(0));
1422  $adv_md_search->setSearchElement($field_form); // e.g. ilADTEnumSearchBridgeMulti
1423  $result = $adv_md_search->performSearch();
1424  }
1425 
1426  // intersect results
1427  if ($result instanceof ilSearchResult) {
1428  $result_obj_ids = array_map(
1429  function ($i) {
1430  return $i["obj_id"];
1431  },
1432  $result->getEntries()
1433  );
1434  $obj_ids = array_intersect($obj_ids, $result_obj_ids);
1435  }
1436  }
1437  }
1438  $objects = array_filter($objects, function ($o) use ($obj_ids) {
1439  return in_array($o["obj_id"], $obj_ids);
1440  });
1441 
1442  return $objects;
1443  }
1444 
1455  protected function legacyOnlineFilter($obj_ids, $objects, $val)
1456  {
1457  $legacy_types = ["glo", "wiki", "qpl", "book", "dcl", "prtt"];
1458  foreach ($legacy_types as $type) {
1459  $lobjects = array_filter($objects, function ($o) use ($type) {
1460  return ($o["type"] == $type);
1461  });
1462  $lobj_ids = array_map(function ($i) {
1463  return $i["obj_id"];
1464  }, $lobjects);
1465  switch ($type) {
1466  case "glo":
1467  $status = ilObjGlossaryAccess::_lookupOnlineStatus($lobj_ids);
1468  break;
1469  case "wiki":
1470  $status = ilObjWikiAccess::_lookupOnlineStatus($lobj_ids);
1471  break;
1472  case "book":
1473  $status = ilObjBookingPoolAccess::_lookupOnlineStatus($lobj_ids);
1474  break;
1475  case "qpl":
1476  $status = [];
1477  foreach ($lobj_ids as $lid) {
1478  $status[$lid] = ilObjQuestionPoolAccess::isOnline($lid);
1479  }
1480  break;
1481  case "dcl":
1482  $status = [];
1483  foreach ($lobj_ids as $lid) {
1484  $status[$lid] = ilObjDataCollectionAccess::_lookupOnline($lid);
1485  }
1486  break;
1487  case "prtt":
1489  break;
1490  }
1491  foreach ($status as $obj_id => $online) {
1492  if ($val == 1 && !$online || $val == 2 && $online) {
1493  if (($key = array_search($obj_id, $obj_ids)) !== false) {
1494  unset($obj_ids[$key]);
1495  }
1496  } elseif (!in_array($obj_id, $obj_ids)) {
1497  $obj_ids[] = $obj_id;
1498  }
1499  }
1500  }
1501 
1502  return $obj_ids;
1503  }
1504 } // END class ilContainer
deleteTranslation($a_lang)
Delete translation.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
setNewsTimelineAutoEntries($a_val)
Set news timeline auto entries.
static _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
cloneDependencies($a_target_id, $a_copy_id)
Clone object dependencies (container sorting)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
static _getContainerDirectory($a_id)
Get the container directory.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static getValidProviders($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
Get all valid providers (for parent container)
removeTranslations()
Remove all translations of container.
const IL_INST_ID
Definition: constants.php:38
const SORT_NEW_ITEMS_POSITION_TOP
legacyOnlineFilter($obj_ids, $objects, $val)
Legacy online filter.
addTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
Add translation.
static _lookupOnline($a_id)
Check wether datacollection is online.
$result
setStyleSheetId($a_style_id)
set ID of assigned style sheet object
isNewsTimelineEffective()
Is news timeline effective?
static getLongDescriptions(array $a_obj_ids)
Get long description data.
static _getAdvancedSearchInstance($query_parser)
get reference of ilFulltextAdvancedSearch
Container start objects page object.
static ilClone($sid, $copy_identifier)
static _isFileHidden($a_file_name)
Returns true, if a file with the specified name, is usually hidden from the user. ...
getNewsTimelineLandingPage()
Get news timline is landing page.
const DESC_LENGTH
filteredSubtree()
Note grp/crs currently allow to filter in their whole subtrees Catetories only their direct childs...
XML writer class.
static _lookupOnlineStatus($a_ids)
Check wether learning module is online (legacy version)
setHiddenFilesFound($a_hiddenfilesfound)
Set Found hidden files (set by getSubItems).
setNewsBlockActivated($a_val)
Set news block activated.
getViewMode()
Get container view mode.
static getInstance()
Get singleton.
setUseNews($a_val)
Set use news.
getNewsTimelineAutoEntries()
Get news timeline auto entries.
xmlData($data, $encode=true, $escape=true)
Writes data.
static lookupObjectStyle($a_obj_id)
Lookup object style.
user()
Definition: user.php:4
static _cloneSettings($a_old_id, $a_new_id)
Clone settings.
xmlEndTag($tag)
Writes an endtag.
static _getAdvancedMDSearchInstance($query_parser)
get advanced meta data search instance
$ilErr
Definition: raiseError.php:18
const QP_COMBINATION_OR
$client_id
Definition: webdav.php:17
getOrderType()
Get order type default implementation.
static _lookupStandard($a_id)
Lookup standard flag.
static writeStyleUsage($a_obj_id, $a_style_id)
Write style usage.
Preloader for object list GUIs.
static _lookupOnlineStatus($a_ids)
Check wether booking pool is online (legacy version)
const SORT_NEW_ITEMS_POSITION_BOTTOM
static _getInstance($a_copy_id)
Get instance of copy wizard options.
getContainerDirectory()
Get the container directory.
setNewsTimelineLandingPage($a_val)
Set news timline is landing page.
foreach($_POST as $key=> $value) $res
setObjectTranslation(ilObjectTranslation $obj_trans)
Get object translation.
getId()
get object id public
Container page object.
isNewsTimelineLandingPageEffective()
Is news timeline landing page effective?
static _deleteContainerSettings($a_id, $a_keyword=null, $a_keyword_like=false)
setNewsTimeline($a_val)
Set news timeline.
const SORT_NEW_ITEMS_ORDER_CREATION
getStyleSheetId()
get ID of assigned style sheet object
getNewsTimeline()
Get news timeline.
static _lookupObjId($a_id)
static _getContainerSettings($a_id)
enablePageEditing()
Check whether page editing is allowed for container.
gotItems()
Check whether we got any items.
global $DIC
Definition: goto.php:24
putInTree($a_parent_ref)
getTitle()
get object title public
getDescription()
get object description
getHiddenFilesFound()
Get Found hidden files (set by getSubItems).
static _allocateCopyId()
Allocate a copy for further entries.
Class ilContainer.
$query
cloneAllObject($session_id, $client_id, $new_type, $ref_id, $clone_source, $options, $soap_call=false, $a_submode=1)
clone all objects according to this container
static cloneSettingsOfBlock(string $block_type, int $block_id, int $new_block_id)
Clone block settings.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getObjectTranslation()
Get object translation.
getType()
get object type public
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
const SORT_NEW_ITEMS_ORDER_ACTIVATION
static fixContainerItemGroupRefsAfterCloning($a_source_container, $a_copy_id)
Fix container item group references after a container has been cloned.
static _lookupOnlineStatus($a_ids)
Check wether booking pool is online (legacy version)
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
static _duplicate($a_session_id)
Duplicate session.
readContainerSettings()
Read container settings.
applyContainerUserFilter($objects, ilContainerUserFilter $container_user_filter=null)
Apply container user filter on objects.
addAdditionalSubItemInformation(&$object)
Add additional information to sub item, e.g.
setOrderType($a_value)
global $ilSetting
Definition: privfeed.php:17
__construct(Container $dic, ilPlugin $plugin)
__construct($a_id=0, $a_reference=true)
getUseNews()
Get use news.
static getInstance($a_field_id, $a_type=null, string $language='')
Get definition instance by type.
static getInstance($a_obj_id)
Get instance.
global $ilDB
static _lookupOnlineStatus($a_ids)
Check wether learning module is online (legacy version)
$ret
Definition: parser.php:6
getLongDescription()
get object long description (stored in object_description)
getRefId()
get reference id public
static isOnline($a_obj_id)
returns the objects&#39;s ONline status
static _writeContainerSetting($a_id, $a_keyword, $a_value)
isClassificationFilterActive()
Is classification filter active?
static getLogger($a_component_id)
Get component logger.
static _lookupSortMode($a_obj_id)
lookup sort mode
static _getInstance($a_obj_id)
get instance by obj_id
getSubItems( $a_admin_panel_enabled=false, $a_include_side_block=false, $a_get_single=0, \ilContainerUserFilter $container_user_filter=null)
Get subitems of container.
$ilUser
Definition: imgupload.php:18
createContainerDirectory()
Create directory for the container.
getNewsBlockActivated()
Get news block activated.
getGroupedObjTypes()
Get grouped repository object types.
static getInstance($a_obj_id)
const SORT_NEW_ITEMS_ORDER_TITLE
Membership notification settings.
static getWebspaceDir($mode="filesystem")
get webspace directory
static getCompleteDescriptions(array $objects)
overwrites description fields to long or short description in an assoc array keys needed (obj_id and ...
Recommended content manager (business logic)
getInitialSubitems()
Get initial subitems.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
$i
Definition: metadata.php:24
Class handles translation mode for an object.