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

Assignment unable to update event

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Assignment (2.2), Calendar
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      Attempting to update the time of an assignment, fails when trying to update the calendar event, with the following error:

      Sorry, but you do not currently have permissions to do that ({$a})

      More information about this error

      Stack trace:
      line 310 of /lib/setuplib.php: moodle_exception thrown
      line 2014 of /calendar/lib.php: call to print_error()
      line 520 of /mod/assignment/lib.php: call to calendar_event->update()
      line 2173 of /mod/assignment/lib.php: call to assignment_base->update_instance()
      line 330 of /course/modedit.php: call to assignment_update_instance()

      Output buffer: Notice: Undefined property: object::$groupid in /home/davo/public_html/moodle20/calendar/lib.php on line 1397 Notice: Undefined property: object::$courseid in /home/davo/public_html/moodle20/calendar/lib.php on line 1406 Notice: Undefined property: object::$userid in /home/davo/public_html/moodle20/calendar/lib.php on line 1410

      As far as I can tell, what is going wrong is that the function 'update_instance' in /mod/assignment/lib.php calls $calendarevent->update($event), where $event is a partial event data object (lacking courseid and groupid amongst other settings). The 'update' function in /calendar/lib.php then overwrites the calendar event's internal data with this partial object on the first line: '$this->properties = (object)$data;' and then uses this newly overwritten object (without the courseid / groupid data), to see if the user has permission to update the calendar ('if(!calendar_edit_event_allowed($this->properties)) {').

      This will usually fail (unless the user has the capability 'moodle/calendar:manageentries' site wide).

      I'm not sure which side of the calendar API is incorrect (the assignment passing a partial object to 'update', or the calendar assuming it is a complete data object), but I'm guessing one of them is wrong (unless I've completely misunderstood the code).

        Attachments

          Activity

            People

            Assignee:
            samhemelryk Sam Hemelryk
            Reporter:
            davosmith Davo Smith
            Tester:
            Nobody
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Andrew Nicols, Jun Pataleta, 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:
              24/Nov/10