public function checkAccess(array $a_users)
 {
     if ($this->wsp_id) {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
         foreach ($a_users as $user_id) {
             $access_handler = new ilWorkspaceAccessHandler($this->tree);
             if ($access_handler->checkAccessOfUser($this->tree, $user_id, "read", "view", $this->wsp_id, "blog")) {
                 return true;
             }
         }
     }
 }
 /**
  * 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"]);
 }
 /**
  * Import data from DB
  * 
  * @param int $a_user_id
  */
 protected function importData($a_user_id)
 {
     global $ilUser;
     $data = array();
     $objects = $this->handler->getSharedObjects($a_user_id);
     if ($objects) {
         foreach ($objects as $wsp_id => $obj_id) {
             // #9848: flag if current share access is password-protected
             $perms = ilWorkspaceAccessHandler::getPermissions($wsp_id);
             $is_password = !in_array($ilUser->getId(), $perms) && !in_array(ilWorkspaceAccessGUI::PERMISSION_REGISTERED, $perms) && !in_array(ilWorkspaceAccessGUI::PERMISSION_ALL, $perms) && in_array(ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD, $perms);
             $data[] = array("wsp_id" => $wsp_id, "obj_id" => $obj_id, "type" => ilObject::_lookupType($obj_id), "title" => ilObject::_lookupTitle($obj_id), "password" => $is_password);
         }
     }
     $this->setData($data);
 }
 protected function checkPassword()
 {
     global $ilDB, $lng;
     $lng->loadLanguageModule("wsp");
     $form = $this->initPasswordForm();
     if ($form->checkInput()) {
         $input = md5($form->getInput("password"));
         if ($this->node_id) {
             include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
             $password = ilWorkspaceAccessHandler::getSharedNodePassword($this->node_id);
         } else {
             include_once "Services/Portfolio/classes/class.ilPortfolioAccessHandler.php";
             $password = ilPortfolioAccessHandler::getSharedNodePassword($this->portfolio_id);
         }
         if ($input == $password) {
             if ($this->node_id) {
                 ilWorkspaceAccessHandler::keepSharedSessionPassword($this->node_id, $input);
                 $this->redirectToResource($this->node_id);
             } else {
                 ilPortfolioAccessHandler::keepSharedSessionPassword($this->portfolio_id, $input);
                 $this->redirectToResource($this->portfolio_id, true);
             }
         } else {
             $item = $form->getItemByPostVar("password");
             $item->setAlert($lng->txt("wsp_invalid_password"));
             ilUtil::sendFailure($lng->txt("form_input_not_valid"));
         }
     }
     $form->setValuesByPost();
     $this->passwordForm($form);
 }
Ejemplo n.º 5
0
 protected function saveBlogObject()
 {
     global $ilUser;
     if (!$_POST["node"]) {
         ilUtil::sendFailure($this->lng->txt("select_one"));
         return $this->createBlogObject();
     }
     $parent_node = $_POST["node"];
     include_once "Modules/Blog/classes/class.ilObjBlog.php";
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
     $blog = new ilObjBlog();
     $blog->setTitle($this->object->getTitle() . " - " . $this->ass->getTitle());
     $blog->create();
     $tree = new ilWorkspaceTree($ilUser->getId());
     $node_id = $tree->insertObject($parent_node, $blog->getId());
     $access_handler = new ilWorkspaceAccessHandler($tree);
     $access_handler->setPermissions($parent_node, $node_id);
     $this->object->addResourceObject($node_id, $this->ass->getId(), $ilUser->getId());
     ilUtil::sendSuccess($this->lng->txt("exc_blog_created"), true);
     $this->ctrl->redirect($this, "showOverview");
 }
 protected function checkPassword()
 {
     global $lng;
     $node_id = $_REQUEST["item_ref_id"];
     if (!$node_id) {
         $this->ctrl->redirect($this, "share");
     }
     $form = $this->initPasswordForm($node_id);
     if ($form->checkInput()) {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
         $password = ilWorkspaceAccessHandler::getSharedNodePassword($node_id);
         $input = md5($form->getInput("password"));
         if ($input == $password) {
             // we save password and start over
             ilWorkspaceAccessHandler::keepSharedSessionPassword($node_id, $input);
             $this->ctrl->setParameter($this, "item_ref_id", $node_id);
             $this->ctrl->redirect($this, "copyShared");
         } else {
             $item = $form->getItemByPostVar("password");
             $item->setAlert($lng->txt("wsp_invalid_password"));
             ilUtil::sendFailure($lng->txt("form_input_not_valid"));
         }
     }
     $form->setValuesByPost();
     $this->passwordForm($node_id, $form);
 }
Ejemplo n.º 7
0
 /**
  * Remove all tree and node data 
  */
 public function cascadingDelete()
 {
     $root_id = $this->readRootId();
     if (!$root_id) {
         return;
     }
     $root = $this->getNodeData($root_id);
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
     $access_handler = new ilWorkspaceAccessHandler($this);
     // delete node data
     $nodes = $this->getSubTree($root);
     foreach ($nodes as $node) {
         $access_handler->removePermission($node["wsp_id"]);
         $object = ilObjectFactory::getInstanceByObjId($node["obj_id"], false);
         if ($object) {
             $object->delete();
         }
         $this->deleteReference($node["wsp_id"]);
     }
     $this->deleteTree($root);
 }
Ejemplo n.º 8
0
 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);
     }
 }
 /**
  * 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>';
         }
     }
 }
 protected static function createBlogInPersonalWorkspace($a_title)
 {
     global $ilUser;
     static $ws_access = null;
     include_once "Modules/Blog/classes/class.ilObjBlog.php";
     $blog = new ilObjBlog();
     $blog->setType("blog");
     $blog->setTitle($a_title);
     $blog->create();
     if (!$ws_access) {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
         $tree = new ilWorkspaceTree($ilUser->getId());
         $ws_access = new ilWorkspaceAccessHandler($tree);
     }
     $tree = $ws_access->getTree();
     $node_id = $tree->insertObject($tree->getRootId(), $blog->getId());
     $ws_access->setPermissions($tree->getRootId(), $node_id);
     return $blog->getId();
 }
Ejemplo n.º 11
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();
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * 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');
     }
 }
 /**
  * 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;
 }
Ejemplo n.º 14
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;
     }
 }