From ba793ac8e0a550d258601e08c21578b1a9c958d1 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 14 Oct 2010 19:42:20 +0000 Subject: [PATCH] Fix rolestasks saving of the `level` for each item Fix tableeditor css to only modify anything in the tableeditor/tableview classes Fix saving language for volunteers Fix error message for saving phone numbers on organization and personal Fix schoolfeedback and schoolinfo pages Update school select tab, better html and school options list Fix css for tertiary menu to show difference between selected and non-selected --- common.inc.php | 12 ++--- schoolfeedback.php | 74 ++++++++++++----------------- schoolinfo.php | 102 ++++++++++------------------------------ super/roletasks.php | 6 ++- tableeditor.css | 4 +- theme/default/sfiab.css | 53 +++++++++++++++++---- user.inc.php | 16 +++++-- user_edit.inc.php | 4 +- user_edit.php | 2 +- user_main.php | 17 ++----- user_organization.php | 2 +- user_personal.php | 2 +- user_school.php | 18 +++---- 13 files changed, 143 insertions(+), 169 deletions(-) diff --git a/common.inc.php b/common.inc.php index b6e43f6..66db37f 100644 --- a/common.inc.php +++ b/common.inc.php @@ -151,9 +151,9 @@ if(isset($_SESSION['roles']) && $_SESSION['username']) {
- : + :
- : + :
@@ -288,7 +288,7 @@ if(array_key_exists('users_id', $_SESSION)) {
"; $cl=""; while($r=mysql_fetch_object($q)) { @@ -318,10 +318,10 @@ if(array_key_exists('users_id', $_SESSION)) { $topicMenuStyle = 'style="display:none;"'; } ?> -
> +
> "; + $q=mysql_query("SELECT * FROM rolestasks WHERE pid='{$_SESSION['nav']['secondary']}' AND conferencetype='{$conference['type']}' ORDER By ord,task"); + echo "
    "; while($r=mysql_fetch_object($q)) { $cl="class=\""; if($r->link) diff --git a/schoolfeedback.php b/schoolfeedback.php index 5955dc6..9df9b6d 100644 --- a/schoolfeedback.php +++ b/schoolfeedback.php @@ -2,52 +2,38 @@ require_once('common.inc.php'); require_once('user.inc.php'); +user_auth_required("teacher"); +$schoolid=user_field_required("schools_id","user_edit.php?tab=school"); -if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) -{ - $title = i18n("Feedback / Questions"); - send_header($title, array("School Home" => "schoolaccess.php")); +send_header("Feedback / Questions"); - // load the school info - $q=mysql_query("SELECT * FROM schools WHERE id='".$_SESSION['schoolid']."' AND accesscode='".$_SESSION['schoolaccesscode']."' AND year='".$config['FAIRYEAR']."'"); - echo mysql_error(); - $school=mysql_fetch_object($q); +// load the school info +$q=mysql_query("SELECT * FROM schools WHERE id='$schoolid'"); +echo mysql_error(); +$school=mysql_fetch_object($q); - if($school->sciencehead_uid > 0) - $sh = user_load_by_uid($school->sciencehead_uid); - else - $sh = array(); - $sh_email = ($sh['email'] != '' && $sh['email'][0] != '*') ? $sh['email'] : ''; - - // send the e-mail if we're receiving a post - if(array_key_exists('feedbacktext', $_POST)){ - $body=""; - $body.=date("r")."\n"; - $body.=$_SERVER['REMOTE_ADDR']." (".$_SERVER['REMOTE_HOST'].")\n"; - $body.="School ID: $school->id\n"; - $body.="School Name: $school->school\n"; - if($sh['name']) $body.="Science Teacher: {$sh['name']}\n"; - if($sh['phonework']) $body.="Science Teacher Phone: {$sh['phonework']}\n"; - if($sh_email) $body.="Science Teacher Email: $sh_email\n"; - $body.="\nFeedback:\n".stripslashes($_POST['feedbacktext'])."\n"; - $returnEmailAddress = $sh_email; - mail($config['fairmanageremail'],"School Feedback",$body,"From: ". $returnEmailAddress."\nReply-To: ".$returnEmailAddress."\nReturn-Path: ".$returnEmailAddress); - echo happy_("Your feedback has been sent"); - } - - // draw the feedback form - echo i18n("We are always welcome to any feedback (both positive and constructive criticism!), or any questions you may have. Please use the following form to communicate with the science fair committee!"); - if($sh_email != '') { - echo ""; - echo "

    "; - echo ""; - echo ""; - }else{ - echo error("Feedback is disabled until a science teacher email address is entered above"); - } - - send_footer(); -}else{ - header('Location: schoolaccess.php'); +// send the e-mail if we're receiving a post +if(array_key_exists('feedbacktext', $_POST)){ + $body=""; + $body.=date("r")."\n"; + $body.=$_SERVER['REMOTE_ADDR']." (".$_SERVER['REMOTE_HOST'].")\n"; + $body.="School ID: $school->id\n"; + $body.="School Name: $school->school\n"; + if($sh['name']) $body.="Science Teacher: {$sh['name']}\n"; + if($sh['phonework']) $body.="Science Teacher Phone: {$sh['phonework']}\n"; + if($sh_email) $body.="Science Teacher Email: $sh_email\n"; + $body.="\nFeedback:\n".stripslashes($_POST['feedbacktext'])."\n"; + $returnEmailAddress = $sh_email; + mail($config['fairmanageremail'],"School Feedback",$body,"From: ". $returnEmailAddress."\nReply-To: ".$returnEmailAddress."\nReturn-Path: ".$returnEmailAddress); + echo happy_("Your feedback has been sent"); } + +// draw the feedback form +echo i18n("We are always welcome to any feedback (both positive and constructive criticism!), or any questions you may have. Please use the following form to communicate with the science fair committee!"); +echo "
    "; +echo "

    "; +echo ""; +echo "
    "; + +send_footer(); ?> diff --git a/schoolinfo.php b/schoolinfo.php index 59f5bd0..de60d5f 100644 --- a/schoolinfo.php +++ b/schoolinfo.php @@ -2,89 +2,37 @@ require_once('common.inc.php'); require_once('user.inc.php'); +user_auth_required("teacher"); +$schoolid=user_field_required("schools_id","user_edit.php?tab=school"); -if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) -{ - $title = i18n("School Information"); - send_header($title, array("School Home" => "schoolaccess.php")); +send_header("School Details"); - $q=mysql_query("SELECT * FROM schools WHERE id='".$_SESSION['schoolid']."' AND accesscode='".$_SESSION['schoolaccesscode']."' AND year='".$config['FAIRYEAR']."'"); - echo mysql_error(); +if($_POST['action']=="save") { + // load the school info so we know which one we're saving + $q=mysql_query("SELECT * FROM schools WHERE id='$schoolid'"); $school=mysql_fetch_object($q); - if($school->sciencehead_uid > 0) - $sh = user_load_by_uid($school->sciencehead_uid); + mysql_query("UPDATE schools SET + school='".mysql_real_escape_string($_POST['school'])."', + address='".mysql_real_escape_string($_POST['address'])."', + city='".mysql_real_escape_string($_POST['city'])."', + province_code='".mysql_real_escape_string($_POST['province_code'])."', + postalcode='".mysql_real_escape_string($_POST['postalcode'])."', + phone='".mysql_real_escape_string($_POST['phone'])."', + fax='".mysql_real_escape_string($_POST['fax'])."' + WHERE id='$school->id'"); + + echo mysql_error(); + if(mysql_error()) + echo error(i18n("An Error occured trying to save the school information")); else - $sh = array(); - $sh_email = ($sh['email'] != '' && $sh['email'][0] != '*') ? $sh['email'] : ''; + echo happy(i18n("School information successfully updated")); - - if($_POST['action']=="save") { - /* Get info about science head */ - $sciencehead_update = ''; - list($first, $last) = explode(' ', $_POST['sciencehead'], 2); - $em = $_POST['scienceheademail']; - if($em == '' && ($first != '' || $last != '')) $em = "*$first$last".user_generate_password(); - - if($school->sciencehead_uid > 0) - $sh = user_load_by_uid($school->sciencehead_uid); - else if($em != '') { - $sh = user_create('teacher', $em); - $sciencehead_update = "sciencehead_uid='{$sh['uid']}',"; - } else - $sh = false; - - /* If we have a record, either delete it or update it */ - if(is_array($sh)) { - if($em == '') { - user_purge($sh, 'teacher'); - $sciencehead_update = 'sciencehead_uid=NULL,'; - } else { - $sh['firstname'] = $first; - $sh['lastname'] = $last; - $sh['phonework'] = $_POST['scienceheadphone']; - $sh['email'] = $em; - $sh['username'] = $em; - user_save($sh); - } - } - - mysql_query("UPDATE schools SET - school='".mysql_escape_string(stripslashes($_POST['school']))."', - address='".mysql_escape_string(stripslashes($_POST['address']))."', - city='".mysql_escape_string(stripslashes($_POST['city']))."', - province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', - postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', - phone='".mysql_escape_string(stripslashes($_POST['phone']))."', - $sciencehead_update - fax='".mysql_escape_string(stripslashes($_POST['fax']))."' - WHERE id='$school->id'"); - - echo mysql_error(); - if(mysql_error()) - echo error(i18n("An Error occured trying to save the school information")); - else - echo happy(i18n("School information successfully updated")); - - } - -}else{ - header('Location: schoolaccess.php'); - exit(); } - // load the school info -$q=mysql_query("SELECT * FROM schools WHERE id='".$_SESSION['schoolid']."' AND accesscode='".$_SESSION['schoolaccesscode']."' AND year='".$config['FAIRYEAR']."'"); -echo mysql_error(); +$q=mysql_query("SELECT * FROM schools WHERE id='$schoolid'"); $school=mysql_fetch_object($q); -if($school->sciencehead_uid > 0) - $sh = user_load_by_uid($school->sciencehead_uid); -else - $sh = array(); -$sh_email = ($sh['email'] != '' && $sh['email'][0] != '*') ? $sh['email'] : ''; - - draw_page(); send_footer(); @@ -92,10 +40,10 @@ function draw_page(){ global $config, $school, $sh_email, $sh_email, $sh; echo i18n("Please make sure your school contact information is correct, make any necessary changes:"); - echo "
    "; - echo ""; + echo ""; + echo ""; echo ""; - echo ""; + echo ""; // echo ""; echo ""; echo ""; @@ -106,9 +54,11 @@ function draw_page(){ echo ""; echo ""; + /* echo ""; echo ""; echo ""; + */ echo "
    ".i18n("School Name")."school\" type=text name=school size=40>
    ".i18n("School Name")."school\" type=\"text\" name=\"school\" size=\"40\">
    Registration Passwordregistration_password\" type=text name=\"registration_password\" size=\"20\">
    ".i18n("Address")."address\" type=text name=address size=40>
    ".i18n("City")."city\" type=text name=city size=30>
    ".i18n("Phone Number")."phone\" type=text name=phone size=30>
    ".i18n("Fax Number")."fax\" type=text name=fax size=30>
    ".i18n("Science Teacher")."
    ".i18n("Science Teacher Email")."
    ".i18n("Science Teacher Phone")."
    (".i18n("If different than above").")
    "; echo ""; echo "
    "; diff --git a/super/roletasks.php b/super/roletasks.php index c3b099c..9252c7e 100644 --- a/super/roletasks.php +++ b/super/roletasks.php @@ -162,10 +162,12 @@ function doTree($id,$roleid,$ctype) { echo mysql_error(); while($r=mysql_fetch_object($q)) { echo "comparing {$r->id} with {$dropid} \n"; + $droplevel=$r->level; if($r->id==$dropid) { $ord++; - mysql_query("UPDATE rolestasks SET pid='$droppid', ord='$ord' WHERE id='$dragid'"); + //dropped on something, so put it at the same level as what we dropped + mysql_query("UPDATE rolestasks SET pid='$droppid', level='$droplevel', ord='$ord' WHERE id='$dragid'"); echo "found!"; $updated=true; } @@ -175,7 +177,7 @@ function doTree($id,$roleid,$ctype) { if(!$updated) { echo "not found, putting it at the end"; $ord++; - mysql_query("UPDATE rolestasks SET pid='$droppid', ord='$ord' WHERE id='$dragid'"); + mysql_query("UPDATE rolestasks SET pid='$droppid', level='$droplevel', ord='$ord' WHERE id='$dragid'"); } echo mysql_error(); } diff --git a/tableeditor.css b/tableeditor.css index d41bd0d..21c4cda 100644 --- a/tableeditor.css +++ b/tableeditor.css @@ -1,8 +1,8 @@ -select { +.tableedit select { font-size: 1.0em; } -input { +.tableedit input { font-size: 1.0em; } diff --git a/theme/default/sfiab.css b/theme/default/sfiab.css index 885c5a9..7f99047 100644 --- a/theme/default/sfiab.css +++ b/theme/default/sfiab.css @@ -17,7 +17,8 @@ body input, textarea, select { font-family: Verdana, Arial, Sans-Serif; - font-size: small; + font-size: 0.85em; + margin: 0; } td { @@ -67,7 +68,7 @@ table tr.odd { #header-conferences { border: 1px solid #777777; position: absolute; - right: 210px; + right: 240px; height: 70px; background-color: #DDDDDD; } @@ -78,7 +79,11 @@ table tr.odd { position: absolute; right: 5px; height: 70px; - width: 200px; + width: 230px; +} +#header-login table { + border-collapse: collapse; + width: 100%; } #primarymenu, @@ -112,8 +117,34 @@ table tr.odd { float: left; margin-left: 0px; margin-right: 10px; + padding-left: 3px; } +.topic-menu ul { + margin-left: 0px; + padding-left: 0px; + + +} + +.topic-menu li { + margin-left: 0px; + padding-left: 0px; +} +.topic-menu li.selected { + color: red; +} + +.sfiab-menu { + list-style-position: inside; + list-style-type: none; +} + +.sfiab-menu .selected { + color: red; +} + + #main { background: #FFFFFF; padding: 3px; @@ -275,18 +306,24 @@ ul.secondarynav li.secondarynav-selected a { } ul.tertiarynav { - font-size: 0.9em; + list-style : none; + padding: 0; } -ul.tertiarynav li a { - +ul.tertiarynav li { + display: block; + margin-left: 5px; + margin-top: 5px; } -.tertiarylinknav-selected a { +li.link a { + color: black; +} + +li.selected a { font-weight: bold; } - .aligncenter { width: 100%; text-align: center; diff --git a/user.inc.php b/user.inc.php index af3dce4..0ce7540 100644 --- a/user.inc.php +++ b/user.inc.php @@ -148,6 +148,7 @@ function user_load($users_id, $accounts_id = false) convenience variable, not not the email itself, for that, they need to access the account. */ unset($u['email']); + $should_be_arrays=array(); foreach(array_keys($u['roles']) as $r) { @@ -176,11 +177,7 @@ function user_load($users_id, $accounts_id = false) // $u['highest_psd'] = $u['highest_psd']; /* Sanity check the arrays, make sure they are arrays */ - $should_be_arrays = array('cat_prefs','div_prefs', - 'divsub_prefs','languages'); - foreach($should_be_arrays as $k) { - if(!is_array($u[$k])) $u[$k] = array(); - } + $should_be_arrays = array('cat_prefs','div_prefs', 'divsub_prefs','languages'); break; case 'sponsor': @@ -190,12 +187,19 @@ function user_load($users_id, $accounts_id = false) $u['sponsor']=mysql_fetch_assoc($q); } break; + case 'volunteer': + $u['languages'] = (strlen($u['languages']) > 0) ? unserialize($u['languages']) : array(); + $should_be_arrays = array('languages'); + break; default: /* Nothing to do for all other roles */ break; } } + foreach($should_be_arrays as $k) { + if(!is_array($u[$k])) $u[$k] = array(); + } /* Do this assignment without recursion :) */ unset($u['orig']); @@ -286,6 +290,8 @@ function user_save(&$u) $fields_for_role['student'] = array('schools_id'); $fields_for_role['fair'] = array('fairs_id'); $fields_for_role['sponsor'] = array('sponsors_id','primary','position'); + $fields_for_role['teacher'] = array(); + $fields_for_role['volunteer'] = array('languages'); /* Merge fields as necessary, build a big list of fields to save */ foreach($new_roles as $r) { diff --git a/user_edit.inc.php b/user_edit.inc.php index cef83e3..689c643 100644 --- a/user_edit.inc.php +++ b/user_edit.inc.php @@ -82,7 +82,7 @@ function user_edit_item(&$u, $label, $fname, $type='textbox', $data1=NULL, $data foreach($config['languages'] AS $l=>$ln) { $ch = (in_array($l,$u['languages'])) ? 'checked="checked"' : ''; if($x) echo '
    '; - echo "$ln"; + echo ""; $x=1; } echo ""; @@ -95,7 +95,7 @@ function user_edit_item(&$u, $label, $fname, $type='textbox', $data1=NULL, $data foreach($data1 AS $key=>$txt) { $ch = (in_array($key,$data2)) ? 'checked="checked"' : ''; if($x) echo '
    '; - echo "$txt"; + echo ""; $x=1; } echo ""; diff --git a/user_edit.php b/user_edit.php index 3745b4b..cff2278 100644 --- a/user_edit.php +++ b/user_edit.php @@ -201,7 +201,7 @@ if(count($a) == 0) { } -send_header(i18n("User Editor").": {$u['name']}"); +send_header($u['name']); /* Setup tabs */ echo '
    '; diff --git a/user_main.php b/user_main.php index cc2b3e6..011b3f3 100644 --- a/user_main.php +++ b/user_main.php @@ -146,20 +146,13 @@ send_header("Main Page", array());

    "; //only display the named greeting if we have their name -echo i18n("Hello %1",array($_SESSION['name'])); +echo i18n("Hello %1",array($_SESSION['name'])); -echo "

    This is a placeholder for the main user page until all the specific user-role pages are removed. For now, here's what you can do:

    "; -draw_roles(); echo "
    "; -echo i18n('Other Options and Things To Do').':
    '; -echo '
      '; -echo '
    • '.i18n('Change Password').' - '.i18n('Change your email, username, and password').'
    • '; -echo '
    • '.i18n('To logout, use the "Logout" link in the upper-right of the page').'
    • '; -echo '
    '; - +echo "
    "; +draw_roles(); send_footer(); @@ -186,7 +179,7 @@ function draw_roles(){ echo '
    '; if(count($registered) > 0){ $rowNumber = 0; - echo "

    " . i18n("You are currently registered for the following roles") . ":

    "; + echo "

    " . i18n("You are currently registered for the following roles") . ":

    "; echo '
    '; echo ""; foreach($registered as $role => $title){ @@ -225,7 +218,7 @@ function draw_roles(){ } if(count($available) > 0){ - echo "

    " . i18n("The following roles are available") . ":

    "; + echo "

    " . i18n("The following roles are available") . ":

    "; $rowNumber = 0; echo "
    "; foreach($available as $type => $title){ diff --git a/user_organization.php b/user_organization.php index 6662be1..0ace477 100644 --- a/user_organization.php +++ b/user_organization.php @@ -123,7 +123,7 @@ jQuery.validator.addMethod("phoneUS", function(phone_number, element) { phone_number = phone_number.replace(/\s+/g, ""); return this.optional(element) || phone_number.length > 9 && phone_number.match(/^[2-9]\d{2}-[2-9]\d{2}-\d{4}$/); -}, "Please specify a valid phone number"); +}, "Please specify a valid phone number (NNN-NNN-NNNN)"); $(document).ready(function() { $("#orgform").validate({ diff --git a/user_personal.php b/user_personal.php index 8f9457f..b45e9f9 100644 --- a/user_personal.php +++ b/user_personal.php @@ -236,7 +236,7 @@ jQuery.validator.addMethod("phoneUS", function(phone_number, element) { phone_number = phone_number.replace(/\s+/g, ""); return this.optional(element) || phone_number.length > 9 && phone_number.match(/^[2-9]\d{2}-[2-9]\d{2}-\d{4}$/); -}, "Please specify a valid phone number"); +}, "Please specify a valid phone number (NNN-NNN-NNNN)"); $(document).ready(function() { $("#personalform").validate({ diff --git a/user_school.php b/user_school.php index d4cfd1a..360ab63 100644 --- a/user_school.php +++ b/user_school.php @@ -109,7 +109,7 @@ if($currentSchool){ // draw the form elements for changing the school echo "
    "; +echo "
    "; -echo "" . i18n("School") . ": "; +echo i18n("School").":"; echo ""; // build a select box for them to pick out a school @@ -117,23 +117,23 @@ echo '"; -echo "
    "; - -// and the rest of the form... -echo "" . i18n("Access Code") . ": "; +echo "
    "; +echo i18n("Access Code") . ":"; echo ""; echo '
    '; echo "
    ";