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

Enable contexts to be added without SQL

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Deferred
    • Icon: Minor Minor
    • None
    • 3.4.2
    • Privacy
    • None
    • Privacy Sprint 1

      In the get_contexts_for_userid() provider method, it would be useful to be able to add known contexts directly when a plugin stores all its data at that context. The only two use cases for this I can think of are the system context and the user context, so it may not be worth making set_contextids() public, but a couple of helper methods like add_system_context() and add_user_context($userid) would be useful.

      At the moment you have to do something like this, which seems absurd:

          public static function get_contexts_for_userid(int $userid): contextlist {
              $result = new contextlist('local_someplugin');
              $result->add_from_sql('SELECT id FROM {context} WHERE id = ?', [\context_system::instance()->id]);
              return $result;
          }
      

            markn Mark Nelson
            maherne Michael Aherne
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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