/**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng, $lng, $ilCtrl;
     switch ($a_set["type"]) {
         case ilPortfolioPage::TYPE_PAGE:
             $this->tpl->setCurrentBlock("title_field");
             $this->tpl->setVariable("ID", $a_set["id"]);
             $this->tpl->setVariable("VAL_TITLE", ilUtil::prepareFormOutput($a_set["title"]));
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("action");
             $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit_page"));
             $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $a_set["id"]);
             $this->tpl->setVariable("CMD_EDIT", $ilCtrl->getLinkTargetByClass("ilportfoliopagegui", "edit"));
             $this->tpl->parseCurrentBlock();
             break;
         case ilPortfolioPage::TYPE_BLOG:
             $this->tpl->setCurrentBlock("title_static");
             $this->tpl->setVariable("VAL_TITLE", $lng->txt("obj_blog") . ": " . ilObjBlog::_lookupTitle($a_set["title"]));
             $this->tpl->parseCurrentBlock();
             $obj_id = (int) $a_set["title"];
             if (isset($this->blogs[$obj_id])) {
                 $node_id = $this->blogs[$obj_id];
                 $link = ilWorkspaceAccessHandler::getGotoLink($node_id, $obj_id);
                 $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $a_set["id"]);
                 $link = $ilCtrl->getLinkTargetByClass(array("ilportfoliopagegui", "ilobjbloggui"), "edit");
                 $this->tpl->setCurrentBlock("action");
                 $this->tpl->setVariable("TXT_EDIT", $lng->txt("blog_edit"));
                 $this->tpl->setVariable("CMD_EDIT", $link);
                 $this->tpl->parseCurrentBlock();
             }
             break;
     }
     $this->tpl->setVariable("ID", $a_set["id"]);
     $this->tpl->setVariable("VAL_ORDER_NR", $a_set["order_nr"]);
 }
 static function sendNotification($a_action, $a_in_wsp, $a_blog_node_id, $a_posting_id, $a_comment = null)
 {
     global $ilUser, $ilAccess;
     // get blog object id (repository or workspace)
     if ($a_in_wsp) {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
         $tree = new ilWorkspaceTree($ilUser->getId());
         // owner of tree is irrelevant
         $blog_obj_id = $tree->lookupObjectId($a_blog_node_id);
         $access_handler = new ilWorkspaceAccessHandler($tree);
         $link = ilWorkspaceAccessHandler::getGotoLink($a_blog_node_id, $blog_obj_id, "_" . $a_posting_id);
     } else {
         $blog_obj_id = ilObject::_lookupObjId($a_blog_node_id);
         $access_handler = null;
         include_once "Services/Link/classes/class.ilLink.php";
         $link = ilLink::_getStaticLink($a_blog_node_id, "blog", true, "_" . $a_posting_id);
     }
     if (!$blog_obj_id) {
         return;
     }
     include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
     $posting = new ilBlogPosting($a_posting_id);
     // #11138
     $ignore_threshold = $a_action == "comment";
     // approval handling
     $admin_only = false;
     if (!$posting->isApproved()) {
         $blog = new self($blog_obj_id, false);
         if ($blog->hasApproval()) {
             switch ($a_action) {
                 case "update":
                     // un-approved posting was updated - no notifications
                     return;
                 case "new":
                     // un-approved posting was activated - admin-only notification
                     $admin_only = true;
                     $ignore_threshold = true;
                     break;
             }
         }
     }
     // recipients
     include_once "./Services/Notification/classes/class.ilNotification.php";
     $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_BLOG, $blog_obj_id, $a_posting_id, $ignore_threshold);
     if (!sizeof($users)) {
         return;
     }
     // send mails
     include_once "./Services/Mail/classes/class.ilMail.php";
     include_once "./Services/User/classes/class.ilObjUser.php";
     include_once "./Services/Language/classes/class.ilLanguageFactory.php";
     include_once "./Services/User/classes/class.ilUserUtil.php";
     $posting_title = $posting->getTitle();
     $blog_title = ilObject::_lookupTitle($blog_obj_id);
     $author = $posting->getAuthor();
     $notified = array();
     foreach (array_unique($users) as $idx => $user_id) {
         // the user responsible for the action should not be notified
         if ($user_id == $ilUser->getId()) {
             continue;
         }
         // workspace
         if ($access_handler) {
             if ($admin_only && !$access_handler->checkAccessOfUser($tree, $user_id, 'write', '', $a_blog_node_id)) {
                 continue;
             }
             if (!$access_handler->checkAccessOfUser($tree, $user_id, 'read', '', $a_blog_node_id)) {
                 continue;
             }
         } else {
             if ($admin_only && !$ilAccess->checkAccessOfUser($user_id, 'write', '', $a_blog_node_id)) {
                 continue;
             }
             if (!$ilAccess->checkAccessOfUser($user_id, 'read', '', $a_blog_node_id)) {
                 continue;
             }
         }
         // use language of recipient to compose message
         $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
         $ulng->loadLanguageModule('blog');
         $subject = sprintf($ulng->txt('blog_change_notification_subject'), $blog_title);
         $message = sprintf($ulng->txt('blog_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
         $message .= $ulng->txt('blog_change_notification_body_' . $a_action) . ":\n\n";
         $message .= $ulng->txt('obj_blog') . ": " . $blog_title . "\n";
         $message .= $ulng->txt('blog_posting') . ": " . $posting_title . "\n";
         $message .= $ulng->txt('blog_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n";
         if ($a_comment) {
             $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n";
         }
         $message .= "\n" . $ulng->txt('blog_change_notification_link') . ": " . $link;
         $mail_obj = new ilMail(ANONYMOUS_USER_ID);
         $mail_obj->appendInstallationSignature(true);
         $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system"));
         $notified[] = $user_id;
     }
     if (sizeof($notified)) {
         ilNotification::updateNotificationTime(ilNotification::TYPE_BLOG, $blog_obj_id, $notified);
     }
 }
Esempio n. 3
0
 /**
  * show related objects as links
  */
 function showTargets(&$tpl, $a_rep_obj_id, $a_note_id, $a_obj_type, $a_obj_id)
 {
     global $tree, $ilAccess, $objDefinition, $ilUser;
     if ($this->targets_enabled) {
         if ($a_rep_obj_id > 0) {
             // get all visible references of target object
             // repository
             $ref_ids = ilObject::_getAllReferences($a_rep_obj_id);
             if ($ref_ids) {
                 $vis_ref_ids = array();
                 foreach ($ref_ids as $ref_id) {
                     if ($ilAccess->checkAccess("visible", "", $ref_id)) {
                         $vis_ref_ids[] = $ref_id;
                     }
                 }
                 // output links to targets
                 if (count($vis_ref_ids) > 0) {
                     foreach ($vis_ref_ids as $vis_ref_id) {
                         $type = ilObject::_lookupType($vis_ref_id, true);
                         $sub_link = $sub_title = "";
                         if ($type == "sahs") {
                             $link = "goto.php?target=sahs_" . $vis_ref_id;
                             $title = ilObject::_lookupTitle($a_rep_obj_id);
                             if ($a_obj_type == "sco" || $a_obj_type == "seqc" || $a_obj_type == "chap" || $a_obj_type == "pg") {
                                 $sub_link = "goto.php?target=sahs_" . $vis_ref_id . "_" . $a_obj_id;
                                 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Node.php";
                                 $sub_title = ilSCORM2004Node::_lookupTitle($a_obj_id);
                                 $sub_icon = ilUtil::getImagePath("icon_" . $a_obj_type . ".svg");
                             }
                         } else {
                             if ($type == "poll") {
                                 include_once "Services/Link/classes/class.ilLink.php";
                                 $title = ilObject::_lookupTitle($a_rep_obj_id);
                                 $link = ilLink::_getLink($vis_ref_id, "poll");
                             } else {
                                 if ($a_obj_type != "pg") {
                                     if (!is_object($this->item_list_gui[$type])) {
                                         $class = $objDefinition->getClassName($type);
                                         $location = $objDefinition->getLocation($type);
                                         $full_class = "ilObj" . $class . "ListGUI";
                                         include_once $location . "/class." . $full_class . ".php";
                                         $this->item_list_gui[$type] = new $full_class();
                                     }
                                     // for references, get original title
                                     // (link will lead to orignal, which basically is wrong though)
                                     if ($a_obj_type == "crsr" || $a_obj_type == "catr") {
                                         include_once "Services/ContainerReference/classes/class.ilContainerReference.php";
                                         $tgt_obj_id = ilContainerReference::_lookupTargetId($a_rep_obj_id);
                                         $title = ilObject::_lookupTitle($tgt_obj_id);
                                     } else {
                                         $title = ilObject::_lookupTitle($a_rep_obj_id);
                                     }
                                     $this->item_list_gui[$type]->initItem($vis_ref_id, $a_rep_obj_id, $title);
                                     $link = $this->item_list_gui[$type]->getCommandLink("infoScreen");
                                     // workaround, because # anchor can't be passed through frameset
                                     $link = ilUtil::appendUrlParameterString($link, "anchor=note_" . $a_note_id);
                                     $link = $this->item_list_gui[$type]->appendRepositoryFrameParameter($link) . "#note_" . $a_note_id;
                                 } else {
                                     $title = ilObject::_lookupTitle($a_rep_obj_id);
                                     $link = "goto.php?target=pg_" . $a_obj_id . "_" . $vis_ref_id;
                                 }
                             }
                         }
                         $par_id = $tree->getParentId($vis_ref_id);
                         // sub object link
                         if ($sub_link != "") {
                             if ($this->export_html || $this->print) {
                                 $tpl->setCurrentBlock("exp_target_sub_object");
                             } else {
                                 $tpl->setCurrentBlock("target_sub_object");
                                 $tpl->setVariable("LINK_SUB_TARGET", $sub_link);
                             }
                             $tpl->setVariable("TXT_SUB_TARGET", $sub_title);
                             $tpl->setVariable("IMG_SUB_TARGET", $sub_icon);
                             $tpl->parseCurrentBlock();
                         }
                         // container and object link
                         if ($this->export_html || $this->print) {
                             $tpl->setCurrentBlock("exp_target_object");
                         } else {
                             $tpl->setCurrentBlock("target_object");
                             $tpl->setVariable("LINK_TARGET", $link);
                         }
                         $tpl->setVariable("TXT_CONTAINER", ilObject::_lookupTitle(ilObject::_lookupObjId($par_id)));
                         $tpl->setVariable("IMG_CONTAINER", ilObject::_getIcon(ilObject::_lookupObjId($par_id), "tiny"));
                         $tpl->setVariable("TXT_TARGET", $title);
                         $tpl->setVariable("IMG_TARGET", ilObject::_getIcon($a_rep_obj_id, "tiny"));
                         $tpl->parseCurrentBlock();
                     }
                     $tpl->touchBlock("target_objects");
                 }
             } else {
                 // we only need 1 instance
                 if (!$this->wsp_tree) {
                     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
                     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
                     $this->wsp_tree = new ilWorkspaceTree($ilUser->getId());
                     $this->wsp_access_handler = new ilWorkspaceAccessHandler($this->wsp_tree);
                 }
                 $node_id = $this->wsp_tree->lookupNodeId($a_rep_obj_id);
                 if ($this->wsp_access_handler->checkAccess("visible", "", $node_id)) {
                     $path = $this->wsp_tree->getPathFull($node_id);
                     if ($path) {
                         $item = array_pop($path);
                         $parent = array_pop($path);
                         if (!$parent["title"]) {
                             $parent["title"] = $this->lng->txt("wsp_personal_workspace");
                         }
                         // sub-objects
                         $additional = null;
                         if ($a_obj_id) {
                             $sub_title = $this->getSubObjectTitle($a_rep_obj_id, $a_obj_id);
                             if ($sub_title) {
                                 $item["title"] .= " (" . $sub_title . ")";
                                 $additional = "_" . $a_obj_id;
                             }
                         }
                         $link = ilWorkspaceAccessHandler::getGotoLink($node_id, $a_rep_obj_id, $additional);
                     } else {
                         $owner = ilObject::_lookupOwner($a_rep_obj_id);
                         $parent["title"] = $this->lng->txt("wsp_tab_shared") . " (" . ilObject::_lookupOwnerName($owner) . ")";
                         $item["title"] = ilObject::_lookupTitle($a_rep_obj_id);
                         $link = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&dsh=" . $owner;
                     }
                     // container and object link
                     if ($this->export_html || $this->print) {
                         $tpl->setCurrentBlock("exp_target_object");
                     } else {
                         $tpl->setCurrentBlock("target_object");
                         $tpl->setVariable("LINK_TARGET", $link);
                     }
                     // :TODO: no images in template ?
                     $tpl->setVariable("TXT_CONTAINER", $parent["title"]);
                     $tpl->setVariable("IMG_CONTAINER", ilObject::_getIcon($parent["obj_id"], "tiny"));
                     $tpl->setVariable("TXT_TARGET", $item["title"]);
                     $tpl->setVariable("IMG_TARGET", ilObject::_getIcon($a_rep_obj_id, "tiny"));
                     $tpl->parseCurrentBlock();
                 }
             }
         }
     }
 }
 /**
  * Create a permanent link for an object
  * @return 
  */
 protected function createPermanentLink($a_params = array(), $a_append = '')
 {
     include_once './Services/Link/classes/class.ilLink.php';
     if ($this->getRefId()) {
         if (!$this->is_in_wsp) {
             return ilLink::_getLink($this->ref_id, $this->getObjType(), $a_params, $a_append);
         } else {
             return ilWorkspaceAccessHandler::getGotoLink($this->getRefId(), $this->getObjId(), $a_append);
         }
     } else {
         // Return root
         return ilLink::_getLink(ROOT_FOLDER_ID, 'root');
     }
 }
