Пример #1
0
 /**
  * Handle read/write current detail level.
  */
 function handleDetailLevel()
 {
     global $ilUser, $ilCtrl;
     // set/get detail level
     if ($this->detail_max > $this->detail_min) {
         include_once "Services/Block/classes/class.ilBlockSetting.php";
         if (isset($_GET[$this->getDetailParameter()])) {
             ilBlockSetting::_writeDetailLevel($this->getBlockType(), $_GET[$this->getDetailParameter()], $ilUser->getId(), $this->block_id);
             $this->setCurrentDetailLevel($_GET[$this->getDetailParameter()]);
             if ((int) $_GET[$this->getDetailParameter()] == 0) {
                 $ilCtrl->redirectByClass("ilcolumngui", "");
             }
         } else {
             $this->setCurrentDetailLevel(ilBlockSetting::_lookupDetailLevel($this->getBlockType(), $ilUser->getId(), $this->block_id));
         }
     }
 }
Пример #2
0
 /**
  * Add hidden block and create block selectors.
  */
 function addHiddenBlockSelector()
 {
     /**
      * @var $lng ilLanguage
      * @var $ilUser ilObjUser
      * @var $ilCtrl ilCtrl
      * $var $tpl ilTemplate
      */
     global $lng, $ilUser, $ilCtrl, $tpl;
     // show selector for hidden blocks
     include_once "Services/Block/classes/class.ilBlockSetting.php";
     $hidden_blocks = array();
     foreach ($this->blocks[$this->getSide()] as $block) {
         include_once "./" . self::$locations[$block["class"]] . "classes/" . "class." . $block["class"] . ".php";
         if ($block["custom"] == false) {
             if ($ilCtrl->getContextObjType() == "user") {
                 if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId()) == 0) {
                     $hidden_blocks[$block["type"]] = $lng->txt('block_show_' . $block["type"]);
                 }
             } else {
                 if ($ilCtrl->getContextObjType() != "") {
                     if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId(), $ilCtrl->getContextObjId()) == 0) {
                         $hidden_blocks[$block["type"] . "_" . $ilCtrl->getContextObjId()] = $lng->txt('block_show_' . $block["type"]);
                     }
                 }
             }
         } else {
             if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId(), $block["id"]) == 0) {
                 include_once "./Services/Block/classes/class.ilCustomBlock.php";
                 $cblock = new ilCustomBlock($block["id"]);
                 $hidden_blocks[$block["type"] . "_" . $block["id"]] = sprintf($lng->txt('block_show_x'), $cblock->getTitle());
             }
         }
     }
     if (count($hidden_blocks) > 0) {
         foreach ($hidden_blocks as $id => $title) {
             $ilCtrl->setParameter($this, 'block', $id);
             $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'activateBlock'));
             $ilCtrl->setParameter($this, 'block', '');
         }
     }
     // create block selection list
     if (!$this->getRepositoryMode() || $this->getEnableEdit()) {
         $add_blocks = array();
         if ($this->getSide() == IL_COL_RIGHT) {
             if (is_array($this->custom_blocks[$this->getColType()])) {
                 foreach ($this->custom_blocks[$this->getColType()] as $block_class) {
                     include_once "./" . self::$locations[$block_class] . "classes/" . "class." . $block_class . ".php";
                     $block_type = call_user_func(array($block_class, 'getBlockType'));
                     // check if block type is globally (de-)activated
                     if ($this->isGloballyActivated($block_type)) {
                         // check if number of blocks is limited
                         if (!$this->exceededLimit($block_type)) {
                             $add_blocks[$block_type] = $lng->txt('block_create_' . $block_type);
                         }
                     }
                 }
             }
         }
         if (count($add_blocks) > 0) {
             foreach ($add_blocks as $id => $title) {
                 $ilCtrl->setParameter($this, 'block_type', $id);
                 $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'addBlock'));
                 $ilCtrl->setParameter($this, 'block_type', '');
             }
         }
     }
     $this->addBlockSorting();
 }