Code Monkey home page Code Monkey logo

Comments (5)

danmarsden avatar danmarsden commented on August 14, 2024 1

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.

digitalskill avatar digitalskill commented on August 14, 2024

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.

danmarsden avatar danmarsden commented on August 14, 2024

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.

emyb2 avatar emyb2 commented on August 14, 2024
// 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.

digitalskill avatar digitalskill commented on August 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.