Changeset - 85225ae6e519
[Not reviewed]
default
0 4 0
Nathan Brink (binki) - 14 years ago 2011-04-09 11:42:43
ohnobinki@ohnopublishing.net
Fix up remembering the school of an edited schedule on the input pages.
4 files changed with 46 insertions and 17 deletions:
0 comments (0 inline, 0 general)
inc/class.page.php
Show inline comments
 
@@ -257,6 +257,11 @@ class page
 
    foreach ($this->scripts as $i)
 
      echo '    ' . $this->headCode["$i"] . "\n";
 

	
 
    $selectschool_query = '&school=' . $this->school['id'];
 
    /* kludge */
 
    if (!empty($_REQUEST['s']))
 
      $selectschool_query .= '&s=' . (int)$_REQUEST['s'];
 

	
 
    echo '  </head>' . PHP_EOL .
 
	 '  <body>'. PHP_EOL .
 
         '    <div id="page">'. PHP_EOL .
 
@@ -266,9 +271,9 @@ class page
 
         '          <p>'. PHP_EOL .
 
         '            <span id="subtitle">'.$this->pagetitle.'</span>'. PHP_EOL .
 
  	 '            <span id="menu">' . PHP_EOL
 
      . '              Profile: <em>' . $this->school['name'] . '</em>' . ($this->school_semester_constant ? '' : ' <a href="input.php?selectschool=1">(change)</a>') . PHP_EOL;
 
      . '              Profile: <em>' . $this->school['name'] . '</em>' . ($this->school_semester_constant ? '' : ' <a href="input.php?selectschool=1' . $selectschool_query . '">(change)</a>') . PHP_EOL;
 
    if (!empty($this->semester))
 
      echo  '             Semester: <em>' . $this->semester['name'] . '</em>' . ($this->school_semester_constant ? '' : ' <a href="input.php?selectsemester=1">(change)</a>') . PHP_EOL;
 
      echo  '             Semester: <em>' . $this->semester['name'] . '</em>' . ($this->school_semester_constant ? '' : ' <a href="input.php?selectsemester=1' . $selectschool_query . '">(change)</a>') . PHP_EOL;
 
    echo '            </span>'. PHP_EOL .
 
         '          </p>'. PHP_EOL .
 
         '        </div>'. PHP_EOL .
inc/class.schedule.php
Show inline comments
 
@@ -117,7 +117,7 @@ class Schedule
 
    $this->parent_id = $parent;
 

	
 
    if (empty($school))
 
      $school = school_load_guess();
 
      $school = school_load_guess(FALSE);
 
    $this->school_id = $school['id'];
 

	
 
    if (empty($semester))
 
@@ -211,7 +211,7 @@ class Schedule
 
      {
 
	/* Ensure we have $_SESSION. */
 
	page::session_start();
 
	$school = school_load_guess();
 
	$school = school_load_guess(FALSE);
 
      }
 

	
 
    return $school;
 
@@ -822,7 +822,7 @@ class Schedule
 
      {
 
	/* Ensure we have $_SESSION. */
 
	page::session_start();
 
	$school = school_load_guess();
 
	$school = school_load_guess(FALSE);
 
	$this->school_id = $school['id'];
 
      }
 
    if (empty($this->semester))
inc/school.inc
Show inline comments
 
@@ -227,7 +227,7 @@ function school_list_html($highlight = N
 
    $linkto = '?';
 
  elseif (strpos($linkto, '?') === FALSE)
 
    $linkto .= '?';
 
  else
 
  elseif (strpos('?&', strstr($linkto, -1)) !== FALSE)
 
    $linkto .= '&';
 
  $linkto .= 'school=';
 
  $linkto = htmlentities($linkto);
 
@@ -239,7 +239,7 @@ function school_list_html($highlight = N
 
      if ($school_id == $highlight)
 
	$class_highlight = ' highlight';
 
      $html .= '<li class="school' . $class_highlight . '"><a href="' . $linkto . $school_id . '">'
 
	. $school_info['name'] . "</a></li>\n";
 
	. htmlentities($school_info['name']) . "</a></li>\n";
 
    }
 
  $html .= "</ul>\n";
 

	
 
@@ -352,7 +352,7 @@ function school_semesters(array $school)
 
 *   to the same keys in the arrays returned by school_semesters() or
 
 *   NULL if no semester can be found.
 
 */
 
function school_semester_guess(array $school, $update_session = FALSE)
 
function school_semester_guess(array $school, $update_session = TRUE)
 
{
 
  $semesters = school_semesters($school);
 

	
input.php
Show inline comments
 
@@ -24,6 +24,14 @@ include_once 'inc' . DIRECTORY_SEPARATOR
 
include_once 'inc' . DIRECTORY_SEPARATOR . 'class.page.php';
 
require_once('inc' . DIRECTORY_SEPARATOR . 'schedule_store.inc');
 

	
 
/*
 
 * Help constrol whether or not the school selection dialogue should
 
 * be shown or whether or not $_SESSION['school_chosen'] should be set
 
 * TRUE. These things should generally be false when loading a saved
 
 * schedule.
 
 */
 
$creating_new_schedule = TRUE;
 

	
 
$schedule_store = FALSE;
 
$sch = FALSE;
 
$errors_fix = FALSE;
 
@@ -35,8 +43,14 @@ if (isset($_REQUEST['s']))
 
    $schedule_store = schedule_store_init();
 
    $parent_schedule_id = (int)$_REQUEST['s'];
 
    $sch = schedule_store_retrieve($schedule_store, $parent_schedule_id);
 
    $inputPage_options += array('school' => $sch->school_get(),
 
				'semester' => $sch->semester_get());
 
    if (!empty($sch))
 
      {
 
	$creating_new_schedule = FALSE;
 
	$inputPage_options += array('school' => $sch->school_get(),
 
				    'semester' => $sch->semester_get());
 
      }
 
    else
 
      $parent_schedule_id = NULL;
 
  }
 
elseif (!empty($_REQUEST['e']))
 
  {
 
@@ -48,6 +62,8 @@ elseif (!empty($_REQUEST['e']))
 
    $errors_fix = TRUE;
 
    if (!empty($_POST['postData']['parent_schedule_id']))
 
      $parent_schedule_id = (int)$_POST['postData']['parent_schedule_id'];
 

	
 
    $creating_new_schedule = FALSE;
 
  }
 

	
 
/*
 
@@ -59,7 +75,7 @@ elseif (!empty($_REQUEST['e']))
 
$inputPage = page::page_create('Scheduler', $scripts, $inputPage_options);
 
$school = $inputPage->get_school();
 

	
 
$my_hc = 'var slate_permutate_example_course_id = ' . json_encode(school_example_course_id($inputPage->get_school())) . ';
 
$my_hc = 'var slate_permutate_example_course_id = ' . json_encode(school_example_course_id($school)) . ';
 

	
 
jQuery(document).ready(
 
  function()
 
@@ -125,20 +141,22 @@ if ($qtips_always || !isset($_SESSION['s
 
 * student before displaying the input form. To do this, we need
 
 * another variable in $_SESSION: $_SESSION['school_chosen'].
 
 */
 
if ($school && (!empty($_REQUEST['school']) || $school['id'] != 'default'))
 
if (!empty($_REQUEST['school']) && !empty($_SESSION['school']) && !strcmp($_REQUEST['school'], $_SESSION['school']))
 
  $_SESSION['school_chosen'] = TRUE;
 
if (!empty($_REQUEST['selectschool'])
 
    || $school['id'] == 'default' && !isset($_SESSION['school_chosen']))
 
    || empty($school) || $school['id'] == 'default' && empty($_SESSION['school_chosen']))
 
  {
 
    $next_page = 'input.php';
 
    $next_page = 'input.php?';
 
    if (isset($_GET['s']))
 
      $next_page .= '?s=' . (int)$_GET['s'];
 
      $next_page .= 's=' . (int)$_GET['s'] . '&';
 
    if (isset($_GET['semester']))
 
      $next_page .= 'semester=' . htmlentities($$_GET['semester']) . '&';
 
?>
 
<h2>School Selection</h2>
 
<p>
 
  Choose the school you attend from the list below. <strong>If you cannot
 
  find your school</strong>, you may proceed using
 
  the <a href="<?php echo $next_page . (strpos($next_page, '?') === FALSE ? '?' : '&amp;'); ?>school=default">generic
 
  the <a href="<?php echo htmlentities($next_page); ?>school=default">generic
 
  settings</a>.
 
</p>
 
<?php
 
@@ -157,7 +175,13 @@ if (!empty($_REQUEST['selectsemester']))
 
  href="feedback.php?feedback=My+school+is+missing+the+&lt;semester+name&gt;+semester.">let us know</a>.
 
</p>
 
<?php
 
  $inputPage->showSemesters();
 
  $next_page = 'input.php?';
 
  if (isset($_GET['s']))
 
    $next_page .= 's=' . (int)$_GET['s'] . '&';
 
  if (!empty($_GET['school']))
 
    $next_page .= 'school=' . $_GET['school'] . '&';
 

	
 
  $inputPage->showSemesters($next_page);
 
  $inputPage->foot();
 
  exit;
 
  }
0 comments (0 inline, 0 general)