コード例 #1
0
 /**
  * checks wether a user may invoke a command or not
  * (this method is called by ilAccessHandler::checkAccess)
  *
  * @param	string		$a_cmd		command (not permission!)
  * @param	string		$a_permission	permission
  * @param	int			$a_ref_id	reference id
  * @param	int			$a_obj_id	object id
  * @param	int			$a_user_id	user id (if not provided, current user is taken)
  *
  * @return	boolean		true, if everything is ok
  */
 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
 {
     global $ilUser, $lng, $rbacsystem, $ilAccess;
     if ($a_user_id == "") {
         $a_user_id = $ilUser->getId();
     }
     switch ($a_cmd) {
         case "listItems":
             if (!ilObjMediaCastAccess::_lookupOnline($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
                 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
                 return false;
             }
             break;
             // for permission query feature
         // for permission query feature
         case "infoScreen":
             if (!ilObjMediaCastAccess::_lookupOnline($a_obj_id)) {
                 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
             } else {
                 $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("online"));
             }
             break;
     }
     switch ($a_permission) {
         case "read":
         case "visible":
             if (!ilObjMediaCastAccess::_lookupOnline($a_obj_id) && !$rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id)) {
                 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
                 return false;
             }
             break;
     }
     return true;
 }
コード例 #2
0
 /**
  * Get item properties
  *
  * @return	array		array of property arrays:
  *						"alert" (boolean) => display as an alert property (usually in red)
  *						"property" (string) => property name
  *						"value" (string) => property value
  */
 function getProperties()
 {
     global $lng, $ilUser;
     $props = array();
     include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
     if (!ilObjMediaCastAccess::_lookupOnline($this->obj_id)) {
         $props[] = array("alert" => true, "property" => $lng->txt("status"), "value" => $lng->txt("offline"));
     }
     return $props;
 }
