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

Add loginas support to cron_setup_user

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 3.1.2
    • Tasks
    • MOODLE_31_STABLE

      I'm adding a patch to MDL-54751 to set the proper user when executing a adhoc task in background. I send both realuser and userid, cron_setup_user could accept a $realuser param and do something like what I'm pasting below.

      This is the logic I am adding to course_delete_modules task should be replaced by cron_setup_user($user, $context, $realuser) (or something similar) if we end up working on this.

              if ($this->get_custom_data()->userid !== $this->get_custom_data()->realuserid) {
                  $realuser = $DB->get_record('user', array('id' => $this->get_custom_data()->realuserid));
                  cron_setup_user($realuser);
                  \core\session\manager::loginas($this->get_custom_data()->userid, \context_system::instance(), false);
              } else {
                  $user = $DB->get_record('user', array('id' => $this->get_custom_data()->userid));
                  cron_setup_user($user);
              }
      

            Unassigned Unassigned
            dmonllao David Monllaó
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.