/**
  * Constructor
  * @access	public
  * @param	string	$a_target scriptname
  * @param	string	$a_session_variable session_variable
  */
 public function __construct($a_type, $a_target, $a_session_variable)
 {
     global $tree, $ilCtrl;
     $this->setId("cont_paste_explorer");
     $this->ctrl = $ilCtrl;
     $this->type = $a_type;
     parent::__construct($a_target);
     $this->tree = $tree;
     $this->root_id = $this->tree->readRootId();
     $this->order_column = 'title';
     $this->setSessionExpandVariable($a_session_variable);
     // reset filter
     $this->filter = array();
     $this->addFilter('root');
     $this->addFilter('crs');
     $this->addFilter('grp');
     $this->addFilter('cat');
     $this->addFilter('fold');
     $this->addFormItemForType('root');
     $this->addFormItemForType('crs');
     $this->addFormItemForType('grp');
     $this->addFormItemForType('cat');
     $this->addFormItemForType('fold');
     $this->setFiltered(true);
     $this->setFilterMode(IL_FM_POSITIVE);
 }
 /**
  * Constructor
  * @access	public
  * @param	string	scriptname
  * @param    int user_id
  */
 function ilConditionSelector($a_target)
 {
     global $tree, $ilCtrl;
     $this->ctrl = $ilCtrl;
     parent::ilExplorer($a_target);
     $this->tree = $tree;
     $this->root_id = $this->tree->readRootId();
     $this->order_column = "title";
     $this->setSessionExpandVariable("condition_selector_expand");
     // add here all container objects
     $this->addFilter("root");
     $this->addFilter("cat");
     $this->addFilter("grp");
     $this->addFilter("fold");
     $this->addFilter("crs");
     $this->addFilter("exc");
     $this->addFilter("tst");
     $this->setFilterMode(IL_FM_POSITIVE);
     $this->setFiltered(true);
     $this->setTitleLength(ilObject::TITLE_LENGTH);
 }
 function showStartObjects()
 {
     include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
     include_once './Services/Repository/classes/class.ilRepositoryExplorer.php';
     include_once './Services/Link/classes/class.ilLink.php';
     global $rbacsystem, $ilias, $ilUser, $ilAccess, $ilObjDataCache;
     $this->tabs_gui->setSubTabActive('crs_content');
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_start_view.html", 'Modules/Course');
     $this->tpl->setVariable("INFO_STRING", $this->lng->txt('crs_info_start'));
     $this->tpl->setVariable("TBL_TITLE_START", $this->lng->txt('crs_table_start_objects'));
     $this->tpl->setVariable("HEADER_NR", $this->lng->txt('crs_nr'));
     $this->tpl->setVariable("HEADER_DESC", $this->lng->txt('description'));
     $this->tpl->setVariable("HEADER_EDITED", $this->lng->txt('crs_objective_accomplished'));
     $lm_continue =& new ilCourseLMHistory($this->course_obj->getRefId(), $ilUser->getId());
     $continue_data = $lm_continue->getLMHistory();
     $counter = 0;
     foreach ($this->start_obj->getStartObjects() as $start) {
         $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']);
         $ref_id = $start['item_ref_id'];
         $type = $ilObjDataCache->lookupType($obj_id);
         $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($ref_id, $obj_id);
         $obj_link = ilLink::_getLink($ref_id, $type);
         $obj_frame = ilRepositoryExplorer::buildFrameTarget($type, $ref_id, $obj_id);
         $obj_frame = $obj_frame ? $obj_frame : '';
         // Tmp fix for tests
         $obj_frame = $type == 'tst' ? '' : $obj_frame;
         $contentObj = false;
         if ($ilAccess->checkAccess('read', '', $ref_id)) {
             $this->tpl->setCurrentBlock("start_read");
             $this->tpl->setVariable("READ_TITLE_START", $ilObjDataCache->lookupTitle($obj_id));
             $this->tpl->setVariable("READ_TARGET_START", $obj_frame);
             $this->tpl->setVariable("READ_LINK_START", $obj_link . '&crs_show_result=' . $this->course_obj->getRefId());
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("start_visible");
             $this->tpl->setVariable("VISIBLE_LINK_START", $ilObjDataCache->lookupTitle($obj_id));
             $this->tpl->parseCurrentBlock();
         }
         // CONTINUE LINK
         if (isset($continue_data[$ref_id])) {
             $this->tpl->setCurrentBlock("link");
             $this->tpl->setVariable("LINK_HREF", ilLink::_getLink($ref_id, '', array('obj_id', $continue_data[$ref_id]['lm_page_id'])));
             #$this->tpl->setVariable("CONTINUE_LINK_TARGET",$target);
             $this->tpl->setVariable("LINK_NAME", $this->lng->txt('continue_work'));
             $this->tpl->parseCurrentBlock();
         }
         // add to desktop link
         if (!$ilUser->isDesktopItem($ref_id, $type) and $this->course_obj->getAboStatus()) {
             if ($ilAccess->checkAccess('read', '', $ref_id)) {
                 $this->tpl->setCurrentBlock("link");
                 $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_ref_id', $ref_id);
                 $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_id', $ref_id);
                 $this->ctrl->setParameterByClass(get_class($this->container_gui), 'type', $type);
                 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTarget($this->container_gui, 'addToDesk'));
                 $this->tpl->setVariable("LINK_NAME", $this->lng->txt("to_desktop"));
                 $this->tpl->parseCurrentBlock();
             }
         } elseif ($this->course_obj->getAboStatus()) {
             $this->tpl->setCurrentBlock("link");
             $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_ref_id', $ref_id);
             $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_id', $ref_id);
             $this->ctrl->setParameterByClass(get_class($this->container_gui), 'type', $type);
             $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTarget($this->container_gui, 'removeFromDesk'));
             $this->tpl->setVariable("LINK_NAME", $this->lng->txt("unsubscribe"));
             $this->tpl->parseCurrentBlock();
         }
         // Description
         if (strlen($ilObjDataCache->lookupDescription($obj_id))) {
             $this->tpl->setCurrentBlock("start_description");
             $this->tpl->setVariable("DESCRIPTION_START", $ilObjDataCache->lookupDescription($obj_id));
             $this->tpl->parseCurrentBlock();
         }
         if ($this->start_obj->isFullfilled($ilUser->getId(), $ref_id)) {
             $accomplished = 'accomplished';
         } else {
             $accomplished = 'not_accomplished';
         }
         $this->tpl->setCurrentBlock("start_row");
         $this->tpl->setVariable("EDITED_IMG", ilUtil::getImagePath('crs_' . $accomplished . '.png'));
         $this->tpl->setVariable("EDITED_ALT", $this->lng->txt('crs_objective_' . $accomplished));
         $this->tpl->setVariable("ROW_CLASS", 'option_value');
         $this->tpl->setVariable("ROW_CLASS_CENTER", 'option_value_center');
         $this->tpl->setVariable("OBJ_NR_START", ++$counter . '.');
         $this->tpl->parseCurrentBlock();
     }
     return true;
 }
 function __showOtherResources()
 {
     global $ilias, $rbacsystem, $ilObjDataCache, $objDefinition;
     if (!count($ors = $this->__getOtherResources())) {
         return false;
     }
     $this->tpl->addBlockfile('RESOURCES_BLOCK', 'resources_block', 'tpl.crs_objectives_view_or_table.html', 'Modules/Course');
     $this->tpl->setVariable("TBL_TITLE_OR", $this->lng->txt('crs_other_resources'));
     $this->__showHideLinks('or');
     if (isset($_SESSION['crs_hide_or'])) {
         return true;
     }
     $this->tpl->setCurrentBlock("tbl_header_columns_or");
     $this->tpl->setVariable("TBL_HEADER_WIDTH_OR", "5%");
     $this->tpl->setVariable("TBL_HEADER_NAME_OR", $this->lng->txt('type'));
     $this->tpl->parseCurrentBlock();
     $this->tpl->setCurrentBlock("tbl_header_columns_or");
     $this->tpl->setVariable("TBL_HEADER_WIDTH_OR", "75%");
     $this->tpl->setVariable("TBL_HEADER_NAME_OR", $this->lng->txt('description'));
     $this->tpl->parseCurrentBlock();
     $this->tpl->setCurrentBlock("tbl_header_columns_or");
     $this->tpl->setVariable("TBL_HEADER_WIDTH_OR", "20%");
     $this->tpl->setVariable("TBL_HEADER_NAME_OR", '');
     $this->tpl->parseCurrentBlock();
     $counter = 1;
     foreach ($ors as $or_id) {
         $obj_id = $ilObjDataCache->lookupObjId($or_id);
         $obj_type = $ilObjDataCache->lookupType($obj_id);
         // do not show side block items
         if ($objDefinition->isSideBlock($obj_type)) {
             continue;
         }
         $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($or_id, $obj_id);
         $obj_link = ilRepositoryExplorer::buildLinkTarget($or_id, $obj_type);
         $obj_frame = ilRepositoryExplorer::buildFrameTarget($obj_type, $or_id, $obj_id);
         $obj_frame = $obj_frame ? $obj_frame : '';
         if (ilRepositoryExplorer::isClickable($obj_type, $or_id, $obj_id)) {
             $this->tpl->setCurrentBlock("or_read");
             $this->tpl->setVariable("READ_TITLE_OR", $ilObjDataCache->lookupTitle($obj_id));
             $this->tpl->setVariable("READ_TARGET_OR", $obj_frame);
             $this->tpl->setVariable("READ_LINK_OR", $obj_link);
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("or_visible");
             $this->tpl->setVariable("VISIBLE_LINK_OR", $ilObjDataCache->lookupTitle($obj_id));
             $this->tpl->parseCurrentBlock();
         }
         // add to desktop link
         if (!$ilias->account->isDesktopItem($or_id, $obj_type) and $this->course_obj->getAboStatus() == $this->course_obj->ABO_ENABLED) {
             if ($rbacsystem->checkAccess('read', $or_id)) {
                 $this->tpl->setCurrentBlock("or_desklink");
                 $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_ref_id', $or_id);
                 $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_id', $or_id);
                 $this->ctrl->setParameterByClass(get_class($this->container_gui), 'type', $obj_type);
                 $this->tpl->setVariable("DESK_LINK_OR", $this->ctrl->getLinkTarget($this->container_gui, 'addToDesk'));
                 $this->tpl->setVariable("TXT_DESK_OR", $this->lng->txt("to_desktop"));
                 $this->tpl->parseCurrentBlock();
             }
         }
         $this->tpl->setCurrentBlock("or_row");
         $this->tpl->setVariable("OBJ_TITLE_OR", $ilObjDataCache->lookupTitle($obj_id));
         $this->tpl->setVariable('IMG_TYPE_OR', ilUtil::getTypeIconPath($obj_type, $obj_id, 'small'));
         $this->tpl->setVariable("TXT_IMG_OR", $this->lng->txt('obj_' . $obj_type));
         $this->tpl->setVariable("OBJ_CLASS_CENTER_OR", 'option_value_center');
         $this->tpl->setVariable("OBJ_CLASS_OR", 'option_value');
         $this->tpl->parseCurrentBlock();
         ++$counter;
     }
 }
 /**
  * show preconditions of the page
  */
 function showPreconditionsOfPage()
 {
     $conds = ilObjContentObject::_getMissingPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $this->getCurrentPageId());
     $topchap = ilObjContentObject::_getMissingPreconditionsTopChapter($this->lm->getRefId(), $this->lm->getId(), $this->getCurrentPageId());
     $page_id = $this->getCurrentPageId();
     // content style
     $this->tpl->setCurrentBlock("ContentStyle");
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
     } else {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
     }
     $this->tpl->parseCurrentBlock();
     $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_preconditions.html", true);
     // list all missing preconditions
     include_once "./Services/Repository/classes/class.ilRepositoryExplorer.php";
     foreach ($conds as $cond) {
         $obj_link = ilRepositoryExplorer::buildLinkTarget($cond["trigger_ref_id"], $cond["trigger_type"]);
         $obj_frame = ilRepositoryExplorer::buildFrameTarget($cond["trigger_type"], $cond["trigger_ref_id"], $cond["trigger_obj_id"]);
         $this->tpl->setCurrentBlock("condition");
         $this->tpl->setVariable("ROWCOL", $rc = $rc != "tblrow2" ? "tblrow2" : "tblrow1");
         $this->tpl->setVariable("VAL_ITEM", ilObject::_lookupTitle($cond["trigger_obj_id"]));
         $this->tpl->setVariable("LINK_ITEM", $obj_link);
         $this->tpl->setVariable("FRAME_ITEM", $obj_frame);
         if ($cond["operator"] == "passed") {
             $cond_str = $this->lng->txt("passed");
         } else {
             $cond_str = $cond["operator"];
         }
         $this->tpl->setVariable("VAL_CONDITION", $cond_str . " " . $cond["value"]);
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setCurrentBlock("pg_content");
     $this->tpl->setVariable("TXT_MISSING_PRECONDITIONS", sprintf($this->lng->txt("cont_missing_preconditions"), ilLMObject::_lookupTitle($topchap)));
     $this->tpl->setVariable("TXT_ITEM", $this->lng->txt("item"));
     $this->tpl->setVariable("TXT_CONDITION", $this->lng->txt("condition"));
     // output skip chapter link
     $parent = $this->lm_tree->getParentId($topchap);
     $childs = $this->lm_tree->getChildsByType($parent, "st");
     $next = "";
     $j = -2;
     $i = 1;
     foreach ($childs as $child) {
         if ($child["child"] == $topchap) {
             $j = $i;
         }
         if ($i++ == $j + 1) {
             $succ_node = $this->lm_tree->fetchSuccessorNode($child["child"], "pg");
         }
     }
     if ($succ_node != "") {
         $framestr = !empty($_GET["frame"]) ? "frame=" . $_GET["frame"] . "&" : "";
         $showViewInFrameset = true;
         $link = "<br /><a href=\"" . $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]) . "\">" . $this->lng->txt("cont_skip_chapter") . "</a>";
         $this->tpl->setVariable("LINK_SKIP_CHAPTER", $link);
     }
     $this->tpl->parseCurrentBlock();
 }
 /**
  * display tree view
  */
 function showTree()
 {
     global $ilCtrl, $tree, $ilSetting, $lng;
     $ilCtrl->setParameter($this, "active_node", $_GET["active_node"]);
     $this->tpl = new ilTemplate("tpl.main.html", true, true);
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
     include_once "./Services/Repository/classes/class.ilRepositoryExplorer.php";
     $active_node = $_GET["active_node"] > 1 ? $_GET["active_node"] : $_GET["ref_id"] > 1 ? $_GET["ref_id"] : 0;
     $top_node = 0;
     if ($ilSetting->get("rep_tree_limit_grp_crs") && $active_node > 0) {
         $path = $tree->getPathId($active_node);
         foreach ($path as $n) {
             if ($top_node > 0) {
                 break;
             }
             if (in_array(ilObject::_lookupType(ilObject::_lookupObjId($n)), array("crs", "grp"))) {
                 $top_node = $n;
             }
         }
     }
     $exp = new ilRepositoryExplorer("ilias.php?baseClass=ilRepositoryGUI&amp;cmd=goto", $top_node);
     $exp->setUseStandardFrame(false);
     $exp->setExpandTarget($ilCtrl->getLinkTarget($this, "showTree"));
     $exp->setFrameUpdater("tree", "updater");
     $exp->setTargetGet("ref_id");
     if ($_GET["repexpand"] == "") {
         $expanded = $this->tree->readRootId();
     } else {
         $expanded = $_GET["repexpand"];
     }
     $exp->setExpand($expanded);
     if ($active_node > 0) {
         $path = $tree->getPathId($active_node);
         if ($top_node > 0) {
             $exp->setForceOpenPath($path);
             $exp->setExpand($expanded);
         } else {
             $exp->setForceOpenPath($path + array($top_node));
         }
         $exp->highlightNode($active_node);
     }
     // build html-output
     if ($top_node > 0) {
         $head_tpl = new ilTemplate("tpl.cont_tree_head.html", true, true, "Services/Repository");
         $path = ilObject::_getIcon(ROOT_FOLDER_ID, "tiny", "root");
         $nd = $tree->getNodeData(ROOT_FOLDER_ID);
         $title = $nd["title"];
         if ($title == "ILIAS") {
             $title = $lng->txt("repository");
         }
         $head_tpl->setVariable("IMG_SRC", $path);
         $head_tpl->setVariable("ALT_IMG", $lng->txt("icon") . " " . $title);
         $head_tpl->setVariable("LINK_TXT", $title);
         $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "1");
         $head_tpl->setVariable("LINK_HREF", $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"));
         $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
         $exp->setTreeLead($head_tpl->get());
         $exp->initItemCounter(1);
         $exp->setOutput($tree->getParentId($top_node), 1, ilObject::_lookupObjId($tree->getParentId($top_node)));
     } else {
         $exp->setOutput(0);
     }
     $output = $exp->getOutput(false);
     //if ($GLOBALS["ilUser"]->getLogin() == "alex") echo "topnode:$top_node:activenode:$active_node:";
     // asynchronous output
     if ($ilCtrl->isAsynch()) {
         echo $output;
         exit;
     }
     $this->tpl->setCurrentBlock("content");
     $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("overview"));
     $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
     $this->tpl->setVariable("EXPLORER", $output);
     $ilCtrl->setParameter($this, "repexpand", $_GET["repexpand"]);
     $this->tpl->setVariable("ACTION", $ilCtrl->getLinkTarget($this, "showTree", "", false, false));
     $this->tpl->parseCurrentBlock();
     include_once "./Services/jQuery/classes/class.iljQueryUtil.php";
     iljQueryUtil::initjQuery($this->tpl);
     $this->tpl->show(false);
     exit;
 }
 public function showItems()
 {
     include_once "./Services/Repository/classes/class.ilRepositoryExplorer.php";
     $this->initBookingsObject();
     $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     if (!count($bookings = ilPaymentBookings::getBookingsOfCustomer($this->user_obj->getId()))) {
         ilUtil::sendInfo($this->lng->txt('pay_not_buyed_any_object'));
         return true;
     }
     $counter = 0;
     foreach ($bookings as $booking) {
         $tmp_obj = ilObjectFactory::getInstanceByRefId($booking['ref_id'], false);
         $tmp_vendor = ilObjectFactory::getInstanceByObjId($booking['b_vendor_id'], false);
         $tmp_purchaser = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false);
         $transaction = $booking['transaction'];
         include_once './Services/Payment/classes/class.ilPayMethods.php';
         $str_paymethod = ilPayMethods::getStringByPaymethod($booking['b_pay_method']);
         $transaction .= " (" . $str_paymethod . ")";
         $f_result[$counter]['transaction'] = $transaction;
         if ($tmp_obj) {
             $obj_link = ilRepositoryExplorer::buildLinkTarget($booking['ref_id'], $tmp_obj->getType());
             $obj_target = ilRepositoryExplorer::buildFrameTarget($tmp_obj->getType(), $booking['ref_id'], $tmp_obj->getId());
             $f_result[$counter]['object_title'] = "<a href=\"" . $obj_link . "\" target=\"" . $obj_target . "\">" . $tmp_obj->getTitle() . "</a>";
         } else {
             $obj_link = '';
             $obj_target = '';
             $f_result[$counter]['object_title'] = $booking['object_title'] . '<br> (' . $this->lng->txt('object_deleted') . ')';
         }
         $f_result[$counter]['vendor'] = '[' . $tmp_vendor->getLogin() . ']';
         $f_result[$counter]['customer'] = '[' . $tmp_purchaser->getLogin() . ']';
         $f_result[$counter]['order_date'] = ilDatePresentation::formatDate(new ilDateTime($booking['order_date'], IL_CAL_UNIX));
         //todo check for accessduration!!
         if ($booking['duration'] == 0 && $booking['access_enddate'] == NULL) {
             $f_result[$counter]['duration'] = $this->lng->txt("unlimited_duration");
         } else {
             if ($booking['duration'] > 0) {
                 $f_result[$counter]['duration'] = $booking['duration'] . ' ' . $this->lng->txt('paya_months');
             }
             $f_result[$counter]['duration'] .= ilDatePresentation::formatDate(new ilDateTime($booking['access_startdate'], IL_CAL_DATETIME)) . ' - ' . ilDatePresentation::formatDate(new ilDateTime($booking['access_enddate'], IL_CAL_DATETIME));
         }
         $f_result[$counter]['price'] = $booking['price'] . ' ' . $booking['currency_unit'];
         $f_result[$counter]['discount'] = $booking['discount'] != '' ? round($booking['discount'], 2) . ' ' . $booking['currency_unit'] : '&nbsp;';
         $payed_access = $booking['payed'] ? $this->lng->txt('yes') : $this->lng->txt('no');
         $payed_access .= '/';
         $payed_access .= $booking['access_granted'] ? $this->lng->txt('yes') : $this->lng->txt('no');
         $f_result[$counter]['payed_access'] = $payed_access;
         unset($tmp_obj);
         unset($tmp_vendor);
         unset($tmp_purchaser);
         ++$counter;
     }
     return $this->showStatisticTable($f_result);
 }
 function buildLinkTarget($a_node_id, $a_type)
 {
     if (!$this->custom_link_target) {
         return parent::buildLinkTarget($a_node_id, $a_type);
     }
     $link = $this->custom_link_target . "&" . $this->target_get . "=" . $a_node_id;
     return $link;
 }