/**
  * Render content
  * 
  * @param bool $a_return
  * @param string $a_url
  */
 public function render($a_return = false, $a_url = false)
 {
     global $ilUser, $lng;
     if (!$a_return) {
         $this->deliver();
     } else {
         $tree = new ilWorkspaceTree($ilUser->getId());
         $wsp_id = $tree->lookupNodeId($this->object->getId());
         $caption = $lng->txt("wsp_type_crsv") . ' "' . $this->object->getTitle() . '"';
         $valid = true;
         if (!file_exists($this->object->getFilePath())) {
             $valid = false;
             $message = $lng->txt("url_not_found");
         } else {
             if (!$a_url) {
                 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
                 $access_handler = new ilWorkspaceAccessHandler($tree);
                 if (!$access_handler->checkAccess("read", "", $wsp_id)) {
                     $valid = false;
                     $message = $lng->txt("permission_denied");
                 }
             }
         }
         if ($valid) {
             if (!$a_url) {
                 $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
             }
             return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
         } else {
             return '<div>' . $caption . ' (' . $message . ')</div>';
         }
     }
 }
 /**
  * execute command
  */
 function &executeCommand()
 {
     global $ilCtrl, $ilUser;
     $next_class = $this->ctrl->getNextClass($this);
     $cmd = $this->ctrl->getCmd();
     switch ($next_class) {
         case "ilobjbloggui":
             // #12879 - we need the wsp-id for the keywords
             include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
             $wsp_tree = new ilWorkspaceTree($ilUser->getId());
             $blog_obj_id = (int) $this->getPageObject()->getTitle();
             $blog_node_id = $wsp_tree->lookupNodeId($blog_obj_id);
             include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
             $blog_gui = new ilObjBlogGUI($blog_node_id, ilObjBlogGUI::WORKSPACE_NODE_ID);
             $blog_gui->disableNotes(!$this->enable_comments);
             return $ilCtrl->forwardCommand($blog_gui);
         case "ilcalendarmonthgui":
             // booking action
             if ($cmd && $cmd != "preview") {
                 include_once './Services/Calendar/classes/class.ilCalendarMonthGUI.php';
                 $month_gui = new ilCalendarMonthGUI(new ilDate());
                 return $ilCtrl->forwardCommand($month_gui);
             } else {
                 $ilCtrl->setParameter($this, "cmd", "preview");
                 return self::EMBEDDED_NO_OUTPUT;
             }
         case "ilpageobjectgui":
             die("Deprecated. ilPortfolioPage gui forwarding to ilpageobject");
             return;
         default:
             $this->setPresentationTitle($this->getPageObject()->getTitle());
             return parent::executeCommand();
     }
 }
 /**
  * Render content
  * 
  * @param bool $a_return
  */
 public function render($a_return = false)
 {
     global $ilUser;
     if (!$a_return) {
         $this->deliver();
     } else {
         $tree = new ilWorkspaceTree($ilUser->getId());
         $wsp_id = $tree->lookupNodeId($this->object->getId());
         $caption = $this->object->getTitle();
         $link = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
         return "<a href=\"" . $link . "\">" . $caption . "</a>";
     }
 }
 /**
  * Check access rights for blog pages
  *
  * @param    int     	object id (glossary)
  * @param    int         page id (definition)
  * @return   boolean     access given (true/false)
  */
 private function checkAccessBlogPage($obj_id, $page_id)
 {
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
     $tree = new ilWorkspaceTree(0);
     $node_id = $tree->lookupNodeId($obj_id);
     // repository
     if (!$node_id) {
         return $this->checkAccessObject($obj_id);
     } else {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
         foreach ($this->check_users as $user_id) {
             $access_handler = new ilWorkspaceAccessHandler($tree);
             if ($access_handler->checkAccessOfUser($tree, $user_id, "read", "view", $node_id, "blog")) {
                 return true;
             }
         }
     }
     return false;
 }
Example #5
0
 /**
  * get all related objects for user
  */
 function _getRelatedObjectsOfUser($a_mode)
 {
     global $ilDB, $ilUser, $tree;
     if ($a_mode == ilPDNotesGUI::PRIVATE_NOTES) {
         $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " . " type = " . $ilDB->quote((int) IL_NOTE_PRIVATE, "integer") . " AND author = " . $ilDB->quote($ilUser->getId(), "integer") . " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" . " ORDER BY rep_obj_id";
         $ilDB->quote($q);
         $set = $ilDB->query($q);
         $reps = array();
         while ($rep_rec = $ilDB->fetchAssoc($set)) {
             // #9343: deleted objects
             if (ilObject::_lookupType($rep_rec["rep_obj_id"])) {
                 $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
             }
         }
     } else {
         // all objects where the user wrote at least one comment
         $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " . " type = " . $ilDB->quote((int) IL_NOTE_PUBLIC, "integer") . " AND author = " . $ilDB->quote($ilUser->getId(), "integer") . " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" . " ORDER BY rep_obj_id";
         $set = $ilDB->query($q);
         $reps = array();
         while ($rep_rec = $ilDB->fetchAssoc($set)) {
             // #9343: deleted objects
             if ($type = ilObject::_lookupType($rep_rec["rep_obj_id"])) {
                 if (ilNote::commentsActivated($rep_rec["rep_obj_id"], "", $type)) {
                     $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
                 }
             }
         }
         // additionally all objects on the personal desktop of the user
         // that have at least on comment
         $dis = ilObjUser::_lookupDesktopItems($ilUser->getId());
         $obj_ids = array();
         foreach ($dis as $di) {
             $obj_ids[] = $di["obj_id"];
         }
         if (count($obj_ids) > 0) {
             $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " . $ilDB->in("rep_obj_id", $obj_ids, false, "integer") . " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")";
             $set = $ilDB->query($q);
             while ($rec = $ilDB->fetchAssoc($set)) {
                 $add = true;
                 reset($reps);
                 foreach ($reps as $r) {
                     if ($r["rep_obj_id"] == $rec["rep_obj_id"]) {
                         $add = false;
                     }
                 }
                 if ($add) {
                     $type = ilObject::_lookupType($rec["rep_obj_id"]);
                     if (ilNote::commentsActivated($rec["rep_obj_id"], "", $type)) {
                         $reps[] = array("rep_obj_id" => $rec["rep_obj_id"]);
                     }
                 }
             }
         }
     }
     if (sizeof($reps)) {
         // check if notes/comments belong to objects in trash
         // see ilNoteGUI::showTargets()
         foreach ($reps as $idx => $rep) {
             $has_active_ref = false;
             // repository?
             $ref_ids = ilObject::_getAllReferences($rep["rep_obj_id"]);
             if ($ref_ids) {
                 $reps[$idx]["ref_ids"] = array_values($ref_ids);
                 foreach ($ref_ids as $ref_id) {
                     if (!$tree->isDeleted($ref_id)) {
                         $has_active_ref = true;
                         break;
                     }
                 }
             } else {
                 // personal workspace?
                 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
                 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
                 $wsp_tree = new ilWorkspaceTree($ilUser->getId());
                 $node_id = $wsp_tree->lookupNodeId($rep["rep_obj_id"]);
                 if ($node_id) {
                     $reps[$idx]["wsp_id"] = $node_id;
                     $has_active_ref = true;
                 }
             }
             if (!$has_active_ref) {
                 unset($reps[$idx]);
             }
         }
     }
     return $reps;
 }