original_string: public static function setup_for_plan($userid, moodle_url $url, $plan = null, $subtitle = '', $returntype = null) {
          global $PAGE, $USER;
  
          // Check that the user is a valid user.
          $user = core_user::get_user($userid);
          if (!$user || !core_user::is_real_user($userid)) {
              throw new \moodle_exception('invaliduser', 'error');
          }
  
          $context = context_user::instance($user->id);
  
          $plansurl = new moodle_url('/admin/tool/lp/plans.php', array('userid' => $userid));
          $planurl = null;
          if ($plan) {
              $planurl = new moodle_url('/admin/tool/lp/plan.php', array('id' => $plan->get('id')));
          }
  
          $returnurl = $plansurl;
          if ($returntype != 'plans' && $planurl) {
              $returnurl = $planurl;
          }
  
          $PAGE->navigation->override_active_url($plansurl);
          $PAGE->set_context($context);
  
          // If not his own plan, we want to extend the navigation for the user.
          $iscurrentuser = ($USER->id == $user->id);
          if (!$iscurrentuser) {
              $PAGE->navigation->extend_for_user($user);
              $PAGE->navigation->set_userid_for_parent_checks($user->id);
          }
  
          if (!empty($plan)) {
              $title = format_string($plan->get('name'), true, array('context' => $context));
          } else {
              $title = get_string('learningplans', 'tool_lp');
          }
  
          $PAGE->set_pagelayout('standard');
          $PAGE->set_url($url);
          $PAGE->set_title($title);
          $PAGE->set_heading($title);
  
          if (!empty($plan)) {
              $PAGE->navbar->add($title, $planurl);
              if (!empty($subtitle)) {
                  $PAGE->navbar->add($subtitle, $url);
              }
          } else if (!empty($subtitle)) {
              // We're in a sub page without a specific plan.
              $PAGE->navbar->add($subtitle, $url);
          }
  
          return array($title, $subtitle, $returnurl);
      }
code: public static function setup_for_plan($userid, moodle_url $url, $plan = null, $subtitle = '', $returntype = null) {
          global $PAGE, $USER;
  
          // Check that the user is a valid user.
          $user = core_user::get_user($userid);
          if (!$user || !core_user::is_real_user($userid)) {
              throw new \moodle_exception('invaliduser', 'error');
          }
  
          $context = context_user::instance($user->id);
  
          $plansurl = new moodle_url('/admin/tool/lp/plans.php', array('userid' => $userid));
          $planurl = null;
          if ($plan) {
              $planurl = new moodle_url('/admin/tool/lp/plan.php', array('id' => $plan->get('id')));
          }
  
          $returnurl = $plansurl;
          if ($returntype != 'plans' && $planurl) {
              $returnurl = $planurl;
          }
  
          $PAGE->navigation->override_active_url($plansurl);
          $PAGE->set_context($context);
  
          // If not his own plan, we want to extend the navigation for the user.
          $iscurrentuser = ($USER->id == $user->id);
          if (!$iscurrentuser) {
              $PAGE->navigation->extend_for_user($user);
              $PAGE->navigation->set_userid_for_parent_checks($user->id);
          }
  
          if (!empty($plan)) {
              $title = format_string($plan->get('name'), true, array('context' => $context));
          } else {
              $title = get_string('learningplans', 'tool_lp');
          }
  
          $PAGE->set_pagelayout('standard');
          $PAGE->set_url($url);
          $PAGE->set_title($title);
          $PAGE->set_heading($title);
  
          if (!empty($plan)) {
              $PAGE->navbar->add($title, $planurl);
              if (!empty($subtitle)) {
                  $PAGE->navbar->add($subtitle, $url);
              }
          } else if (!empty($subtitle)) {
              // We're in a sub page without a specific plan.
              $PAGE->navbar->add($subtitle, $url);
          }
  
          return array($title, $subtitle, $returnurl);
      }
code_tokens: public static function setup_for_plan ( $ userid , moodle_url $ url , $ plan = null , $ subtitle = '' , $ returntype = null ) { global $ PAGE , $ USER ; // Check that the user is a valid user. $ user = core_user :: get_user ( $ userid ) ; if ( ! $ user || ! core_user :: is_real_user ( $ userid ) ) { throw new \ moodle_exception ( 'invaliduser' , 'error' ) ; } $ context = context_user :: instance ( $ user -> id ) ; $ plansurl = new moodle_url ( '/admin/tool/lp/plans.php' , array ( 'userid' => $ userid ) ) ; $ planurl = null ; if ( $ plan ) { $ planurl = new moodle_url ( '/admin/tool/lp/plan.php' , array ( 'id' => $ plan -> get ( 'id' ) ) ) ; } $ returnurl = $ plansurl ; if ( $ returntype != 'plans' && $ planurl ) { $ returnurl = $ planurl ; } $ PAGE -> navigation -> override_active_url ( $ plansurl ) ; $ PAGE -> set_context ( $ context ) ; // If not his own plan, we want to extend the navigation for the user. $ iscurrentuser = ( $ USER -> id == $ user -> id ) ; if ( ! $ iscurrentuser ) { $ PAGE -> navigation -> extend_for_user ( $ user ) ; $ PAGE -> navigation -> set_userid_for_parent_checks ( $ user -> id ) ; } if ( ! empty ( $ plan ) ) { $ title = format_string ( $ plan -> get ( 'name' ) , true , array ( 'context' => $ context ) ) ; } else { $ title = get_string ( 'learningplans' , 'tool_lp' ) ; } $ PAGE -> set_pagelayout ( 'standard' ) ; $ PAGE -> set_url ( $ url ) ; $ PAGE -> set_title ( $ title ) ; $ PAGE -> set_heading ( $ title ) ; if ( ! empty ( $ plan ) ) { $ PAGE -> navbar -> add ( $ title , $ planurl ) ; if ( ! empty ( $ subtitle ) ) { $ PAGE -> navbar -> add ( $ subtitle , $ url ) ; } } else if ( ! empty ( $ subtitle ) ) { // We're in a sub page without a specific plan. $ PAGE -> navbar -> add ( $ subtitle , $ url ) ; } return array ( $ title , $ subtitle , $ returnurl ) ; }
docstring: Set-up a plan page.
  
  Example:
  list($title, $subtitle) = page_helper::setup_for_plan($url, $template, $pagetitle);
  echo $OUTPUT->heading($title);
  echo $OUTPUT->heading($subtitle, 3);
  
  @param  int $userid The user ID.
  @param  moodle_url $url The current page.
  @param  \core_competency\plan $plan The plan, if any.
  @param  string $subtitle The title of the subpage, if any.
  @param  string $returntype The desired return page.
  @return array With the following:
  - Page title
  - Page sub title
  - Return URL (main plan page)
docstring_tokens: Set - up a plan page .