original_string: public static function mark_all_notifications_as_read($touserid, $fromuserid = null) {
          global $DB;
  
          $notificationsql = "SELECT n.*
                                FROM {notifications} n
                               WHERE useridto = ?
                                 AND timeread is NULL";
          $notificationsparams = [$touserid];
          if (!empty($fromuserid)) {
              $notificationsql .= " AND useridfrom = ?";
              $notificationsparams[] = $fromuserid;
          }
  
          $notifications = $DB->get_recordset_sql($notificationsql, $notificationsparams);
          foreach ($notifications as $notification) {
              self::mark_notification_as_read($notification);
          }
          $notifications->close();
      }
code: public static function mark_all_notifications_as_read($touserid, $fromuserid = null) {
          global $DB;
  
          $notificationsql = "SELECT n.*
                                FROM {notifications} n
                               WHERE useridto = ?
                                 AND timeread is NULL";
          $notificationsparams = [$touserid];
          if (!empty($fromuserid)) {
              $notificationsql .= " AND useridfrom = ?";
              $notificationsparams[] = $fromuserid;
          }
  
          $notifications = $DB->get_recordset_sql($notificationsql, $notificationsparams);
          foreach ($notifications as $notification) {
              self::mark_notification_as_read($notification);
          }
          $notifications->close();
      }
code_tokens: public static function mark_all_notifications_as_read ( $ touserid , $ fromuserid = null ) { global $ DB ; $ notificationsql = "SELECT n.*
                                FROM {notifications} n
                               WHERE useridto = ?
                                 AND timeread is NULL" ; $ notificationsparams = [ $ touserid ] ; if ( ! empty ( $ fromuserid ) ) { $ notificationsql .= " AND useridfrom = ?" ; $ notificationsparams [ ] = $ fromuserid ; } $ notifications = $ DB -> get_recordset_sql ( $ notificationsql , $ notificationsparams ) ; foreach ( $ notifications as $ notification ) { self :: mark_notification_as_read ( $ notification ) ; } $ notifications -> close ( ) ; }
docstring: Marks all notifications being sent from one user to another user as read.
  
  If the from user is null then it marks all notifications as read sent to the to user.
  
  @param int $touserid the id of the message recipient
  @param int|null $fromuserid the id of the message sender, null if all messages
  @return void
docstring_tokens: Marks all notifications being sent from one user to another user as read .