original_string: public static function mark_all_notifications_as_read($useridto, $useridfrom) {
          global $USER;
  
          $params = self::validate_parameters(
              self::mark_all_notifications_as_read_parameters(),
              array(
                  'useridto' => $useridto,
                  'useridfrom' => $useridfrom,
              )
          );
  
          $context = context_system::instance();
          self::validate_context($context);
  
          $useridto = $params['useridto'];
          $useridfrom = $params['useridfrom'];
  
          if (!empty($useridto)) {
              if (core_user::is_real_user($useridto)) {
                  $userto = core_user::get_user($useridto, '*', MUST_EXIST);
              } else {
                  throw new moodle_exception('invaliduser');
              }
          }
  
          if (!empty($useridfrom)) {
              // We use get_user here because the from user can be the noreply or support user.
              $userfrom = core_user::get_user($useridfrom, '*', MUST_EXIST);
          }
  
          // Check if the current user is the sender/receiver or just a privileged user.
          if ($useridto != $USER->id and $useridfrom != $USER->id and
              // The deleteanymessage cap seems more reasonable here than readallmessages.
               !has_capability('moodle/site:deleteanymessage', $context)) {
              throw new moodle_exception('accessdenied', 'admin');
          }
  
          \core_message\api::mark_all_notifications_as_read($useridto, $useridfrom);
  
          return true;
      }
code: public static function mark_all_notifications_as_read($useridto, $useridfrom) {
          global $USER;
  
          $params = self::validate_parameters(
              self::mark_all_notifications_as_read_parameters(),
              array(
                  'useridto' => $useridto,
                  'useridfrom' => $useridfrom,
              )
          );
  
          $context = context_system::instance();
          self::validate_context($context);
  
          $useridto = $params['useridto'];
          $useridfrom = $params['useridfrom'];
  
          if (!empty($useridto)) {
              if (core_user::is_real_user($useridto)) {
                  $userto = core_user::get_user($useridto, '*', MUST_EXIST);
              } else {
                  throw new moodle_exception('invaliduser');
              }
          }
  
          if (!empty($useridfrom)) {
              // We use get_user here because the from user can be the noreply or support user.
              $userfrom = core_user::get_user($useridfrom, '*', MUST_EXIST);
          }
  
          // Check if the current user is the sender/receiver or just a privileged user.
          if ($useridto != $USER->id and $useridfrom != $USER->id and
              // The deleteanymessage cap seems more reasonable here than readallmessages.
               !has_capability('moodle/site:deleteanymessage', $context)) {
              throw new moodle_exception('accessdenied', 'admin');
          }
  
          \core_message\api::mark_all_notifications_as_read($useridto, $useridfrom);
  
          return true;
      }
code_tokens: public static function mark_all_notifications_as_read ( $ useridto , $ useridfrom ) { global $ USER ; $ params = self :: validate_parameters ( self :: mark_all_notifications_as_read_parameters ( ) , array ( 'useridto' => $ useridto , 'useridfrom' => $ useridfrom , ) ) ; $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; $ useridto = $ params [ 'useridto' ] ; $ useridfrom = $ params [ 'useridfrom' ] ; if ( ! empty ( $ useridto ) ) { if ( core_user :: is_real_user ( $ useridto ) ) { $ userto = core_user :: get_user ( $ useridto , '*' , MUST_EXIST ) ; } else { throw new moodle_exception ( 'invaliduser' ) ; } } if ( ! empty ( $ useridfrom ) ) { // We use get_user here because the from user can be the noreply or support user. $ userfrom = core_user :: get_user ( $ useridfrom , '*' , MUST_EXIST ) ; } // Check if the current user is the sender/receiver or just a privileged user. if ( $ useridto != $ USER -> id and $ useridfrom != $ USER -> id and // The deleteanymessage cap seems more reasonable here than readallmessages. ! has_capability ( 'moodle/site:deleteanymessage' , $ context ) ) { throw new moodle_exception ( 'accessdenied' , 'admin' ) ; } \ core_message \ api :: mark_all_notifications_as_read ( $ useridto , $ useridfrom ) ; return true ; }
docstring: Mark all notifications as read function.
  
  @since  3.2
  @throws invalid_parameter_exception
  @throws moodle_exception
  @param  int      $useridto       the user id who received the message
  @param  int      $useridfrom     the user id who send the message. -10 or -20 for no-reply or support user
  @return external_description
docstring_tokens: Mark all notifications as read function .