コード例 #3
0
 function ilObjectFeedWriter($a_ref_id, $a_userid = false, $a_purpose = false)
 {
     global $ilSetting, $lng;
     parent::ilFeedWriter();
     if ($a_ref_id <= 0) {
         return;
     }
     include_once "./Services/Block/classes/class.ilBlockSetting.php";
     $news_set = new ilSetting("news");
     if (!$news_set->get("enable_rss_for_internal")) {
         return;
     }
     $obj_id = ilObject::_lookupObjId($a_ref_id);
     $obj_type = ilObject::_lookupType($obj_id);
     $obj_title = ilObject::_lookupTitle($obj_id);
     if (!ilBlockSetting::_lookup("news", "public_feed", 0, $obj_id)) {
         return;
     }
     if ($ilSetting->get('short_inst_name') != "") {
         $this->setChannelTitle($ilSetting->get('short_inst_name') . " - " . $this->prepareStr($loc . $obj_title));
     } else {
         $this->setChannelTitle("ILIAS" . " - " . $this->prepareStr($loc . $obj_title . ($a_purpose ? " - " . $a_purpose : "")));
     }
     $this->setChannelAbout(ILIAS_HTTP_PATH);
     $this->setChannelLink(ILIAS_HTTP_PATH);
     // not nice, to do: general solution
     if ($obj_type == "mcst") {
         include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
         if (!ilObjMediaCastAccess::_lookupOnline($obj_id)) {
             $lng->loadLanguageModule("mcst");
             $feed_item = new ilFeedItem();
             $feed_item->setTitle($lng->txt("mcst_media_cast_not_online"));
             $feed_item->setDescription($lng->txt("mcst_media_cast_not_online_text"));
             $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"]);
             $this->addItem($feed_item);
             return;
         }
     }
     include_once "./Services/Locator/classes/class.ilLocatorGUI.php";
     $cont_loc = new ilLocatorGUI();
     $cont_loc->addContextItems($a_ref_id, true);
     $cont_loc->setTextOnly(true);
     $loc = $cont_loc->getTextVersion();
     if (trim($loc) != "") {
         $loc = " [" . $loc . "] ";
     }
     $rss_period = ilNewsItem::_lookupRSSPeriod();
     ilNewsItem::setPrivateFeedId($a_userid);
     $news_item = new ilNewsItem();
     $news_item->setContextObjId($obj_id);
     $news_item->setContextObjType($obj_type);
     $items = $news_item->getNewsForRefId($a_ref_id, true, false, $rss_period, true);
     if ($a_purpose) {
         include_once "./Services/MediaObjects/classes/class.ilMediaItem.php";
     }
     $i = 0;
     foreach ($items as $item) {
         $i++;
         if ($a_purpose != false && $obj_type == "mcst") {
             $mob = ilMediaItem::_getMediaItemsOfMObId($item[mob_id], $a_purpose);
             if ($mob == false) {
                 continue;
             }
         }
         $obj_title = ilObject::_lookupTitle($item["context_obj_id"]);
         $feed_item = new ilFeedItem();
         $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]);
         // path
         $cont_loc = new ilLocatorGUI();
         $cont_loc->addContextItems($item["ref_id"], true, $a_ref_id);
         $cont_loc->setTextOnly(true);
         $loc = $cont_loc->getHTML();
         if (trim($loc) != "") {
             $loc = "[" . $loc . "]";
         }
         if ($news_set->get("rss_title_format") == "news_obj") {
             $sep = trim($this->prepareStr($loc)) == "" ? "" : " ";
             $feed_item->setTitle($this->prepareStr($title) . " (" . $this->prepareStr($loc) . $sep . $this->prepareStr($obj_title) . ")");
         } else {
             $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) . ": " . $this->prepareStr($title));
         }
         $feed_item->setDescription($this->prepareStr(nl2br(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]))));
         // lm hack, not nice
         if (in_array($item["context_obj_type"], array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg" && $item["context_sub_obj_id"] > 0) {
             $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"]);
         } else {
             if ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg" && $item["context_sub_obj_id"] > 0) {
                 include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                 $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
                 $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $wptitle);
             } else {
                 if (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos" && $item["context_sub_obj_id"] > 0) {
                     // frm hack, not nice
                     include_once "./Modules/Forum/classes/class.ilObjForumAccess.php";
                     $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
                     if ($thread_id > 0) {
                         $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]);
                     } else {
                         $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
                     }
                 } else {
                     $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
                     //echo "<br>".ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
                     //					"&amp;target=".$item["context_obj_type"]."_".$item["ref_id"];
                 }
             }
         }
         $feed_item->setAbout($feed_item->getLink() . "&amp;il_about_feed=" . $item["id"]);
         $feed_item->setDate($item["creation_date"]);
         // Enclosure
         if ($item["content_type"] == NEWS_AUDIO && $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"])) {
             $go_on = true;
             if ($obj_type == "mcst") {
                 include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
                 if (!ilObjMediaCastAccess::_lookupPublicFiles($obj_id)) {
                     $go_on = false;
                 }
             }
             if ($go_on) {
                 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
                 $url = ilObjMediaObject::_lookupItemPath($item["mob_id"], true, true, $mob["purpose"]);
                 $file = ilObjMediaObject::_lookupItemPath($item["mob_id"], false, false, $mob["purpose"]);
                 if (is_file($file)) {
                     $size = filesize($file);
                 }
                 $feed_item->setEnclosureUrl($url);
                 $feed_item->setEnclosureType(isset($mob["format"]) ? $mob["format"] : "audio/mpeg");
                 $feed_item->setEnclosureLength($size);
             }
         }
         $this->addItem($feed_item);
     }
 }
