Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-21055

unable to add sub category by using a user with Admin role in parent category

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a bug
    • Affects Version/s: 1.9.2
    • Fix Version/s: 1.9.4
    • Component/s: Administration
    • Labels:
      None
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      i set a user to be an Admin (role) on some category and tried to use
      that user to add new sub categories under that category... and was not able to.

      i was keep getting the "add new category" page filled with what i defined previously
      but i could not submit it.

      to solve this issue i had to:

      open course/editcategory_form.php and change line 28 from:
      $mform->addElement('hidden', 'id', null);
      to:
      $mform->addElement('hidden', 'id', $this->_customdata['id']);

      and open course/editcategory.php and change line 69 from :
      if (empty($category) && has_capability('moodle/category:create', $context)) { // Create a new category
      to:
      if (empty($category) && has_capability('moodle/category:create', get_context_instance(CONTEXT_COURSECAT, $id,$USER))) { // Create a new category

      and line 75 from :
      redirect('index.php?categoryedit=on');
      to:
      redirect('category.php?id='.$id.'&categoryedit=on');

      it was not passing the category id to the form and it was not checking
      the capabilities against the specific user in that specific category.
      as far as i can tell.

      now it works fine

        Attachments

          Activity

            People

            • Assignee:
              poltawski Dan Poltawski
              Reporter:
              nadavkav Nadav Kavalerchik
              Participants:
              Component watchers:
              Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                28/Jan/09