forked from science-ation/science-ation
Fix one small issue with db update 204
Allow logging in if the user isnt in the conference (just go to the user_account page for now, i guess eventually it'll need to go to a "register for the conference" page Some fixes and updates to the menu/navigation, still not perfect, btu getting there
This commit is contained in:
parent
aaea2764b6
commit
b3ce18ca0c
@ -79,8 +79,8 @@ function taskNav(id,pid,level) {
|
|||||||
$("#tertiarymenu_accordion").accordion("destroy");
|
$("#tertiarymenu_accordion").accordion("destroy");
|
||||||
$("#tertiarymenu_accordion").load("<?=$config['SFIABDIRECTORY']?>/nav.php?level=2&id="+id,null,function() {
|
$("#tertiarymenu_accordion").load("<?=$config['SFIABDIRECTORY']?>/nav.php?level=2&id="+id,null,function() {
|
||||||
$("#tertiarymenu_accordion").accordion({clearStyle: true}); //"option", "collapsible", true);
|
$("#tertiarymenu_accordion").accordion({clearStyle: true}); //"option", "collapsible", true);
|
||||||
});
|
|
||||||
$("#tertiarymenu").show();
|
$("#tertiarymenu").show();
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ if(!$_SESSION['conferences_id']) {
|
|||||||
$cl="class=\"selected\"";
|
$cl="class=\"selected\"";
|
||||||
else
|
else
|
||||||
$cl="";
|
$cl="";
|
||||||
echo "<li $cl><a $cl href=\"".$_SERVER['PHP_SELF']."?switchconference=$r->id\">$r->name</a></li>\n";
|
echo "<li $cl><a $cl href=\"user_login.php?action=switchconference&switchconference=$r->id\">$r->name</a></li>\n";
|
||||||
}
|
}
|
||||||
echo "</ul>\n";
|
echo "</ul>\n";
|
||||||
}
|
}
|
||||||
@ -314,22 +314,6 @@ if(array_key_exists('users_id', $_SESSION)) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?
|
<?
|
||||||
if($_SESSION['nav']['primary']) {
|
|
||||||
echo "<script type=\"text/javascript\">";
|
|
||||||
echo " $(document).ready(function() {\n";
|
|
||||||
echo "taskNav({$_SESSION['nav']['primary']},0,0);";
|
|
||||||
echo " });";
|
|
||||||
echo "</script>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if($_SESSION['nav']['secondary']) {
|
|
||||||
echo "<script type=\"text/javascript\">";
|
|
||||||
echo " $(document).ready(function() {\n";
|
|
||||||
echo "taskNav({$_SESSION['nav']['secondary']},{$_SESSION['nav']['primary']},1);";
|
|
||||||
echo " });";
|
|
||||||
echo "</script>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//take SFIABDIRECTORY off of the current URL
|
//take SFIABDIRECTORY off of the current URL
|
||||||
$pageurl=substr($_SERVER['PHP_SELF'],strlen($config['SFIABDIRECTORY']));
|
$pageurl=substr($_SERVER['PHP_SELF'],strlen($config['SFIABDIRECTORY']));
|
||||||
@ -340,17 +324,42 @@ if($r=mysql_fetch_object($q)) {
|
|||||||
//because we cannot assume that the user navigated to this page via the pri/sec/ter nav menus
|
//because we cannot assume that the user navigated to this page via the pri/sec/ter nav menus
|
||||||
$navTree=array();
|
$navTree=array();
|
||||||
upTree($r->id,&$navTree);
|
upTree($r->id,&$navTree);
|
||||||
|
|
||||||
|
echo "<script type=\"text/javascript\">";
|
||||||
|
echo " $(document).ready(function() {\n";
|
||||||
|
echo "taskNav({$_SESSION['nav']['secondary']},{$_SESSION['nav']['primary']},1);";
|
||||||
|
|
||||||
foreach($navTree AS $t) {
|
foreach($navTree AS $t) {
|
||||||
print_r($t);
|
switch($t['level']) {
|
||||||
echo "<br />";
|
case 0: //primary nav
|
||||||
|
$_SESSION['nav']['primary']=$t['id'];
|
||||||
|
// echo "$(\"#primary_nav_".$t['id']."\").addClass('primarynav-selected');";
|
||||||
|
break;
|
||||||
|
case 1: //secondary nav
|
||||||
|
$_SESSION['nav']['secondary']=$t['id'];
|
||||||
|
// echo "$(\"#secondary_nav_".$t['id']."\").addClass('secondarynav-selected');";
|
||||||
|
break;
|
||||||
|
case 2: //tertiary nav heading
|
||||||
|
case 3: //tertiary nav link
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
echo " });";
|
||||||
|
echo "</script>\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
echo "<script type=\"text/javascript\">";
|
||||||
|
echo " $(document).ready(function() {\n";
|
||||||
|
|
||||||
|
if($_SESSION['nav']['primary']) {
|
||||||
|
echo "taskNav({$_SESSION['nav']['primary']},0,0);\n";
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
if($_SESSION['nav']['secondary']) {
|
||||||
|
echo "taskNav({$_SESSION['nav']['secondary']},{$_SESSION['nav']['primary']},1);\n";
|
||||||
|
}
|
||||||
|
echo " });";
|
||||||
|
echo "</script>\n";
|
||||||
|
|
||||||
<?
|
|
||||||
/*
|
/*
|
||||||
if(is_array($nav)) {
|
if(is_array($nav)) {
|
||||||
echo "<div id=\"mainwhere\">".i18n('You are here:').' ';
|
echo "<div id=\"mainwhere\">".i18n('You are here:').' ';
|
||||||
|
@ -16,7 +16,7 @@ function db_update_204_post()
|
|||||||
);
|
);
|
||||||
|
|
||||||
// get the year => conference_id links
|
// get the year => conference_id links
|
||||||
$q1 = mysql_query("SELECT year, id FROM conferences");
|
$q1 = mysql_query("SELECT year, id FROM conferences WHERE year>0");
|
||||||
while($r = mysql_fetch_assoc($q1)){
|
while($r = mysql_fetch_assoc($q1)){
|
||||||
|
|
||||||
foreach($tables as $tableName){
|
foreach($tables as $tableName){
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
echo " <tr>";
|
echo " <tr>";
|
||||||
echo " <td><a href=\"systemvariables.php\">".theme_icon("configuration_variables")."<br />".i18n("System Configuration Variables")."</a></td>";
|
echo " <td><a href=\"systemvariables.php\">".theme_icon("configuration_variables")."<br />".i18n("System Configuration Variables")."</a></td>";
|
||||||
echo " <td><a href=\"conferences.php\">".theme_icon("conferences")."<br />".i18n("Conferences Setup")."</a></td>";
|
echo " <td><a href=\"conferences.php\">".theme_icon("conferences")."<br />".i18n("Conferences Setup")."</a></td>";
|
||||||
echo " <td></td>\n";
|
echo " <td><a href=\"roletasks.php\">".theme_icon("rolestasks")."<br />".i18n("Roles Tasks Setup")."</a></td>";
|
||||||
echo " <td></td>\n";
|
echo " <td></td>\n";
|
||||||
echo " </tr>";
|
echo " </tr>";
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
|
171
user_login.php
171
user_login.php
@ -65,90 +65,20 @@ function try_login($user, $pass)
|
|||||||
return $r['id'];
|
return $r['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't do any login stuff if they're already logged in */
|
function user_conference_load($accounts_id,$conferences_id) {
|
||||||
if(isset($_SESSION['accounts_id'])) {
|
global $config;
|
||||||
/* They're already logged in, if they're not trying to logout, don't
|
|
||||||
* let them see the login page */
|
|
||||||
if($_GET['action'] != 'logout') {
|
|
||||||
message_push(error(i18n('You are already logged in, please use the [Logout] link in the upper right to logout before logging in as different user')));
|
|
||||||
header("location: user_main.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$notice=$_GET['notice'];
|
|
||||||
|
|
||||||
$redirect = $_GET['redirect'];
|
|
||||||
$redirect_data = $_GET['redirectdata'];
|
|
||||||
|
|
||||||
switch($redirect) {
|
|
||||||
case 'roleadd':
|
|
||||||
$redirect_url = "&redirect=$redirect&redirectdata=$redirectdata";
|
|
||||||
break;
|
|
||||||
case 'roleattached':
|
|
||||||
$redirect_url = "&redirect=$redirect";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$redirect_url = '';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
switch($role) {
|
|
||||||
case 'volunteer':
|
|
||||||
// returns "notopenyet", "closed", or "open"
|
|
||||||
$reg_open = user_volunteer_registration_status();
|
|
||||||
break;
|
|
||||||
case 'committee':
|
|
||||||
$reg_open = 'notpermitted';
|
|
||||||
break;
|
|
||||||
case 'judge':
|
|
||||||
$reg_open = user_judge_registration_status();
|
|
||||||
break;
|
|
||||||
case 'fair':
|
|
||||||
$reg_open = 'notpermitted';
|
|
||||||
break;
|
|
||||||
case 'sponsor':
|
|
||||||
$reg_open = 'notpermitted';
|
|
||||||
break;
|
|
||||||
case 'parent': case 'alumni': case 'principal': case 'mentor':
|
|
||||||
/* Always open, because they could have been auto-created
|
|
||||||
$reg_open = 'open';
|
|
||||||
break;
|
|
||||||
case 'student':
|
|
||||||
default:
|
|
||||||
if($_GET['action']!="logout")
|
|
||||||
exit;
|
|
||||||
$reg_open = 'closed';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if($_POST['action']== 'login' ) {
|
|
||||||
|
|
||||||
$user = $_POST['username'];
|
|
||||||
$pass = $_POST['password'];
|
|
||||||
|
|
||||||
$accounts_id = try_login($user, $pass);
|
|
||||||
if($accounts_id == false) {
|
|
||||||
message_push(error(i18n("Invalid Email/Password")));
|
|
||||||
header("location: user_login.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$a = account_load($accounts_id);
|
|
||||||
|
|
||||||
/* Use the active conference to find the user id to load */
|
/* Use the active conference to find the user id to load */
|
||||||
/* FIXME: Need to be able to handle the case where there is no
|
/* FIXME: Need to be able to handle the case where there is no
|
||||||
* active conference, but one step at a time */
|
* active conference, but one step at a time */
|
||||||
$q = mysql_query("SELECT id FROM users WHERE accounts_id=$accounts_id AND conferences_id={$_SESSION['conferences_id']}");
|
$q = mysql_query("SELECT id FROM users WHERE accounts_id=$accounts_id AND conferences_id=$conferences_id");
|
||||||
if(mysql_num_rows($q) == 0) {
|
if(mysql_num_rows($q) == 0) {
|
||||||
/* FIXME: this should probably just return false, but for now, see if there's an error */
|
/* FIXME: this should probably just return false, but for now, see if there's an error */
|
||||||
echo "No user {$accounts_id} for conference {$_SESSION['conferences_id']}";
|
header("location: user_account.php");
|
||||||
|
// echo "No user {$accounts_id} for conference {$_SESSION['conferences_id']}";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if(mysql_num_rows($q) > 1) {
|
if(mysql_num_rows($q) > 1) {
|
||||||
echo "DATABASE ERROR: More than one user for account $accounts_id conference {$_SESSION['conferences_id']}";
|
echo "DATABASE ERROR: More than one user for account $accounts_id conference {$conferences_id}";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$uid = mysql_fetch_assoc($q);
|
$uid = mysql_fetch_assoc($q);
|
||||||
@ -157,12 +87,8 @@ if(isset($_SESSION['accounts_id'])) {
|
|||||||
$u = user_load($id);
|
$u = user_load($id);
|
||||||
|
|
||||||
$_SESSION['name']="{$u['firstname']} {$u['lastname']}";
|
$_SESSION['name']="{$u['firstname']} {$u['lastname']}";
|
||||||
$_SESSION['username']=$u['username'];
|
|
||||||
$_SESSION['email']=$u['email'];
|
|
||||||
$_SESSION['users_id']=$u['id'];
|
$_SESSION['users_id']=$u['id'];
|
||||||
$_SESSION['accounts_id']=$u['accounts_id'];
|
|
||||||
$_SESSION['roles']=array_keys($u['roles']);
|
$_SESSION['roles']=array_keys($u['roles']);
|
||||||
$_SESSION['superuser'] = ($a['superuser'] == 'yes') ? 'yes' : 'no';
|
|
||||||
|
|
||||||
/* Load the password expiry for each user role, and
|
/* Load the password expiry for each user role, and
|
||||||
* find the longest expiry, which is the one we'll use
|
* find the longest expiry, which is the one we'll use
|
||||||
@ -246,7 +172,92 @@ if(isset($_SESSION['accounts_id'])) {
|
|||||||
}
|
}
|
||||||
header("location: user_main.php");
|
header("location: user_main.php");
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Don't do any login stuff if they're already logged in */
|
||||||
|
if(isset($_SESSION['accounts_id'])) {
|
||||||
|
/* They're already logged in, if they're not trying to logout, don't
|
||||||
|
* let them see the login page */
|
||||||
|
if($_GET['action'] != 'logout' && $_GET['action']!='switchconference') {
|
||||||
|
message_push(error(i18n('You are already logged in, please use the "Logout" link in the upper right to logout before logging in as different user')));
|
||||||
|
header("location: user_main.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$notice=$_GET['notice'];
|
||||||
|
|
||||||
|
$redirect = $_GET['redirect'];
|
||||||
|
$redirect_data = $_GET['redirectdata'];
|
||||||
|
|
||||||
|
switch($redirect) {
|
||||||
|
case 'roleadd':
|
||||||
|
$redirect_url = "&redirect=$redirect&redirectdata=$redirectdata";
|
||||||
|
break;
|
||||||
|
case 'roleattached':
|
||||||
|
$redirect_url = "&redirect=$redirect";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$redirect_url = '';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
switch($role) {
|
||||||
|
case 'volunteer':
|
||||||
|
// returns "notopenyet", "closed", or "open"
|
||||||
|
$reg_open = user_volunteer_registration_status();
|
||||||
|
break;
|
||||||
|
case 'committee':
|
||||||
|
$reg_open = 'notpermitted';
|
||||||
|
break;
|
||||||
|
case 'judge':
|
||||||
|
$reg_open = user_judge_registration_status();
|
||||||
|
break;
|
||||||
|
case 'fair':
|
||||||
|
$reg_open = 'notpermitted';
|
||||||
|
break;
|
||||||
|
case 'sponsor':
|
||||||
|
$reg_open = 'notpermitted';
|
||||||
|
break;
|
||||||
|
case 'parent': case 'alumni': case 'principal': case 'mentor':
|
||||||
|
/* Always open, because they could have been auto-created
|
||||||
|
$reg_open = 'open';
|
||||||
|
break;
|
||||||
|
case 'student':
|
||||||
|
default:
|
||||||
|
if($_GET['action']!="logout")
|
||||||
|
exit;
|
||||||
|
$reg_open = 'closed';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if($_POST['action']== 'login' ) {
|
||||||
|
|
||||||
|
$user = $_POST['username'];
|
||||||
|
$pass = $_POST['password'];
|
||||||
|
|
||||||
|
$accounts_id = try_login($user, $pass);
|
||||||
|
if($accounts_id == false) {
|
||||||
|
message_push(error(i18n("Invalid Email/Password")));
|
||||||
|
header("location: user_login.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$a = account_load($accounts_id);
|
||||||
|
$_SESSION['username']=$a['username'];
|
||||||
|
$_SESSION['email']=$a['email'];
|
||||||
|
$_SESSION['accounts_id']=$accounts_id;
|
||||||
|
$_SESSION['superuser'] = ($a['superuser'] == 'yes') ? 'yes' : 'no';
|
||||||
|
$_SESSION['roles']=array();
|
||||||
|
|
||||||
|
user_conference_load($accounts_id,$_SESSION['conferences_id']);
|
||||||
|
} else if($_GET['action']=="switchconference") {
|
||||||
|
//get rid of their current roles, and load their record for the new conference
|
||||||
|
$_SESSION['roles']=array();
|
||||||
|
user_conference_load($_SESSION['accounts_id'],$_SESSION['conferences_id']);
|
||||||
} else if($_GET['action']=='logout') {
|
} else if($_GET['action']=='logout') {
|
||||||
/* Session keys to skip on logout */
|
/* Session keys to skip on logout */
|
||||||
$skip = array('debug', 'lang', 'messages');
|
$skip = array('debug', 'lang', 'messages');
|
||||||
|
Loading…
Reference in New Issue
Block a user