コード例 #4
0
 function ilUserFeedWriter($a_user_id, $a_hash, $privFeed = false)
 {
     global $ilSetting, $lng;
     parent::ilFeedWriter();
     //$lng->loadLanguageModule("news");
     if ($a_user_id == "" || $a_hash == "") {
         return;
     }
     $news_set = new ilSetting("news");
     if (!$news_set->get("enable_rss_for_internal")) {
         return;
     }
     include_once "Services/User/classes/class.ilObjUser.php";
     $hash = ilObjUser::_lookupFeedHash($a_user_id);
     include_once "./Services/News/classes/class.ilNewsItem.php";
     $rss_period = ilNewsItem::_lookupRSSPeriod();
     if ($a_hash == $hash) {
         if ($privFeed) {
             //ilNewsItem::setPrivateFeedId($a_user_id);
             $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, false, true, $rss_period);
         } else {
             $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, true, true, $rss_period);
         }
         if ($ilSetting->get('short_inst_name') != "") {
             $this->setChannelTitle($ilSetting->get('short_inst_name'));
         } else {
             $this->setChannelTitle("ILIAS");
         }
         $this->setChannelAbout(ILIAS_HTTP_PATH);
         $this->setChannelLink(ILIAS_HTTP_PATH);
         //$this->setChannelDescription("ILIAS Channel Description");
         $i = 0;
         foreach ($items as $item) {
             $obj_id = ilObject::_lookupObjId($item["ref_id"]);
             $obj_type = ilObject::_lookupType($obj_id);
             $obj_title = ilObject::_lookupTitle($obj_id);
             // not nice, to do: general solution
             if ($obj_type == "mcst") {
                 include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
                 if (!ilObjMediaCastAccess::_lookupOnline($obj_id)) {
                     continue;
                 }
             }
             $i++;
             $feed_item = new ilFeedItem();
             $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]);
             // path
             $loc = $this->getContextPath($item["ref_id"]);
             // title
             if ($news_set->get("rss_title_format") == "news_obj") {
                 $feed_item->setTitle($this->prepareStr(str_replace("<br />", " ", $title)) . " (" . $this->prepareStr($loc) . " " . $this->prepareStr($obj_title) . ")");
             } else {
                 $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) . ": " . $this->prepareStr(str_replace("<br />", " ", $title)));
             }
             // description
             $content = $this->prepareStr(nl2br(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"])));
             $feed_item->setDescription($content);
             // lm page hack, not nice
             if (in_array($item["context_obj_type"], array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg" && $item["context_sub_obj_id"] > 0) {
                 $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"]);
             } else {
                 if ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg" && $item["context_sub_obj_id"] > 0) {
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
                     $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . urlencode($wptitle));
                     // #14629
                 } else {
                     if (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos" && $item["context_sub_obj_id"] > 0) {
                         // frm hack, not nice
                         include_once "./Modules/Forum/classes/class.ilObjForumAccess.php";
                         $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
                         if ($thread_id > 0) {
                             $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]);
                         } else {
                             $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
                         }
                     } else {
                         $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
                     }
                 }
             }
             $feed_item->setAbout($feed_item->getLink() . "&amp;il_about_feed=" . $item["id"]);
             $feed_item->setDate($item["creation_date"]);
             $this->addItem($feed_item);
         }
     }
 }
コード例 #5
0
 /**
  * 
  *
  * @param
  * @return
  */
 function checkAccessMobUsage($usage, $oid)
 {
     /**
      * @var $ilObjDataCache ilObjectDataCache
      */
     global $ilObjDataCache;
     switch ($usage['type']) {
         case 'lm:pg':
             if ($oid > 0) {
                 if ($this->checkAccessLM($oid, 'lm', $usage['id'])) {
                     return true;
                 }
             }
             break;
         case 'news':
             // media objects in news (media casts)
             include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
             include_once "./Services/News/classes/class.ilNewsItem.php";
             if ($this->checkAccessObject($oid, 'mcst')) {
                 return true;
             } elseif (ilObjMediaCastAccess::_lookupPublicFiles($oid) && ilNewsItem::_lookupVisibility($usage["id"]) == NEWS_PUBLIC) {
                 return true;
             }
             break;
         case 'dcl:html':
             include_once "./Modules/DataCollection/classes/class.ilObjDataCollectionAccess.php";
             include_once "./Services/Object/classes/class.ilObject2.php";
             $ref_ids = ilObject2::_getAllReferences($oid);
             foreach ($ref_ids as $ref_id) {
                 if (ilObjDataCollectionAccess::_checkAccess("view", "read", $ref_id, $oid)) {
                     return true;
                 }
             }
             break;
         case 'frm~:html':
             // $oid = userid
             foreach ($this->check_users as $user_id) {
                 if ($ilObjDataCache->lookupType($oid) == 'usr' && $oid == $user_id) {
                     return true;
                 }
             }
             break;
         case 'qpl:pg':
         case 'qpl:html':
             // test questions
             if ($this->checkAccessTestQuestion($oid, $usage['id'])) {
                 return true;
             }
             break;
         case 'gdf:pg':
             // special check for glossary terms
             if ($this->checkAccessGlossaryTerm($oid, $usage['id'])) {
                 return true;
             }
             break;
         case 'sahs:pg':
             // check for scorm pages
             if ($this->checkAccessObject($oid, 'sahs')) {
                 return true;
             }
             break;
         case 'prtf:pg':
             // special check for portfolio pages
             if ($this->checkAccessPortfolioPage($oid, $usage['id'])) {
                 return true;
             }
             break;
         case 'blp:pg':
             // special check for blog pages
             if ($this->checkAccessBlogPage($oid, $usage['id'])) {
                 return true;
             }
             break;
         default:
             // standard object check
             if ($this->checkAccessObject($oid)) {
                 return true;
             }
             break;
     }
     return false;
 }
