/** * Custom callback after object is created (in parent containert * * @param ilObject $a_obj */ public function afterSaveCallback(ilObject $a_obj) { // add new object to materials include_once './Modules/Session/classes/class.ilEventItems.php'; $event_items = new ilEventItems($this->object->getId()); $event_items->addItem($a_obj->getRefId()); $event_items->update(); /* ilUtil::sendSuccess($this->lng->txt("object_added"), true); $this->ctrl->redirect($this, "materials"); */ }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { switch ($a_entity) { case "sess": include_once "./Modules/Session/classes/class.ilObjSession.php"; include_once "./Modules/Session/classes/class.ilSessionAppointment.php"; if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) { $newObj = ilObjectFactory::getInstanceByObjId($new_id, false); } else { $newObj = new ilObjSession(); $newObj->setType("sess"); $newObj->create(true); } $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->setLocation($a_rec["Location"]); $newObj->setName($a_rec["TutorName"]); $newObj->setPhone($a_rec["TutorPhone"]); $newObj->setEmail($a_rec["TutorEmail"]); $newObj->setDetails($a_rec["Details"]); $newObj->update(); $start = new ilDateTime($a_rec["EventStart"], IL_CAL_DATETIME, "UTC"); $end = new ilDateTime($a_rec["EventEnd"], IL_CAL_DATETIME, "UTC"); //echo "<br>".$start->get(IL_CAL_UNIX); //echo "<br>".$start->get(IL_CAL_DATETIME); $app = new ilSessionAppointment(); $app->setStart($a_rec["EventStart"]); $app->setEnd($a_rec["EventEnd"]); $app->setStartingTime($start->get(IL_CAL_UNIX)); $app->setEndingTime($end->get(IL_CAL_UNIX)); $app->toggleFullTime($a_rec["Fulltime"]); $app->setSessionId($newObj->getId()); $app->create(); //$newObj->setAppointments(array($app)); //$newObj->update(); $this->current_obj = $newObj; $a_mapping->addMapping("Modules/Session", "sess", $a_rec["Id"], $newObj->getId()); //var_dump($a_mapping->mappings["Services/News"]["news_context"]); break; case "sess_item": if ($obj_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['ItemId'])) { $ref_id = current(ilObject::_getAllReferences($obj_id)); include_once './Modules/Session/classes/class.ilEventItems.php'; $evi = new ilEventItems($this->current_obj->getId()); $evi->addItem($ref_id); $evi->update(); } break; } }
/** * Redraw a list item (ajax) * * @param * @return */ function redrawListItemObject() { global $tpl; $html = null; $item_data = $this->object->getSubItems(false, false, (int) $_GET["child_ref_id"]); $container_view = $this->getContentGUI(); // list item is session material (not part of "_all"-items - see below) include_once './Modules/Session/classes/class.ilEventItems.php'; $event_items = ilEventItems::_getItemsOfContainer($this->object->getRefId()); if (in_array((int) $_GET["child_ref_id"], $event_items)) { include_once './Services/Object/classes/class.ilObjectActivation.php'; foreach ($this->object->items["sess"] as $id) { $items = ilObjectActivation::getItemsByEvent($id['obj_id']); foreach ($items as $event_item) { if ($event_item["child"] == (int) $_GET["child_ref_id"]) { // sessions if ((int) $_GET["parent_ref_id"]) { $event_item["parent"] = (int) $_GET["parent_ref_id"]; } $html = $container_view->renderItem($event_item); } } } } // "normal" list item if (!$html) { foreach ($this->object->items["_all"] as $id) { if ($id["child"] == (int) $_GET["child_ref_id"]) { $html = $container_view->renderItem($id); } } } if ($html) { echo $html; // we need to add onload code manually (rating, comments, etc.) echo $tpl->getOnLoadCodeForAsynch(); } exit; }
/** * Get (sub) item data for timings view (no session material, no side blocks) * * @param int $a_container_ref_id * @return array */ public static function getTimingsItems($a_container_ref_id) { global $objDefinition; $filtered = array(); include_once 'Modules/Session/classes/class.ilEventItems.php'; $event_items = ilEventItems::_getItemsOfContainer($a_container_ref_id); foreach (self::getTimingsAdministrationItems($a_container_ref_id) as $item) { if (!in_array($item['ref_id'], $event_items) && !$objDefinition->isSideBlock($item['type'])) { $filtered[] = $item; } } return $filtered; }
function isVisible($a_ref_id, $a_type) { global $ilAccess, $tree, $ilSetting; if (!$ilAccess->checkAccess('visible', '', $a_ref_id)) { return false; } $is_course = false; $container_parent_id = $tree->checkForParentType($a_ref_id, 'grp'); if (!$container_parent_id) { $is_course = true; $container_parent_id = $tree->checkForParentType($a_ref_id, 'crs'); } if ($container_parent_id) { // do not display session materials for container course/group if ($ilSetting->get("repository_tree_pres") == "all_types" && $container_parent_id != $a_ref_id) { // get container event items only once if (!isset($this->session_materials[$container_parent_id])) { include_once './Modules/Session/classes/class.ilEventItems.php'; $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id); } // get item group items only once if (!isset($this->item_group_items[$container_parent_id])) { include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php'; $this->item_group_items[$container_parent_id] = ilItemGroupItems::_getItemsOfContainer($container_parent_id); } if (in_array($a_ref_id, $this->session_materials[$container_parent_id])) { return false; } if (in_array($a_ref_id, $this->item_group_items[$container_parent_id])) { return false; } } } return true; }
/** * delete session and all related data * * @access public * @return bool */ public function delete() { global $ilDB; global $ilAppEventHandler; if (!parent::delete()) { return false; } $query = "DELETE FROM event " . "WHERE obj_id = " . $this->db->quote($this->getId(), 'integer') . " "; $res = $ilDB->manipulate($query); include_once './Modules/Session/classes/class.ilSessionAppointment.php'; ilSessionAppointment::_deleteBySession($this->getId()); include_once './Modules/Session/classes/class.ilEventItems.php'; ilEventItems::_delete($this->getId()); include_once './Modules/Session/classes/class.ilEventParticipants.php'; ilEventParticipants::_deleteByEvent($this->getId()); foreach ($this->getFiles() as $file) { $file->delete(); } $ilAppEventHandler->raise('Modules/Session', 'delete', array('object' => $this, 'obj_id' => $this->getId(), 'appointments' => $this->prepareCalendarAppointments('delete'))); return true; }
/** * Get subitems of container * * @param bool administration panel enabled * @param bool side blocks enabled * * @return array */ function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0) { global $objDefinition, $ilBench, $tree, $ilObjDataCache, $ilUser, $rbacsystem, $ilSetting; // Caching if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) && !$a_get_single) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } $type_grps = $this->getGroupedObjTypes(); $objects = $tree->getChilds($this->getRefId(), "title"); // using long descriptions? $short_desc = $ilSetting->get("rep_shorten_description"); $short_desc_max_length = $ilSetting->get("rep_shorten_description_length"); if (!$short_desc || $short_desc_max_length != ilObject::TITLE_LENGTH) { // using (part of) shortened description if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::TITLE_LENGTH) { foreach ($objects as $key => $object) { $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true); } } else { $obj_ids = array(); foreach ($objects as $key => $object) { $obj_ids[] = $object["obj_id"]; } if (sizeof($obj_ids)) { $long_desc = ilObject::getLongDescriptions($obj_ids); foreach ($objects as $key => $object) { // #12166 - keep translation, ignore long description if ($ilObjDataCache->isTranslatedDescription($object["obj_id"])) { $long_desc[$object["obj_id"]] = $object["description"]; } if ($short_desc && $short_desc_max_length) { $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true); } $objects[$key]["description"] = $long_desc[$object["obj_id"]]; } } } } $found = false; $all_ref_ids = array(); if (!self::$data_preloaded) { include_once "./Services/Object/classes/class.ilObjectListGUIPreloader.php"; $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_REPOSITORY); } include_once 'Services/Container/classes/class.ilContainerSorting.php'; $sort = ilContainerSorting::_getInstance($this->getId()); // TODO: check this // get items attached to a session include_once './Modules/Session/classes/class.ilEventItems.php'; $event_items = ilEventItems::_getItemsOfContainer($this->getRefId()); foreach ($objects as $key => $object) { if ($a_get_single > 0 && $object["child"] != $a_get_single) { continue; } // hide object types in devmode if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm" || $object["type"] == "rolf") { continue; } // remove inactive plugins if ($objDefinition->isInactivePlugin($object["type"])) { continue; } // BEGIN WebDAV: Don't display hidden Files, Folders and Categories if (in_array($object['type'], array('file', 'fold', 'cat'))) { include_once 'Modules/File/classes/class.ilObjFileAccess.php'; if (ilObjFileAccess::_isFileHidden($object['title'])) { $this->setHiddenFilesFound(true); if (!$a_admin_panel_enabled) { continue; } } } // END WebDAV: Don't display hidden Files, Folders and Categories // including event items! if (!self::$data_preloaded) { $preloader->addItem($object["obj_id"], $object["type"], $object["child"]); } // filter out items that are attached to an event if (in_array($object['ref_id'], $event_items)) { continue; } // filter side block items if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) { continue; } $all_ref_ids[] = $object["child"]; } // data preloader if (!self::$data_preloaded) { $preloader->preload(); unset($preloader); self::$data_preloaded = true; } foreach ($objects as $key => $object) { // see above, objects were filtered if (!in_array($object["child"], $all_ref_ids)) { continue; } // group object type groups together (e.g. learning resources) $type = $objDefinition->getGroupOfObj($object["type"]); if ($type == "") { $type = $object["type"]; } // this will add activation properties $this->addAdditionalSubItemInformation($object); $this->items[$type][$key] = $object; $this->items["_all"][$key] = $object; if ($object["type"] != "sess") { $this->items["_non_sess"][$key] = $object; } } $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items); return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; }
/** * Get subitems of container * * @param bool administration panel enabled * @param bool side blocks enabled * * @return array */ function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0) { global $objDefinition, $ilBench, $tree, $ilObjDataCache, $ilUser, $rbacsystem, $ilSetting; // Caching if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) && !$a_get_single) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } $type_grps = $this->getGroupedObjTypes(); $objects = $tree->getChilds($this->getRefId(), "title"); // using long descriptions? $short_desc = $ilSetting->get("rep_shorten_description"); $short_desc_max_length = $ilSetting->get("rep_shorten_description_length"); if (!$short_desc || $short_desc_max_length != ilObject::TITLE_LENGTH) { // using (part of) shortened description if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::TITLE_LENGTH) { foreach ($objects as $key => $object) { $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true); } } else { $obj_ids = array(); foreach ($objects as $key => $object) { $obj_ids[] = $object["obj_id"]; } if (sizeof($obj_ids)) { $long_desc = ilObject::getLongDescriptions($obj_ids); foreach ($objects as $key => $object) { if ($short_desc && $short_desc_max_length) { $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true); } $objects[$key]["description"] = $long_desc[$object["obj_id"]]; } } } } $found = false; $all_obj_types = array(); $all_ref_ids = array(); $all_obj_ids = array(); include_once 'Services/Container/classes/class.ilContainerSorting.php'; $sort = ilContainerSorting::_getInstance($this->getId()); // TODO: check this // get items attached to a session include_once './Modules/Session/classes/class.ilEventItems.php'; $event_items = ilEventItems::_getItemsOfContainer($this->getRefId()); foreach ($objects as $key => $object) { if ($a_get_single > 0 && $object["child"] != $a_get_single) { continue; } // hide object types in devmode if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm" || $object["type"] == "rolf") { continue; } // remove inactive plugins if ($objDefinition->isInactivePlugin($object["type"])) { continue; } // BEGIN WebDAV: Don't display hidden Files, Folders and Categories if (in_array($object['type'], array('file', 'fold', 'cat'))) { include_once 'Modules/File/classes/class.ilObjFileAccess.php'; if (ilObjFileAccess::_isFileHidden($object['title'])) { $this->setHiddenFilesFound(true); if (!$a_admin_panel_enabled) { continue; } } } // END WebDAV: Don't display hidden Files, Folders and Categories // filter out items that are attached to an event if (in_array($object['ref_id'], $event_items)) { continue; } // filter side block items if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) { continue; } $all_obj_types[$object["type"]] = $object["type"]; $obj_ids_of_type[$object["type"]][] = $object["obj_id"]; $ref_ids_of_type[$object["type"]][] = $object["child"]; $all_ref_ids[] = $object["child"]; $all_obj_ids[] = $object["obj_id"]; } // data preloader if (!self::$data_preloaded && sizeof($all_ref_ids)) { // type specific preloads foreach ($all_obj_types as $t) { // condition handler: preload conditions include_once "./Services/AccessControl/classes/class.ilConditionHandler.php"; ilConditionHandler::preloadConditionsForTargetRecords($t, $obj_ids_of_type[$t]); $class = $objDefinition->getClassName($t); $location = $objDefinition->getLocation($t); $full_class = "ilObj" . $class . "Access"; include_once $location . "/class." . $full_class . ".php"; call_user_func(array($full_class, "_preloadData"), $obj_ids_of_type[$t], $ref_ids_of_type[$t]); } // general preloads $tree->preloadDeleted($all_ref_ids); $tree->preloadDepthParent($all_ref_ids); $ilObjDataCache->preloadReferenceCache($all_ref_ids, false); ilObjUser::preloadIsDesktopItem($ilUser->getId(), $all_ref_ids); $rbacsystem->preloadRbacPaCache($all_ref_ids, $ilUser->getId()); include_once "./Services/Object/classes/class.ilObjectListGUI.php"; ilObjectListGUI::preloadCommonProperties($all_obj_ids); include_once "./Services/Object/classes/class.ilObjectActivation.php"; ilObjectActivation::preloadData($all_ref_ids); self::$data_preloaded = true; } foreach ($objects as $key => $object) { // see above, objects were filtered if (!in_array($object["child"], $all_ref_ids)) { continue; } // group object type groups together (e.g. learning resources) $type = $objDefinition->getGroupOfObj($object["type"]); if ($type == "") { $type = $object["type"]; } // this will add activation properties (ilObjActivation) $this->addAdditionalSubItemInformation($object); $this->items[$type][$key] = $object; $this->items["_all"][$key] = $object; if ($object["type"] != "sess") { $this->items["_non_sess"][$key] = $object; } } $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items); return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; }
/** * Clone items * * @access public * * @param int source event id * @param int copy id */ public function cloneItems($a_source_id, $a_copy_id) { global $ilObjDataCache, $ilLog; $ilLog->write(__METHOD__ . ': Begin cloning session materials ...'); include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php'; $cwo = ilCopyWizardOptions::_getInstance($a_copy_id); $mappings = $cwo->getMappings(); $new_items = array(); foreach (ilEventItems::_getItemsOfEvent($a_source_id) as $item_id) { if (isset($mappings[$item_id]) and $mappings[$item_id]) { $ilLog->write(__METHOD__ . ': Clone session material nr. ' . $item_id); $new_items[] = $mappings[$item_id]; } else { $ilLog->write(__METHOD__ . ': No mapping found for session material nr. ' . $item_id); } } $this->setItems($new_items); $this->update(); $ilLog->write(__METHOD__ . ': Finished cloning session materials ...'); return true; }