Comments (5)
cool - that should make it easier for others to review too..
I'd probably simplify it to a single line myself:
if (!empty($custompage->accesslevel)) {
but that's just me being picky... :-)
from moodle-local_pages.
I have updated the readme in this Repo and will update the content in Moodle to Make this clear.
Page access is controlled when the page is created, capabilites can used to restrict/allow access at each page level.
from moodle-local_pages.
Cool - It looked like you could just pass a different id to the index script and load every page you wanted to. Ideally it would be good if there was some form of check in the top of index.php to see if the page is public or not. If not public then use require login and capability checks?
from moodle-local_pages.
// Function throws exception if query string is not provided
$pageid = required_param('id', PARAM_INT);
// Can do this. Print your own custom message.
if (!($page = $DB->get_record('local_pages_page', ['id' => $pageid])) {
// Print some custom error message using a lang string.
print_error('someidentifier', 'local_pages');
}
// Or this. Use the function get record to throw exception if record don't exist
$page = $DB->get_record('local_pages_page', ['id' => $pageid], '*', MUST_EXIST);
// Use whatever property indicates that the page is public or not
if (!$page->ispublic) {
require_login();
}
from moodle-local_pages.
Have updated the page index to passback if a cability is needed - require login is required if the page required a capability.
// Set the page layout.
$custompage = custompage::load($pageid);
// Check if the page has an access level requirement.
$accesslevel = $custompage->accesslevel;
if ($accesslevel != '') {
require_login();
}
An id is not required to load a page, if the site supports htaccess files, the page can be loaded by a url as well - making for cleaner urls to load pages
from moodle-local_pages.
Related Issues (20)
- Typo in the short description at moodle.org/plugins HOT 2
- Description could help more with the first steps HOT 1
- In moodle HOT 1
- Boost Navigation Block HOT 1
- Child pages cannot be viewed if parent is deleted HOT 1
- Travis CI Moodle 3.5+ HOT 1
- Orphaned Boost Navbar item HOT 2
- Translation HOT 1
- Feature Request: Capabilities HOT 1
- Translation #2 HOT 1
- Missing hideIf in construct HOT 1
- Getting undefined method hideIf HOT 1
- Invalid page layout specified HOT 1
- Invalid get_string() identifier: 'cachedef_sent' HOT 1
- Crumble path HOT 1
- Form pages don't render for Moodle 3.9 HOT 9
- Error when using mssql and adding a new page
- textarea message x local page
- Error on moodle 3.11 (php 8) HOT 2
- Required parameter $gnav follows optional parameter $parent HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moodle-local_pages.