original_string: protected static function validate_submission($submission, workshop $workshop) {
          global $USER;
  
          $workshopclosed = $workshop->phase == workshop::PHASE_CLOSED;
          $canviewpublished = has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context);
  
          $canview = $submission->authorid == $USER->id;  // I did it.
          $canview = $canview || !empty($workshop->get_assessment_of_submission_by_user($submission->id, $USER->id));  // I reviewed.
          $canview = $canview || has_capability('mod/workshop:viewallsubmissions', $workshop->context); // I can view all.
          $canview = $canview || ($submission->published && $workshopclosed && $canviewpublished);    // It has been published.
  
          if ($canview) {
              // Here we should check if the user share group.
              if ($submission->authorid != $USER->id &&
                      !groups_user_groups_visible($workshop->course, $submission->authorid, $workshop->cm)) {
                  throw new moodle_exception('notingroup');
              }
          } else {
              throw new moodle_exception('nopermissions', 'error', '', 'view submission');
          }
      }
code: protected static function validate_submission($submission, workshop $workshop) {
          global $USER;
  
          $workshopclosed = $workshop->phase == workshop::PHASE_CLOSED;
          $canviewpublished = has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context);
  
          $canview = $submission->authorid == $USER->id;  // I did it.
          $canview = $canview || !empty($workshop->get_assessment_of_submission_by_user($submission->id, $USER->id));  // I reviewed.
          $canview = $canview || has_capability('mod/workshop:viewallsubmissions', $workshop->context); // I can view all.
          $canview = $canview || ($submission->published && $workshopclosed && $canviewpublished);    // It has been published.
  
          if ($canview) {
              // Here we should check if the user share group.
              if ($submission->authorid != $USER->id &&
                      !groups_user_groups_visible($workshop->course, $submission->authorid, $workshop->cm)) {
                  throw new moodle_exception('notingroup');
              }
          } else {
              throw new moodle_exception('nopermissions', 'error', '', 'view submission');
          }
      }
code_tokens: protected static function validate_submission ( $ submission , workshop $ workshop ) { global $ USER ; $ workshopclosed = $ workshop -> phase == workshop :: PHASE_CLOSED ; $ canviewpublished = has_capability ( 'mod/workshop:viewpublishedsubmissions' , $ workshop -> context ) ; $ canview = $ submission -> authorid == $ USER -> id ; // I did it. $ canview = $ canview || ! empty ( $ workshop -> get_assessment_of_submission_by_user ( $ submission -> id , $ USER -> id ) ) ; // I reviewed. $ canview = $ canview || has_capability ( 'mod/workshop:viewallsubmissions' , $ workshop -> context ) ; // I can view all. $ canview = $ canview || ( $ submission -> published && $ workshopclosed && $ canviewpublished ) ; // It has been published. if ( $ canview ) { // Here we should check if the user share group. if ( $ submission -> authorid != $ USER -> id && ! groups_user_groups_visible ( $ workshop -> course , $ submission -> authorid , $ workshop -> cm ) ) { throw new moodle_exception ( 'notingroup' ) ; } } else { throw new moodle_exception ( 'nopermissions' , 'error' , '' , 'view submission' ) ; } }
docstring: Helper method for validating a submission.
  
  @param  stdClass   $submission submission object
  @param  workshop   $workshop     workshop instance
  @return void
  @since  Moodle 3.4
docstring_tokens: Helper method for validating a submission .