コード例 #6
0
 /**
  * 
  *
  * @param
  * @return
  */
 function checkAccessMobUsage($usage, $oid)
 {
     /**
      * @var $ilObjDataCache ilObjectDataCache
      */
     global $ilObjDataCache;
     switch ($usage['type']) {
         case 'lm:pg':
             if ($this->checkAccessObject($oid, 'lm')) {
                 return true;
             }
             /* as $usage['id'] (== page) is not processed anymore, we can use standard
             			if ($oid > 0)
             			{
             				if ($this->checkAccessLM($oid, 'lm', $usage['id']))
             				{
             					return true;
             				}
             			}				 
             			*/
             break;
         case 'news':
             // media objects in news (media casts)
             include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
             include_once "./Services/News/classes/class.ilNewsItem.php";
             if ($this->checkAccessObject($oid, 'mcst')) {
                 return true;
             } elseif (ilObjMediaCastAccess::_lookupPublicFiles($oid) && ilNewsItem::_lookupVisibility($usage["id"]) == NEWS_PUBLIC) {
                 return true;
             }
             break;
             /* see default
                         case 'dcl:html':
                             include_once("./Modules/DataCollection/classes/class.ilObjDataCollectionAccess.php");
                             include_once("./Services/Object/classes/class.ilObject2.php");
                             $ref_ids = ilObject2::_getAllReferences($oid);
                             foreach($ref_ids as $ref_id)
                                 if(ilObjDataCollectionAccess::_checkAccess("view", "read", $ref_id, $oid))
                                     return true;
                             break;
             			*/
         /* see default
                     case 'dcl:html':
                         include_once("./Modules/DataCollection/classes/class.ilObjDataCollectionAccess.php");
                         include_once("./Services/Object/classes/class.ilObject2.php");
                         $ref_ids = ilObject2::_getAllReferences($oid);
                         foreach($ref_ids as $ref_id)
                             if(ilObjDataCollectionAccess::_checkAccess("view", "read", $ref_id, $oid))
                                 return true;
                         break;
         			*/
         case 'frm~:html':
         case 'exca~:html':
             // $oid = userid
             foreach ($this->check_users as $user_id) {
                 if ($ilObjDataCache->lookupType($oid) == 'usr' && $oid == $user_id) {
                     return true;
                 }
             }
             break;
         case 'qpl:pg':
         case 'qpl:html':
             // test questions
             if ($this->checkAccessTestQuestion($oid, $usage['id'])) {
                 return true;
             }
             break;
         case 'gdf:pg':
             // special check for glossary terms
             if ($this->checkAccessGlossaryTerm($oid, $usage['id'])) {
                 return true;
             }
             break;
         case 'sahs:pg':
             // check for scorm pages
             if ($this->checkAccessObject($oid, 'sahs')) {
                 return true;
             }
             break;
         case 'prtf:pg':
             // special check for portfolio pages
             if ($this->checkAccessPortfolioPage($oid, $usage['id'])) {
                 return true;
             }
             break;
         case 'blp:pg':
             // special check for blog pages
             if ($this->checkAccessBlogPage($oid, $usage['id'])) {
                 return true;
             }
             break;
         case 'lobj:pg':
             // special check for learning objective pages
             if ($this->checkAccessLearningObjectivePage($oid, $usage['id'])) {
                 return true;
             }
             break;
         case 'impr:pg':
             include_once 'Services/Imprint/classes/class.ilImprint.php';
             return ilImprint::isActive() || $this->checkAccessObject(SYSTEM_FOLDER_ID, 'adm');
         case 'cstr:pg':
         default:
             // standard object check
             if ($this->checkAccessObject($oid)) {
                 return true;
             }
             break;
     }
     return false;
 }
コード例 #7
0
 /**
  * Gets the disk usage of the object in bytes.
  *
  * @access	public
  * @return	integer		the disk usage in bytes
  */
 function getDiskUsage()
 {
     require_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
     return ilObjMediaCastAccess::_lookupDiskUsage($this->id);
 }