Esempio n. 5
0
 protected function buildGotoLink()
 {
     switch ($this->context) {
         case self::CONTEXT_WORKSPACE_SHARING:
             include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
             return ilWorkspaceAccessHandler::getGotoLink($this->ref_id, $this->obj_id);
         default:
             // not implemented yet
             break;
     }
 }
 function executeCommand()
 {
     global $ilCtrl, $tpl, $ilMainMenu, $ilLocator, $ilUser, $lng;
     $next_class = $ilCtrl->getNextClass($this);
     $cmd = $ilCtrl->getCmd();
     $tpl->getStandardTemplate();
     // #8509
     $ilMainMenu->setActive("desktop");
     // #12096
     if ($ilUser->getId() != ANONYMOUS_USER_ID && $next_class && !in_array($next_class, array("ilobjbloggui", "ilobjportfoliogui"))) {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
         $tree = new ilWorkspaceTree($ilUser->getId());
         $access_handler = new ilWorkspaceAccessHandler($tree);
         $owner_id = $tree->lookupOwner($this->node_id);
         $obj_id = $tree->lookupObjectId($this->node_id);
         $lng->loadLanguageModule("wsp");
         // see ilPersonalWorkspaceGUI
         if ($owner_id != $ilUser->getId()) {
             $ilCtrl->setParameterByClass("ilpersonaldesktopgui", "dsh", $owner_id);
             $link = $ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "jumptoworkspace");
             $ilLocator->addItem($lng->txt("wsp_tab_shared"), $link);
             include_once "Services/User/classes/class.ilUserUtil.php";
             $ilLocator->addItem(ilUserUtil::getNamePresentation($owner_id), $link);
         } else {
             $link = $ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "jumptoworkspace");
             $ilLocator->addItem($lng->txt("wsp_tab_personal"), $link);
         }
         $link = $access_handler->getGotoLink($this->node_id, $obj_id);
         $ilLocator->addItem(ilObject::_lookupTitle($obj_id), $link);
         $tpl->setLocator($ilLocator);
     }
     switch ($next_class) {
         case "ilobjbloggui":
             include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
             $bgui = new ilObjBlogGUI($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID);
             $ilCtrl->forwardCommand($bgui);
             break;
         case "ilobjfilegui":
             include_once "Modules/File/classes/class.ilObjFileGUI.php";
             $fgui = new ilObjFileGUI($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID);
             $ilCtrl->forwardCommand($fgui);
             break;
         case "ilobjtestverificationgui":
             include_once "Modules/Test/classes/class.ilObjTestVerificationGUI.php";
             $tgui = new ilObjTestVerificationGUI($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID);
             $ilCtrl->forwardCommand($tgui);
             break;
         case "ilobjexerciseverificationgui":
             include_once "Modules/Exercise/classes/class.ilObjExerciseVerificationGUI.php";
             $egui = new ilObjExerciseVerificationGUI($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID);
             $ilCtrl->forwardCommand($egui);
             break;
         case "ilobjlinkresourcegui":
             include_once "Modules/WebResource/classes/class.ilObjLinkResourceGUI.php";
             $lgui = new ilObjLinkResourceGUI($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID);
             $ilCtrl->forwardCommand($lgui);
             break;
         case "ilobjportfoliogui":
             include_once "Modules/Portfolio/classes/class.ilObjPortfolioGUI.php";
             $pgui = new ilObjPortfolioGUI($this->portfolio_id, ilObject2GUI::PORTFOLIO_OBJECT_ID);
             $ilCtrl->forwardCommand($pgui);
             break;
         default:
             if (!$cmd) {
                 $cmd = "process";
             }
             $this->{$cmd}();
     }
     $tpl->show();
 }