/**
  * Constructor
  */
 function __construct($a_parent_obj, $a_parent_cmd, $a_tag)
 {
     global $ilCtrl, $lng, $ilAccess, $lng;
     parent::__construct($a_parent_obj, $a_parent_cmd);
     $this->setData(ilTagging::getUsersForTag($a_tag));
     $this->setTitle($lng->txt("tagging_users_using_tag"));
     $this->addColumn($this->lng->txt("user"), "");
     $this->setEnableHeader(true);
     $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
     $this->setRowTemplate("tpl.user_for_tag_row.html", "Services/Tagging");
     //$this->disable("footer");
     $this->setEnableTitle(true);
     //$this->addMultiCommand("", $lng->txt(""));
     //$this->addCommandButton("", $lng->txt(""));
 }
 /**
  * Handle an event in a listener.
  *
  * @param	string	$a_component	component, e.g. "Modules/Forum" or "Services/User"
  * @param	string	$a_event		event e.g. "createUser", "updateUser", "deleteUser", ...
  * @param	array	$a_parameter	parameter array (assoc), array("name" => ..., "phone_office" => ...)
  */
 static function handleEvent($a_component, $a_event, $a_parameter)
 {
     include_once "./Services/Tagging/classes/class.ilTagging.php";
     switch ($a_component) {
         case "Services/Object":
             switch ($a_event) {
                 case "toTrash":
                     if (!ilObject::_hasUntrashedReference($a_parameter["obj_id"])) {
                         ilTagging::setTagsOfObjectOffline($a_parameter["obj_id"], ilObject::_lookupType($a_parameter["obj_id"]), 0, "");
                     }
                     break;
                 case "undelete":
                     ilTagging::setTagsOfObjectOffline($a_parameter["obj_id"], ilObject::_lookupType($a_parameter["obj_id"]), 0, "", false);
                     break;
                 case "delete":
                     $ref_ids = ilObject::_getAllReferences($a_parameter["obj_id"]);
                     if (count($ref_ids) == 0) {
                         ilTagging::deleteTagsOfObject($a_parameter["obj_id"], $a_parameter["type"], 0, "");
                     }
                     break;
             }
             break;
     }
 }
