original_string: public static function plan_cancel_review_request($planorid) {
          static::require_enabled();
          $plan = $planorid;
          if (!is_object($plan)) {
              $plan = new plan($plan);
          }
  
          // We need to be able to view the plan at least.
          if (!$plan->can_read()) {
              throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', '');
          }
  
          if ($plan->is_based_on_template()) {
              throw new coding_exception('Template plans cannot be reviewed.');   // This should never happen.
          } else if ($plan->get('status') != plan::STATUS_WAITING_FOR_REVIEW) {
              throw new coding_exception('The plan review cannot be cancelled at this stage.');
          } else if (!$plan->can_request_review()) {
              throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', '');
          }
  
          $plan->set('status', plan::STATUS_DRAFT);
          $result = $plan->update();
  
          // Trigger review request cancelled event.
          \core\event\competency_plan_review_request_cancelled::create_from_plan($plan)->trigger();
  
          return $result;
      }
code: public static function plan_cancel_review_request($planorid) {
          static::require_enabled();
          $plan = $planorid;
          if (!is_object($plan)) {
              $plan = new plan($plan);
          }
  
          // We need to be able to view the plan at least.
          if (!$plan->can_read()) {
              throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', '');
          }
  
          if ($plan->is_based_on_template()) {
              throw new coding_exception('Template plans cannot be reviewed.');   // This should never happen.
          } else if ($plan->get('status') != plan::STATUS_WAITING_FOR_REVIEW) {
              throw new coding_exception('The plan review cannot be cancelled at this stage.');
          } else if (!$plan->can_request_review()) {
              throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', '');
          }
  
          $plan->set('status', plan::STATUS_DRAFT);
          $result = $plan->update();
  
          // Trigger review request cancelled event.
          \core\event\competency_plan_review_request_cancelled::create_from_plan($plan)->trigger();
  
          return $result;
      }
code_tokens: public static function plan_cancel_review_request ( $ planorid ) { static :: require_enabled ( ) ; $ plan = $ planorid ; if ( ! is_object ( $ plan ) ) { $ plan = new plan ( $ plan ) ; } // We need to be able to view the plan at least. if ( ! $ plan -> can_read ( ) ) { throw new required_capability_exception ( $ plan -> get_context ( ) , 'moodle/competency:planview' , 'nopermissions' , '' ) ; } if ( $ plan -> is_based_on_template ( ) ) { throw new coding_exception ( 'Template plans cannot be reviewed.' ) ; // This should never happen. } else if ( $ plan -> get ( 'status' ) != plan :: STATUS_WAITING_FOR_REVIEW ) { throw new coding_exception ( 'The plan review cannot be cancelled at this stage.' ) ; } else if ( ! $ plan -> can_request_review ( ) ) { throw new required_capability_exception ( $ plan -> get_context ( ) , 'moodle/competency:planmanage' , 'nopermissions' , '' ) ; } $ plan -> set ( 'status' , plan :: STATUS_DRAFT ) ; $ result = $ plan -> update ( ) ; // Trigger review request cancelled event. \ core \ event \ competency_plan_review_request_cancelled :: create_from_plan ( $ plan ) -> trigger ( ) ; return $ result ; }
docstring: Cancel the review of a plan.
  
  @param int|plan $planorid The plan, or its ID.
  @return bool
docstring_tokens: Cancel the review of a plan .