Changeset - 7ce1a5a69798
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 14 years ago 2011-04-18 23:54:52
ohnobinki@ohnopublishing.net
Sync the `Registration Codes' dialogue with a saved_schedule's specified school/semester. Previously it relied on the session variable for this information.
2 files changed with 14 insertions and 7 deletions:
0 comments (0 inline, 0 general)
ajax.php
Show inline comments
 
@@ -58,32 +58,33 @@ function slate_permutate_json_error($mes
 
 * \param $data
 
 *   A PHP array to be encoded with json_encode() and sent as
 
 *   obj.data.
 
 */
 
function slate_permutate_json_success(array $data = array())
 
{
 
  echo json_encode(array('success' => TRUE, 'data' => $data));
 
  exit;
 
}
 

	
 
if (isset($_REQUEST['school_registration_html']))
 
  {
 
    if (!empty($_REQUEST['school']))
 
      $school = school_load($_REQUEST['school']);
 
    if (empty($school))
 
      {
 
	$school = school_load_guess();
 
    /*
 
     * Since we're just an AJAX callback, ask school_load_guess() not
 
     * to update $_SESSION with the school the user is using... And
 
     * make sure that the frontend actually tells us what school the
 
     * user is using ;-).
 
     */
 
    $school = school_load_guess(FALSE);
 
	if (empty($school))
 
	  slate_permutate_json_error('Unable to load any school.');
 
      }
 

	
 
    $page = page::page_create('');
 

	
 
    $courses = array();
 
    if (!empty($_REQUEST['courses']) && is_array($_REQUEST['courses']))
 
      {
 
	/*
 
	 * The below course deserialization blob should be moved into
 
	 * the Course object.
 
	 */
 
	foreach ($_REQUEST['courses'] as $course_json)
 
	  {
scripts/displayTables.js
Show inline comments
 
@@ -40,45 +40,51 @@ function show_box_change()
 

	
 
    return false;
 
}
 

	
 
/**
 
 * \brief
 
 *   Do an AJAX loading of data with arbitrary error handling.
 
 *
 
 * \param target
 
 *   The jQuery object which should be populated with an error message
 
 *   or the result of loading.
 
 * \param data
 
 *   The data to send as a request.
 
 *   The data to send as a request. The school and semester keys shall
 
 *   automatically be set.
 
 * \param handler
 
 *   A function with the signature handler(target, data) which is called upon
 
 *   a successful response. There is a default handler which uses
 
 *   .html() to load the data.data.html into target.
 
 * \param error_handler
 
 *   A function with the signature handler(target, status_text, data)
 
 *   which is called upon an error. The default error_handler will
 
 *   store an error message in target, possibly provided by
 
 *   data.message if the HTTP request itself was successful but the
 
 *   server still claimed there is an error. The third argument, data,
 
 *   will be null if the error is at the HTTP level.
 
 */
 
function slate_permutate_load(target, data, handler, error_handler)
 
{
 
    if (jQuery.type(handler) == 'undefined')
 
	handler = function(target, data)
 
	    {
 
		target.html(data.html);
 
	    }
 

	
 
    if (!data.school)
 
	data.school = slate_permutate_school;
 
    if (!data.semester)
 
	data.semester = slate_permutate_semester;
 

	
 
    if (jQuery.type(error_handler) == 'undefined')
 
	error_handler = function(target, status_text, data)
 
	    {
 
		if (data)
 
		    if (data.message)
 
			target.html(data.message);
 
		    else
 
			target.html('<div class="error">Unknown error.</div>');
 
		else
 
		    target.html('<div class="error">HTTP error: ' + status_text + '</div>');
 
	    }
 

	
0 comments (0 inline, 0 general)