Пример #3
0
 /**
  * Build navigation block
  *
  * @param array $items
  * @param string $a_list_cmd
  * @param string $a_posting_cmd
  * @param bool $a_link_template
  * @param bool $a_show_inactive
  * @return string
  */
 function renderNavigation(array $items, $a_list_cmd = "render", $a_posting_cmd = "preview", $a_link_template = null, $a_show_inactive = false)
 {
     global $ilCtrl, $ilSetting;
     $max_detail_postings = 10;
     $wtpl = new ilTemplate("tpl.blog_list_navigation.html", true, true, "Modules/Blog");
     $wtpl->setVariable("NAVIGATION_TITLE", $this->lng->txt("blog_navigation"));
     $ilCtrl->setParameter($this, "blpg", "");
     include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
     $counter = 0;
     foreach ($items as $month => $postings) {
         $month_name = ilCalendarUtil::_numericMonthToString((int) substr($month, 5)) . " " . substr($month, 0, 4);
         if (!$a_link_template) {
             $ilCtrl->setParameter($this, "bmn", $month);
             $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
         } else {
             $month_url = $this->buildExportLink($a_link_template, "list", $month);
         }
         // list postings for month
         if ($counter < $max_detail_postings) {
             foreach ($postings as $id => $posting) {
                 $is_active = ilBlogPosting::_lookupActive($id, "blp");
                 if (!$is_active && !$a_show_inactive) {
                     continue;
                 }
                 $counter++;
                 $caption = $posting["title"];
                 if (!$a_link_template) {
                     $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
                     $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
                     $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
                 } else {
                     $url = $this->buildExportLink($a_link_template, "posting", $id);
                 }
                 if (!$is_active) {
                     $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
                 } else {
                     if ($this->object->hasApproval() && !$posting["approved"]) {
                         $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
                     }
                 }
                 $wtpl->setCurrentBlock("navigation_item");
                 $wtpl->setVariable("NAV_ITEM_URL", $url);
                 $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
                 $wtpl->parseCurrentBlock();
             }
             $wtpl->setCurrentBlock("navigation_month_details");
             $wtpl->setVariable("NAV_MONTH", $month_name);
             $wtpl->setVariable("URL_MONTH", $month_url);
             $wtpl->parseCurrentBlock();
         } else {
             $wtpl->setCurrentBlock("navigation_month");
             $wtpl->setVariable("MONTH_NAME", $month_name);
             $wtpl->setVariable("URL_MONTH", $month_url);
             $wtpl->setVariable("MONTH_COUNT", sizeof($postings));
             $wtpl->parseCurrentBlock();
         }
     }
     $ilCtrl->setParameter($this, "bmn", $this->month);
     $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
     // authors
     if ($this->id_type == self::REPOSITORY_NODE_ID) {
         $authors = array();
         foreach ($this->items as $month => $items) {
             foreach ($items as $item) {
                 if (($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp")) && $item["author"]) {
                     $authors[] = $item["author"];
                 }
             }
         }
         $authors = array_unique($authors);
         if (sizeof($authors) > 1) {
             include_once "Services/User/classes/class.ilUserUtil.php";
             $list = array();
             foreach ($authors as $user_id) {
                 if ($user_id) {
                     $ilCtrl->setParameter($this, "ath", $user_id);
                     $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
                     $ilCtrl->setParameter($this, "ath", "");
                     $name = ilUserUtil::getNamePresentation($user_id, true);
                     $idx = trim(strip_tags($name)) . "///" . $user_id;
                     // #10934
                     $list[$idx] = array($name, $url);
                 }
             }
             ksort($list);
             $wtpl->setVariable("AUTHORS_TITLE", $this->lng->txt("blog_authors"));
             $wtpl->setCurrentBlock("author");
             foreach ($list as $author) {
                 $wtpl->setVariable("TXT_AUTHOR", $author[0]);
                 $wtpl->setVariable("URL_AUTHOR", $author[1]);
                 $wtpl->parseCurrentBlock();
             }
         }
     }
     if (!$a_link_template) {
         // keywords
         $may_edit_keywords = $_GET["blpg"] && $this->mayContribute($_GET["blpg"]) && !$a_link_template && $a_list_cmd != "preview" && $a_list_cmd != "gethtml";
         $keywords = $this->getKeywords($a_show_inactive, $_GET["blpg"]);
         if ($keywords || $may_edit_keywords) {
             $wtpl->setVariable("KEYWORDS_TITLE", $this->lng->txt("blog_keywords"));
             if ($keywords) {
                 $max = max($keywords);
                 include_once "Services/Tagging/classes/class.ilTagging.php";
                 $wtpl->setCurrentBlock("keyword");
                 foreach ($keywords as $keyword => $counter) {
                     $ilCtrl->setParameter($this, "kwd", $keyword);
                     $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
                     $ilCtrl->setParameter($this, "kwd", "");
                     $wtpl->setVariable("TXT_KEYWORD", $keyword);
                     $wtpl->setVariable("SIZE_KEYWORD", ilTagging::calculateFontSize($counter, $max));
                     $wtpl->setVariable("URL_KEYWORD", $url);
                     $wtpl->parseCurrentBlock();
                 }
             } else {
                 $wtpl->setVariable("TXT_NO_KEYWORDS", $this->lng->txt("blog_no_keywords"));
             }
             if ($may_edit_keywords) {
                 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
                 $wtpl->setVariable("URL_EDIT_KEYWORDS", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords"));
                 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", "");
                 $wtpl->setVariable("TXT_EDIT_KEYWORDS", $this->lng->txt("blog_edit_keywords"));
             }
         }
         // rss
         if ($this->object->hasRSS() && $ilSetting->get('enable_global_profiles') && $a_list_cmd == "preview") {
             // #10827
             $blog_id = $this->node_id;
             if ($this->id_type != self::WORKSPACE_NODE_ID) {
                 $blog_id .= "_cll";
             }
             $url = ILIAS_HTTP_PATH . "/feed.php?blog_id=" . $blog_id . "&client_id=" . rawurlencode(CLIENT_ID);
             $wtpl->setCurrentBlock("rss");
             $wtpl->setVariable("URL_RSS", $url);
             $wtpl->setVariable("IMG_RSS", ilUtil::getImagePath("rss.png"));
             $wtpl->parseCurrentBlock();
         }
     }
     return $wtpl->get();
 }
Пример #4
0
 /**
  * Get objects for tag and user
  *
  * @param	int			$a_user_id			User ID
  */
 static function getObjectsForTagAndUser($a_user_id, $a_tag)
 {
     global $ilDB;
     $q = "SELECT * FROM il_tag WHERE " . "user_id = " . $ilDB->quote($a_user_id, "integer") . " AND tag = " . $ilDB->quote($a_tag, "text");
     $set = $ilDB->query($q);
     $objects = array();
     while ($rec = $ilDB->fetchAssoc($set)) {
         if (ilObject::_exists($rec["obj_id"])) {
             if ($rec["sub_obj_type"] == "-") {
                 $rec["sub_obj_type"] = "";
             }
             $objects[] = $rec;
         } else {
             ilTagging::deleteTagsOfObject($rec["obj_id"], $rec["obj_type"], $rec["sub_obj_id"], $rec["sub_obj_type"]);
         }
     }
     return $objects;
 }
Пример #5
0
 /**
  * Build navigation by keywords block 
  *
  * @param string $a_list_cmd
  * @param bool $a_show_inactive
  * @return string
  */
 protected function renderNavigationByKeywords($a_list_cmd = "render", $a_show_inactive = false)
 {
     global $ilCtrl;
     $keywords = $this->getKeywords($a_show_inactive, $_GET["blpg"]);
     if ($keywords) {
         $wtpl = new ilTemplate("tpl.blog_list_navigation_keywords.html", true, true, "Modules/Blog");
         $max = max($keywords);
         include_once "Services/Tagging/classes/class.ilTagging.php";
         $wtpl->setCurrentBlock("keyword");
         foreach ($keywords as $keyword => $counter) {
             $ilCtrl->setParameter($this, "kwd", urlencode($keyword));
             // #15885
             $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
             $ilCtrl->setParameter($this, "kwd", "");
             $wtpl->setVariable("TXT_KEYWORD", $keyword);
             $wtpl->setVariable("CLASS_KEYWORD", ilTagging::getRelevanceClass($counter, $max));
             $wtpl->setVariable("URL_KEYWORD", $url);
             $wtpl->parseCurrentBlock();
         }
         return $wtpl->get();
     }
 }
 /**
  * Remove tasg without access
  */
 function removeTagsWithoutAccess()
 {
     global $ilCtrl, $ilAccess, $ilUser, $lng;
     // get resources
     include_once "./Services/Tagging/classes/class.ilTagging.php";
     $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $_GET["tag"]);
     foreach ($objs as $key => $obj) {
         $ref_ids = ilObject::_getAllReferences($obj["obj_id"]);
         if (count($ref_ids) == 0) {
             $inaccessible = true;
         } else {
             $inaccessible = false;
         }
         foreach ($ref_ids as $ref_id) {
             $type = $obj["obj_type"];
             if ($type == "") {
                 $inaccessible = true;
                 continue;
             }
             if (!$ilAccess->checkAccess("visible", "", $ref_id) && !$ilAccess->checkAccess("read", "", $ref_id) && !$ilAccess->checkAccess("write", "", $ref_id)) {
                 $inaccessible = true;
             }
             if ($inaccessible) {
                 ilTagging::deleteTagOfObjectForUser($ilUser->getId(), $obj["obj_id"], $obj["obj_type"], $obj["sub_obj_id"], $obj["sub_obj_type"], $_GET["tag"]);
             }
         }
     }
     ilUtil::sendSuccess($lng->txt("tag_tags_deleted"), true);
     $ilCtrl->returnToParent($this);
 }
Пример #7
0
 /**
  * Preload common properties
  *
  * @param
  * @return
  */
 static function preloadCommonProperties($a_obj_ids, $a_context)
 {
     global $lng, $ilSetting, $ilUser;
     if ($a_context == self::CONTEXT_REPOSITORY) {
         $active_notes = !$ilSetting->get("disable_notes");
         $active_comments = !$ilSetting->get("disable_comments");
         if ($active_notes || $active_comments) {
             include_once "./Services/Notes/classes/class.ilNote.php";
         }
         if ($active_comments) {
             // needed for action
             self::$comments_activation = ilNote::getRepObjActivation($a_obj_ids);
         }
         // properties are optional
         if ($ilSetting->get('comments_tagging_in_lists')) {
             if ($active_notes || $active_comments) {
                 self::$cnt_notes = ilNote::_countNotesAndCommentsMultiple($a_obj_ids, true);
                 $lng->loadLanguageModule("notes");
             }
             $tags_set = new ilSetting("tags");
             if ($tags_set->get("enable")) {
                 $all_users = $tags_set->get("enable_all_users");
                 include_once "./Services/Tagging/classes/class.ilTagging.php";
                 if (!$ilSetting->get('comments_tagging_in_lists_tags')) {
                     self::$cnt_tags = ilTagging::_countTags($a_obj_ids, $all_users);
                 } else {
                     $tag_user_id = null;
                     if (!$all_users) {
                         $tag_user_id = $ilUser->getId();
                     }
                     self::$tags = ilTagging::_getListTagsForObjects($a_obj_ids, $tag_user_id);
                 }
                 $lng->loadLanguageModule("tagging");
             }
         }
         $lng->loadLanguageModule("rating");
     }
     self::$preload_done = true;
 }
 protected function getSubTreeTags()
 {
     global $tree, $ilUser;
     $sub_ids = array();
     foreach ($tree->getSubTree($tree->getNodeData($this->parent_ref_id)) as $sub_item) {
         if ($sub_item["ref_id"] != $this->parent_ref_id && $sub_item["type"] != "rolf" && !$tree->isDeleted($sub_item["ref_id"])) {
             $sub_ids[$sub_item["obj_id"]] = $sub_item["type"];
         }
     }
     if ($sub_ids) {
         $only_user = $this->enable_all_users ? null : $ilUser->getId();
         include_once "Services/Tagging/classes/class.ilTagging.php";
         return ilTagging::_getTagCloudForObjects($sub_ids, $only_user, $ilUser->getId());
     }
 }
Пример #9
0
 /**
  * Save JS
  */
 function saveJS()
 {
     $input = ilUtil::stripSlashes($_POST["tags"]);
     $input = str_replace(",", " ", $input);
     $itags = explode(" ", $input);
     $tags = array();
     foreach ($itags as $itag) {
         $itag = trim($itag);
         if (!in_array($itag, $tags) && $itag != "") {
             if (!$this->isForbidden($itag)) {
                 $tags[] = $itag;
             }
         }
     }
     ilTagging::writeTagsForUserAndObject($this->obj_id, $this->obj_type, $this->sub_obj_id, $this->sub_obj_type, $this->getUserId(), $tags);
     $this->mess = "mod";
     $this->getHTML();
 }
 /**
  * Preload common properties
  *
  * @param
  * @return
  */
 static function preloadCommonProperties($a_obj_ids)
 {
     global $lng;
     $lng->loadLanguageModule("notes");
     $lng->loadLanguageModule("tagging");
     include_once "./Services/Tagging/classes/class.ilTagging.php";
     self::$cnt_tags = ilTagging::_countTags($a_obj_ids);
     include_once "./Services/Notes/classes/class.ilNote.php";
     self::$cnt_notes = ilNote::_countNotesAndCommentsMultiple($a_obj_ids, true);
     self::$comments_activation = ilNote::getRepObjActivation($a_obj_ids);
     self::$preload_done = true;
 }
 /**
  * List resources for tag
  */
 function showResourcesForTag()
 {
     global $lng, $ilCtrl, $ilUser, $objDefinition;
     $_GET["tag"] = str_replace("-->", "", $_GET["tag"]);
     $tpl = new ilTemplate("tpl.resources_for_tag.html", true, true, "Services/Tagging");
     include_once "./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php";
     $content_block = new ilPDContentBlockGUI();
     $content_block->setColSpan(2);
     $content_block->setTitle(sprintf($lng->txt("tagging_resources_for_tag"), "<i>" . $_GET["tag"] . "</i>"));
     $content_block->setImage(ilUtil::getImagePath("icon_tag.png"));
     $content_block->addHeaderCommand($ilCtrl->getParentReturn($this), $lng->txt("selected_items_back"));
     // get resources
     include_once "./Services/Tagging/classes/class.ilTagging.php";
     $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $_GET["tag"]);
     foreach ($objs as $key => $obj) {
         $ref_ids = ilObject::_getAllReferences($obj["obj_id"]);
         foreach ($ref_ids as $ref_id) {
             $type = $obj["obj_type"];
             if ($type == "") {
                 continue;
             }
             // get list gui class for each object type
             if (empty($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();
                 $this->item_list_gui[$type]->enableDelete(false);
                 $this->item_list_gui[$type]->enablePath(true);
                 $this->item_list_gui[$type]->enableCut(false);
                 $this->item_list_gui[$type]->enableCopy(false);
                 $this->item_list_gui[$type]->enableSubscribe(false);
                 $this->item_list_gui[$type]->enablePayment(false);
                 $this->item_list_gui[$type]->enableLink(false);
                 $this->item_list_gui[$type]->enableIcon(true);
             }
             $html = $this->item_list_gui[$type]->getListItemHTML($ref_id, $obj["obj_id"], ilObject::_lookupTitle($obj["obj_id"]), ilObject::_lookupDescription($obj["obj_id"]));
             if ($html != "") {
                 $css = $css != "tblrow1" ? "tblrow1" : "tblrow2";
                 $tpl->setCurrentBlock("res_row");
                 $tpl->setVariable("ROWCLASS", $css);
                 $tpl->setVariable("RESOURCE_HTML", $html);
                 $tpl->setVariable("ALT_TYPE", $lng->txt("obj_" . $type));
                 $tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_" . $type . ".png"));
                 $tpl->parseCurrentBlock();
             }
         }
     }
     $content_block->setContent($tpl->get());
     //$content_block->setContent("test");
     return $content_block->getHTML();
 }