Moodle
  1. Moodle
  2. MDL-39209

Course badges can still be accessed though URL when course badges setting is disabled

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.5
    • Component/s: Badges
    • Labels:
    • Testing Instructions:
      Hide

      1. The easiest way to test is to open the pages related to course badges (such as, badges/index.php, badges/view.php, badges/newbadge.php, badges/edit.php, badges/criteria.php, badges/overview.php, badges/recipients.php) .
      2. In site administration > badges settings, turn off course badges.
      3. Try reloading open pages.
      4. Should get an error that course badges are not currently enabled.

      Show
      1. The easiest way to test is to open the pages related to course badges (such as, badges/index.php, badges/view.php, badges/newbadge.php, badges/edit.php, badges/criteria.php, badges/overview.php, badges/recipients.php) . 2. In site administration > badges settings, turn off course badges. 3. Try reloading open pages. 4. Should get an error that course badges are not currently enabled.
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull Master Branch:
      MDL-39209_master
    • Rank:
      49817

      Description

      Need to add checks for empty($CFG->badges_allowcoursebadges) on the front end pages.

        Activity

        Hide
        Michael de Raadt added a comment -

        Go for it.

        Show
        Michael de Raadt added a comment - Go for it.
        Hide
        Mark Nelson added a comment -

        Hi Yuliya,

        Patch looks good to me. Just a quick note -

        if (empty($CFG->badges_allowcoursebadges)) {
            print_error('coursebadgesdisabled', 'badges');
        } else {
            require_login($badge->courseid);
            $navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
        }
        

        The else is not necessary in this statement, as the print_error will throw a moodle_exception and the rest of the code will not be executed.

        Show
        Mark Nelson added a comment - Hi Yuliya, Patch looks good to me. Just a quick note - if (empty($CFG->badges_allowcoursebadges)) { print_error('coursebadgesdisabled', 'badges'); } else { require_login($badge->courseid); $navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid)); } The else is not necessary in this statement, as the print_error will throw a moodle_exception and the rest of the code will not be executed.
        Hide
        Yuliya Bozhko added a comment -

        Thanks Mark!

        I applied suggested changes.

        Yuliya

        Show
        Yuliya Bozhko added a comment - Thanks Mark! I applied suggested changes. Yuliya
        Hide
        Mark Nelson added a comment -

        HI Yuliya, thanks for that. I am submitting to integration.

        Show
        Mark Nelson added a comment - HI Yuliya, thanks for that. I am submitting to integration.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
        Hide
        Damyon Wiese added a comment -

        The change looks ok to me - phpunit passes - just waiting for behat.

        Show
        Damyon Wiese added a comment - The change looks ok to me - phpunit passes - just waiting for behat.
        Hide
        Damyon Wiese added a comment -

        behat passed!

        Show
        Damyon Wiese added a comment - behat passed!
        Hide
        Damyon Wiese added a comment -

        Thanks Yuliya,

        This change has been integrated to master. Off to testing now...

        Show
        Damyon Wiese added a comment - Thanks Yuliya, This change has been integrated to master. Off to testing now...
        Hide
        Rajesh Taneja added a comment -

        Thanks for fixing this Yuliya,

        I can see error message for course badges, when cfg is disabled.

        Show
        Rajesh Taneja added a comment - Thanks for fixing this Yuliya, I can see error message for course badges, when cfg is disabled.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Just In Time® for stable releases, thanks!

        Closing as fixed, ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Just In Time® for stable releases, thanks! Closing as fixed, ciao

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: