die; } if ($displayer->get_hash() != $hash) { http_response_code(404); die; } # Grab the media_work's associated group if it has one $es = new entity_selector(); $es->add_type(id_of('group_type')); $es->add_right_relationship($media_work->id(), relationship_id_of('av_restricted_to_group')); $group = current($es->run_one()); $extension = $media_file->get_value('av_type') == 'Video' ? 'mp4' : 'mp3'; # If the user doesn't have access to the media work, header to the "No Access" url $mwh = new media_work_helper($media_work); if (!$mwh->user_has_access_to_media()) { $username = reason_require_http_authentication(); if (!$mwh->user_has_access_to_media($username)) { // header to the access denied media header('Location: http://' . HTTP_HOST_NAME . REASON_HTTP_BASE_PATH . 'modules/av/no_access_message.' . $extension); die; } } # If we make it here, the podcast is safe to provide $file_url = $media_file->get_value('url'); // ask the shim if we need to do a url hack to allow iTunes to import the file $shim = MediaWorkFactory::shim($media_work); if ($shim) { if ($shim->requires_extension_for_podcast()) { $extra_extension = '/a.' . $extension; } else { $extra_extension = '';
function run($send_header = true) { $this->get_site_id(); if ($page = $this->_get_page()) { if ($groups = $this->get_page_restriction_groups($page, $this->site)) { foreach ($groups as $group) { $gh = new group_helper(); $gh->set_group_by_entity($group); if ($gh->requires_login()) { $username = reason_require_http_authentication(); if (!$gh->is_username_member_of_group($username)) { $this->_send_unauthorized_output($send_header); die; } } } } } else { $pages = $this->get_sitewide_media_pages($this->site); if (!empty($pages)) { $restricted_pages = array(); $page_group_helpers = array(); foreach ($pages as $page) { if ($groups = $this->get_page_restriction_groups($page, $this->site)) { foreach ($groups as $group) { $gh = new group_helper(); $gh->set_group_by_entity($group); if ($gh->requires_login()) { $restricted_pages[$page->id()] = $page; if (!isset($page_group_helpers[$page->id()])) { $page_group_helpers[$page->id()] = array(); } $page_group_helpers[$page->id()][] = $gh; } } } } if (count($restricted_pages) >= count($pages)) { $username = reason_require_http_authentication(); $access_ok = false; foreach ($restricted_pages as $page) { $is_member = true; foreach ($page_group_helpers[$page->id()] as $gh) { if (!$gh->is_username_member_of_group($username)) { $is_member = false; break; } } if ($is_member) { $access_ok = true; break; } } if (!$access_ok) { $this->_send_unauthorized_output($send_header); die; } } } else { $this->_send_unauthorized_output($send_header); die; } } parent::run($send_header); }