Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-4282

WS core_user_update_users should allow to update own profile

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 2.4.3
    • None
    • MOODLE_24_STABLE

      Seb service function "core_user_update_users" is restricted to "moodle/user:update" permission. It should check "moodle/user:editownprofile" if editing own profile.

      Here is solution, what i did in user/externallib.php:

      public static function update_users($users) {
      global $CFG, $DB, $USER;
      require_once($CFG->dirroot."/user/lib.php");
      require_once($CFG->dirroot."/user/profile/lib.php"); //required for customfields related function

      $params = self::validate_parameters(self::update_users_parameters(), array('users'=>$users));

      $transaction = $DB->start_delegated_transaction();

      $context = context_system::instance();
      foreach ($params['users'] as $user) {

      // Ensure the current user is allowed to run this function
      // if editing own profile
      if ($user['id'] == $USER->id)

      { require_capability('moodle/user:editownprofile', $context); }

      else

      { require_capability('moodle/user:update', $context); }

      self::validate_context($context);

      user_update_user($user);

            timhunt Tim Hunt
            andrewvaca Ondřej Vacek
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

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