forked from science-ation/science-ation
- Fix login check for an expired password
- Allow user_personal.php to handle committee members - Add password field if the editer in user_personal has access_super - Allow a committee member to edit anyone in user_personal.php - Convert auth_required to user_auth_required, and check for both a user type and an access level (if committee) - Convert the committee to the new user system (BIG change :) - Remove the ^M from admin/committees.php
This commit is contained in:
parent
1d7f5f9871
commit
2715d67aef
@ -1,500 +1,349 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation, version 2.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
auth_required('admin');
|
||||
|
||||
send_header("Administration - Committee Management");
|
||||
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>\n";
|
||||
?>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
|
||||
function getElement(e,f)
|
||||
{
|
||||
if(document.layers)
|
||||
{
|
||||
f=(f)?f:self;
|
||||
if(f.document.layers[e]) {
|
||||
return f.document.layers[e];
|
||||
}
|
||||
for(W=0;i<f.document.layers.length;W++) {
|
||||
return(getElement(e,fdocument.layers[W]));
|
||||
}
|
||||
}
|
||||
if(document.all) {
|
||||
return document.all[e];
|
||||
}
|
||||
return document.getElementById(e);
|
||||
}
|
||||
|
||||
|
||||
function actionChanged()
|
||||
{
|
||||
if(document.forms.memberaction.action.selectedIndex==1) //assign
|
||||
{
|
||||
getElement('assigndiv').style.display = 'block';
|
||||
|
||||
}
|
||||
else // edit or delete
|
||||
{
|
||||
getElement('assigndiv').style.display = 'none';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function actionSubmit()
|
||||
{
|
||||
if(document.forms.memberaction.action.selectedIndex==0)
|
||||
{
|
||||
alert('You must choose an action');
|
||||
return false;
|
||||
}
|
||||
if(document.forms.memberaction.committees_members_id.selectedIndex==0)
|
||||
{
|
||||
alert('You must choose a member');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(document.forms.memberaction.action.selectedIndex==3) //remove
|
||||
{
|
||||
return confirmClick('Are you sure you want to completely remove this member?');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
<?
|
||||
|
||||
if($_POST['addcommittee'])
|
||||
{
|
||||
//add a new committee
|
||||
mysql_query("INSERT INTO committees (name) VALUES ('".mysql_escape_string($_POST['addcommittee'])."')");
|
||||
echo happy(i18n("Committee successfully added"));
|
||||
}
|
||||
|
||||
if($_POST['committees_id'] && $_POST['committees_ord'])
|
||||
{
|
||||
//re-order the committees
|
||||
$x=0;
|
||||
$ids=$_POST['committees_id'];
|
||||
$ords=$_POST['committees_ord'];
|
||||
|
||||
while($ids[$x])
|
||||
{
|
||||
mysql_query("UPDATE committees SET ord='".$ords[$x]."' WHERE id='".$ids[$x]."'");
|
||||
$x++;
|
||||
}
|
||||
echo happy(i18n("Committees successfully re-ordered"));
|
||||
|
||||
}
|
||||
|
||||
if($_POST['action']=="assign")
|
||||
{
|
||||
if($_POST['committees_id'] && $_POST['committees_members_id'])
|
||||
{
|
||||
$q=mysql_query("SELECT * FROM committees_link WHERE committees_id='".$_POST['committees_id']."' AND committees_members_id='".$_POST['committees_members_id']."'");
|
||||
|
||||
if(!mysql_num_rows($q))
|
||||
{
|
||||
mysql_query("INSERT INTO committees_link (committees_id,committees_members_id) VALUES ('".$_POST['committees_id']."','".$_POST['committees_members_id']."')");
|
||||
echo happy(i18n("Successfully added member to committee"));
|
||||
}
|
||||
else
|
||||
echo error(i18n("That member already exists in that committee"));
|
||||
}
|
||||
else
|
||||
echo error(("You must choose both a member and a committee"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($_GET['deletecommittee'])
|
||||
{
|
||||
mysql_query("DELETE FROM committees WHERE id='".$_GET['deletecommittee']."'");
|
||||
echo happy(i18n("Committee removed"));
|
||||
|
||||
}
|
||||
|
||||
if($_POST['action']=="remove")
|
||||
{
|
||||
mysql_query("DELETE FROM committees_members WHERE id='".$_POST['committees_members_id']."'");
|
||||
mysql_query("DELETE FROM committees_link WHERE committees_members_id='".$_POST['committees_members_id']."'");
|
||||
echo happy(i18n("Committee member removed"));
|
||||
|
||||
}
|
||||
|
||||
if($_GET['unlinkmember'] && $_GET['unlinkcommittee'])
|
||||
{
|
||||
//unlink the member from the committee
|
||||
mysql_query("DELETE FROM committees_link WHERE committees_members_id='".$_GET['unlinkmember']."' AND committees_id='".$_GET['unlinkcommittee']."'");
|
||||
echo happy(i18n("Committee member unlinked from committee"));
|
||||
|
||||
}
|
||||
|
||||
if($_POST['add_member_to_committees_id'])
|
||||
{
|
||||
mysql_query("INSERT INTO committees_link (committees_id,committees_members_id) VALUES ('".$_POST['add_member_to_committees_id']."')");
|
||||
$edit=$_POST['committees_members_id'];
|
||||
}
|
||||
|
||||
if($_POST['add_member'])
|
||||
{
|
||||
mysql_query("INSERT INTO committees_members (name) VALUES ('".mysql_escape_string(stripslashes($_POST['add_member']))."')");
|
||||
$edit=mysql_insert_id();
|
||||
}
|
||||
|
||||
if($_POST['save'])
|
||||
{
|
||||
if(auth_has_access("super"))
|
||||
{
|
||||
//FIXME: deal with what the user can actually do based on their own permissions
|
||||
if($_POST['access_admin']=="Y") $a_admin='Y'; else $a_admin='N';
|
||||
if($_POST['access_config']=="Y") $a_config='Y'; else $a_config='N';
|
||||
if($_POST['access_super']=="Y") $a_super='Y'; else $a_super='N';
|
||||
|
||||
$access="access_admin='$a_admin', access_config='$a_config', access_super='$a_super', ";
|
||||
$pass="password='".mysql_escape_string(stripslashes($_POST['password']))."', ";
|
||||
}
|
||||
else if(intval($_POST['save']) == $_SESSION['committee_member_id'])
|
||||
{
|
||||
$access="";
|
||||
$pass="password='".mysql_escape_string(stripslashes($_POST['password']))."', ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$access="";
|
||||
$pass="";
|
||||
}
|
||||
|
||||
//check for unique email address
|
||||
$q=mysql_query("SELECT id FROM committees_members WHERE (email='".$_POST['email']."' OR emailprivate='".$_POST['email']."') AND id!='".$_POST['save']."'");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
$emailupdate="";
|
||||
echo notice(i18n("Cannot update email address. That address already exists for a different committee member"));
|
||||
}
|
||||
else
|
||||
$emailupdate="email='".mysql_escape_string(stripslashes($_POST['email']))."', ";
|
||||
|
||||
$emailprivate = trim(mysql_escape_string(stripslashes($_POST['emailprivate'])));
|
||||
if($emailprivate != '') {
|
||||
$q=mysql_query("SELECT id FROM committees_members WHERE (email='$emailprivate' OR emailprivate='$emailprivate') AND id!='".$_POST['save']."'");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
$emailprivateupdate="";
|
||||
echo notice(i18n("Cannot update private email address. That address already exists for a different committee member"));
|
||||
} else {
|
||||
$emailprivateupdate="emailprivate='$emailprivate', ";
|
||||
}
|
||||
} else {
|
||||
$emailprivateupdate="emailprivate='$emailprivate', ";
|
||||
}
|
||||
|
||||
mysql_query("UPDATE committees_members SET ".
|
||||
"name='".mysql_escape_string(stripslashes($_POST['name']))."', ".
|
||||
$pass.
|
||||
"organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
|
||||
$emailupdate.
|
||||
$emailprivateupdate.
|
||||
"phonehome='".mysql_escape_string(stripslashes($_POST['phonehome']))."', ".
|
||||
"phonework='".mysql_escape_string(stripslashes($_POST['phonework']))."', ".
|
||||
"phonecell='".mysql_escape_string(stripslashes($_POST['phonecell']))."', ".
|
||||
"fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ".
|
||||
$access.
|
||||
" displayemail='".$_POST['displayemail']."' ".
|
||||
" WHERE id='".$_POST['save']."'");
|
||||
|
||||
if($_POST['ord'])
|
||||
{
|
||||
$keys=@array_keys($_POST['ord']);
|
||||
foreach ($keys AS $key)
|
||||
{
|
||||
mysql_query("UPDATE committees_link SET title='".mysql_escape_string(stripslashes($_POST['titles'][$key]))."', ord='".$_POST['ord'][$key]."' WHERE committees_id='$key' AND committees_members_id='".$_POST['save']."'");
|
||||
echo mysql_error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if($_FILES['picture']['error']==UPLOAD_ERR_OK)
|
||||
{
|
||||
system("convert -sample 100 ".$_FILES['picture']['tmp_name']." ".$_SERVER['DOCUMENT_ROOT']."/board/".$_POST['save']."-thumb.jpg");
|
||||
move_uploaded_file($_FILES['picture']['tmp_name'],$_SERVER['DOCUMENT_ROOT']."/board/".$_POST['save'].".jpg");
|
||||
echo notice("Picture updated");
|
||||
echo "<br>\n";
|
||||
}
|
||||
*/
|
||||
|
||||
//print_r($config);
|
||||
|
||||
if($config['committees_executeonsave'])
|
||||
{
|
||||
echo happy(i18n("Executing:").$config['committees_executeonsave']);
|
||||
system($config['committees_executeonsave']);
|
||||
}
|
||||
|
||||
echo happy(i18n("Committee member saved"));
|
||||
|
||||
}
|
||||
|
||||
if($_POST['action']=="edit")
|
||||
{
|
||||
$edit=$_POST['committees_members_id'];
|
||||
}
|
||||
|
||||
if($_GET['edit'] || $edit)
|
||||
{
|
||||
if($_GET['edit'])
|
||||
$e=$_GET['edit'];
|
||||
else
|
||||
$e=$edit;
|
||||
$q=mysql_query("SELECT * FROM committees_members WHERE id='$e'");
|
||||
$r=mysql_fetch_object($q);
|
||||
echo "<h4>".i18n("Edit Committee Member")."</h4>";
|
||||
echo "<a href=\"committees.php\"><< ".i18n("Back to Committees Editor")."</a>\n";
|
||||
|
||||
echo "<form action=\"committees.php\" method=\"post\">\n";
|
||||
echo "<input type=\"hidden\" name=\"save\" value=\"$e\" />\n";
|
||||
|
||||
|
||||
echo "<table>";
|
||||
|
||||
echo "<tr><td>".i18n("Name").":</td><td><input size=\"25\" type=\"text\" name=\"name\" value=\"".htmlspecialchars($r->name)."\" /></td></tr>";
|
||||
|
||||
if(auth_has_access("super") || ($_SESSION['committee_member_id'] == intval($e)))
|
||||
echo "<tr><td>".i18n("Password").":</td><td><input size=\"15\" type=\"text\" name=\"password\" value=\"$r->password\" /></td></tr>";
|
||||
|
||||
$cq=mysql_query("SELECT committees.name, committees.id, committees_link.title, committees_link.ord FROM committees,committees_link WHERE committees_link.committees_id=committees.id AND committees_link.committees_members_id='$e' ORDER BY committees.name");
|
||||
|
||||
echo "<tr><td valign=\"top\">".i18n("Committees").":</td><td>";
|
||||
if(mysql_num_rows($cq))
|
||||
{
|
||||
echo "<table>";
|
||||
echo "<tr><th>".i18n("Committee")."</th><th>".i18n("Title in Committee")."</th><th>".i18n("Order")."</th></tr>";
|
||||
while($cr=mysql_fetch_object($cq))
|
||||
{
|
||||
echo "<tr><td>$cr->name</td><td><input type=\"text\" name=\"titles[$cr->id]\" value=\"$cr->title\" /></td><td><input type=\"text\" name=\"ord[$cr->id]\" value=\"$cr->ord\" size=\"3\" /></td></tr>";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
}
|
||||
else
|
||||
echo "None";
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr><td>".i18n("Organization").":</td><td><input size=\"25\" type=\"text\" name=\"organization\" value=\"$r->organization\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Email (Public)").":</td><td><input size=\"25\" type=\"text\" name=\"email\" value=\"$r->email\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Email (Private)").":</td><td><input size=\"25\" type=\"text\" name=\"emailprivate\" value=\"$r->emailprivate\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Display Emails").":</td><td>";
|
||||
if($r->displayemail=="N") $checked="checked=\"checked\""; else $checked="";
|
||||
echo "<input type=\"radio\" name=\"displayemail\" value=\"N\" $checked />".i18n("No");
|
||||
echo " ";
|
||||
if($r->displayemail=="Y") $checked="checked=\"checked\""; else $checked="";
|
||||
echo "<input type=\"radio\" name=\"displayemail\" value=\"Y\" $checked />".i18n("Yes");
|
||||
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr><td>".i18n("Phone (Home)").":</td><td><input size=\"15\" type=\"text\" name=\"phonehome\" value=\"$r->phonehome\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Phone (Work)").":</td><td><input size=\"15\" type=\"text\" name=\"phonework\" value=\"$r->phonework\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Phone (Cell)").":</td><td><input size=\"15\" type=\"text\" name=\"phonecell\" value=\"$r->phonecell\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Fax").":</td><td><input size=\"15\" type=\"text\" name=\"fax\" value=\"$r->fax\" /></td></tr>\n";
|
||||
|
||||
if(auth_has_access("super"))
|
||||
{
|
||||
echo "<tr><td align=\"center\" colspan=\"2\"><hr /></td></tr>";
|
||||
echo "<tr><td>".i18n("Access Controls").":</td><td>";
|
||||
if($r->access_admin=="Y") $checked="checked=\"checked\""; else $checked="";
|
||||
echo "<input type=\"checkbox\" name=\"access_admin\" value=\"Y\" $checked /> ".i18n("Administration")."<br />";
|
||||
if($r->access_config=="Y") $checked="checked=\"checked\""; else $checked="";
|
||||
echo "<input type=\"checkbox\" name=\"access_config\" value=\"Y\" $checked /> ".i18n("Configuration")."<br />";
|
||||
if($r->access_super=="Y") $checked="checked=\"checked\""; else $checked="";
|
||||
echo "<input type=\"checkbox\" name=\"access_super\" value=\"Y\" $checked /> ".i18n("Superuser")."<br />";
|
||||
|
||||
echo "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
echo "<tr><td align=\"center\" colspan=\"2\">";
|
||||
echo "<br /><br />";
|
||||
echo "<input type=\"submit\" value=\"".i18n("Save Member")."\" />\n";
|
||||
echo "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
echo "</form>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td>";
|
||||
|
||||
echo "<h4>".i18n("Add Committee")."</h4>\n";
|
||||
echo "<form method=\"post\"action=\"committees.php\">\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><td>".i18n("Committee Name").": </td><td><input type=\"text\" size=\"15\" name=\"addcommittee\" /></td>";
|
||||
echo " <td><input type=\"submit\" value=\"".i18n("Add")."\" /></td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
echo "</td><td width=\"40\"> </td><td>";
|
||||
|
||||
echo "<h4>".i18n("Add Committee Member")."</h4>\n";
|
||||
echo "<form method=\"post\" action=\"committees.php\">\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><td>".i18n("Member Name").": </td><td>";
|
||||
echo "<input type=\"text\" size=\"15\" name=\"add_member\" />\n";
|
||||
echo "</td>\n";
|
||||
echo " <td><input type=\"submit\" value=\"".i18n("Add")."\" /></td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
|
||||
echo "<hr />";
|
||||
echo "<h4>".i18n("Committee Member Management")."</h4>\n";
|
||||
echo "<form name=\"memberaction\" method=\"post\" action=\"committees.php\" onsubmit=\"return actionSubmit()\">\n";
|
||||
echo "<table>";
|
||||
echo "<tr><td>";
|
||||
echo "<select name=\"action\" onchange=\"javascript:actionChanged()\">";
|
||||
echo "<option value=\"\">".i18n("Choose")."</option>\n";
|
||||
echo "<option value=\"assign\">".i18n("Assign")."</option>\n";
|
||||
echo "<option value=\"edit\">".i18n("Edit")."</option>\n";
|
||||
echo "<option value=\"remove\">".i18n("Remove")."</option>\n";
|
||||
echo "</select>";
|
||||
|
||||
echo "</td><td>";
|
||||
$q=mysql_query("SELECT * FROM committees_members ORDER BY name");
|
||||
echo "<select name=\"committees_members_id\">";
|
||||
echo "<option value=\"\">".i18n("Select a Member")."</option>\n";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<option value=\"$r->id\">$r->name</option>\n";
|
||||
}
|
||||
echo "</select>";
|
||||
|
||||
echo "</td><td>";
|
||||
|
||||
|
||||
//The Assign Div
|
||||
echo "<div id=\"assigndiv\">";
|
||||
echo i18n("To Committee").": ";
|
||||
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
||||
echo "<select name=\"committees_id\">";
|
||||
echo "<option value=\"\">".i18n("Select a Committee")."</option>\n";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<option value=\"$r->id\">$r->name</option>\n";
|
||||
}
|
||||
echo "</select>";
|
||||
echo "</div>";
|
||||
|
||||
|
||||
//The Edit or Remove Div
|
||||
|
||||
echo "</td><td><input type=\"submit\" value=\"".i18n("Go")."\" /></td></tr>";
|
||||
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
|
||||
echo "<script language=\"javascript\" type=\"text/javascript\">actionChanged()</script>";
|
||||
echo "<hr />";
|
||||
|
||||
|
||||
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
echo "<h4>".i18n("Committees")."</h4>";
|
||||
echo "<form method=\"post\" action=\"committees.php\">\n";
|
||||
echo "<table>";
|
||||
echo "<tr><td colspan=\"2\"></td><td><b>".i18n("Public Email / Private Email")."</b></td></tr>";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"3\">";
|
||||
echo "<input type=\"hidden\" name=\"committees_id[]\" value=\"$r->id\" />";
|
||||
echo "<input size=\"2\" type=\"text\" name=\"committees_ord[]\" value=\"$r->ord\" />";
|
||||
echo " <b>$r->name</b>";
|
||||
|
||||
$q2=mysql_query("SELECT ".
|
||||
"committees_members.id,".
|
||||
"committees_members.name,".
|
||||
"committees_members.email,".
|
||||
"committees_members.emailprivate,".
|
||||
"committees_link.title, ".
|
||||
"committees_link.ord ".
|
||||
"FROM committees_members, committees_link ".
|
||||
"WHERE committees_link.committees_members_id=committees_members.id ".
|
||||
" AND committees_link.committees_id='$r->id'".
|
||||
" ORDER BY ord,name");
|
||||
if(mysql_num_rows($q2)==0)
|
||||
{
|
||||
echo " ";
|
||||
echo "<a title=\"Remove Committee\" onclick=\"return confirmClick('Are you sure you want to remove this committee?');\" href=\"committees.php?deletecommittee=$r->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=\"0\" alt=\"Remove Committee\" /></a>";
|
||||
}
|
||||
|
||||
echo "</td></tr>\n";
|
||||
echo mysql_error();
|
||||
while($r2=mysql_fetch_object($q2))
|
||||
{
|
||||
echo "<tr><td align=\"right\"> ";
|
||||
echo "<a title=\"Edit Member\" href=\"committees.php?edit=$r2->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\" border=\"0\" alt=\"Edit\" /></a>";
|
||||
echo " ";
|
||||
echo "<a title=\"Unlink Member from Committee\" onclick=\"return confirmClick('Are you sure you want to unlink this member from this committee?');\" href=\"committees.php?unlinkmember=$r2->id&unlinkcommittee=$r->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/undo.".$config['icon_extension']."\" border=\"0\" alt=\"Unlink\" /></a>";
|
||||
echo "</td>";
|
||||
echo "<td valign=\"top\">";
|
||||
echo " <b>$r2->name</b>";
|
||||
|
||||
if($r2->title) echo " - $r2->title ";
|
||||
|
||||
echo "</td><td>";
|
||||
|
||||
if($r2->email)
|
||||
{
|
||||
list($b,$a)=split("@",$r2->email);
|
||||
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
||||
}
|
||||
|
||||
if($r2->emailprivate)
|
||||
{
|
||||
if($r2->email) echo " <b>/</b> ";
|
||||
list($b,$a)=split("@",$r2->emailprivate);
|
||||
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
||||
}
|
||||
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
echo "<tr><td colspan=\"2\"> </td></tr>\n";
|
||||
}
|
||||
echo "<tr><td colspan=\"2\"><input type=\"submit\" value=\"".i18n("Re-Order Committees")."\" /></td></tr>\n";
|
||||
echo "</table>";
|
||||
echo "</form>\n";
|
||||
}
|
||||
}
|
||||
|
||||
send_footer();
|
||||
?>
|
||||
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation, version 2.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require_once("../common.inc.php");
|
||||
require_once("../committee.inc.php");
|
||||
|
||||
user_auth_required('committee', 'admin');
|
||||
|
||||
$users_id = intval($_POST['users_id']);
|
||||
|
||||
/* Some actions we want to redirect to the personal editor, so deal with those first */
|
||||
if($_POST['add_member'])
|
||||
{
|
||||
$u = user_create('committee');
|
||||
list($u['firstname'], $u['lastname']) = split(' ', $_POST['add_member']);
|
||||
user_save($u);
|
||||
header("location: {$config['SFIABDIRECTORY']}/user_personal.php?edit={$u['id']}");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($_POST['action'] == 'edit') {
|
||||
header("location: {$config['SFIABDIRECTORY']}/user_personal.php?edit=$users_id");
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Now, start the output for this page */
|
||||
send_header("Committee Management",
|
||||
array('Committee Main' => 'committee_main.php',
|
||||
'Administration' => 'admin/index.php' ));
|
||||
|
||||
$_SESSION['last_page'] = 'committee_management';
|
||||
?>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
|
||||
function getElement(e,f)
|
||||
{
|
||||
if(document.layers)
|
||||
{
|
||||
f=(f)?f:self;
|
||||
if(f.document.layers[e]) {
|
||||
return f.document.layers[e];
|
||||
}
|
||||
for(W=0;i<f.document.layers.length;W++) {
|
||||
return(getElement(e,fdocument.layers[W]));
|
||||
}
|
||||
}
|
||||
if(document.all) {
|
||||
return document.all[e];
|
||||
}
|
||||
return document.getElementById(e);
|
||||
}
|
||||
|
||||
|
||||
function actionChanged()
|
||||
{
|
||||
if(document.forms.memberaction.action.selectedIndex==1) //assign
|
||||
{
|
||||
getElement('assigndiv').style.display = 'block';
|
||||
|
||||
}
|
||||
else // edit or delete
|
||||
{
|
||||
getElement('assigndiv').style.display = 'none';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function actionSubmit()
|
||||
{
|
||||
if(document.forms.memberaction.action.selectedIndex==0)
|
||||
{
|
||||
alert('You must choose an action');
|
||||
return false;
|
||||
}
|
||||
if(document.forms.memberaction.users_id.selectedIndex==0)
|
||||
{
|
||||
alert('You must choose a member');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(document.forms.memberaction.action.selectedIndex==3) //remove
|
||||
{
|
||||
return confirmClick('Are you sure you want to completely remove this member?');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
<?
|
||||
|
||||
|
||||
if($_POST['addcommittee'])
|
||||
{
|
||||
//add a new committee
|
||||
mysql_query("INSERT INTO committees (name) VALUES ('".mysql_escape_string($_POST['addcommittee'])."')");
|
||||
echo happy(i18n("Committee successfully added"));
|
||||
}
|
||||
|
||||
if($_POST['committees_id'] && $_POST['committees_ord'])
|
||||
{
|
||||
//re-order the committees
|
||||
$x=0;
|
||||
$ids=$_POST['committees_id'];
|
||||
$ords=$_POST['committees_ord'];
|
||||
|
||||
while($ids[$x])
|
||||
{
|
||||
mysql_query("UPDATE committees SET ord='".$ords[$x]."' WHERE id='".$ids[$x]."'");
|
||||
$x++;
|
||||
}
|
||||
echo happy(i18n("Committees successfully re-ordered"));
|
||||
|
||||
}
|
||||
|
||||
if($_POST['action']=="assign")
|
||||
{
|
||||
if($_POST['committees_id'] && $_POST['users_id'])
|
||||
{
|
||||
$cid = intval($_POST['committees_id']);
|
||||
$q=mysql_query("SELECT * FROM committees_link WHERE committees_id='$cid' AND users_id='$users_id'");
|
||||
|
||||
if(!mysql_num_rows($q))
|
||||
{
|
||||
mysql_query("INSERT INTO committees_link (committees_id,users_id) VALUES ('$cid','$users_id')");
|
||||
echo happy(i18n("Successfully added member to committee"));
|
||||
}
|
||||
else
|
||||
echo error(i18n("That member already exists in that committee"));
|
||||
}
|
||||
else
|
||||
echo error(("You must choose both a member and a committee"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($_GET['deletecommittee'])
|
||||
{
|
||||
$del = intval($_GET['deletecommittee']);
|
||||
mysql_query("DELETE FROM committees WHERE id='$del'");
|
||||
echo happy(i18n("Committee removed"));
|
||||
}
|
||||
|
||||
if($_POST['action']=="remove")
|
||||
{
|
||||
user_delete($users_id, 'committee');
|
||||
mysql_query("DELETE FROM committees_link WHERE users_id='$users_id'");
|
||||
echo happy(i18n("Committee member removed"));
|
||||
}
|
||||
|
||||
if($_GET['unlinkmember'] && $_GET['unlinkcommittee'])
|
||||
{
|
||||
$mem = intval($_GET['unlinkmember']);
|
||||
$com = intval($_GET['unlinkcommittee']);
|
||||
//unlink the member from the committee
|
||||
mysql_query("DELETE FROM committees_link WHERE users_id='$mem' AND committees_id='$com'");
|
||||
echo happy(i18n("Committee member unlinked from committee"));
|
||||
}
|
||||
|
||||
/* This seems to be unused (there would also be an sql error on the INSERT :p) :
|
||||
if($_POST['add_member_to_committees_id'])
|
||||
{
|
||||
$add = intval($_POST['add_member_to_committees_id']);
|
||||
mysql_query("INSERT INTO committees_link (committees_id,users_id) VALUES ('$add')");
|
||||
$edit=$_POST['committees_members_id'];
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
echo "<table>";
|
||||
echo "<tr><td>";
|
||||
|
||||
echo "<h4>".i18n("Add Committee")."</h4>\n";
|
||||
echo "<form method=\"post\"action=\"committees.php\">\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><td>".i18n("Committee Name").": </td><td><input type=\"text\" size=\"15\" name=\"addcommittee\" /></td>";
|
||||
echo " <td><input type=\"submit\" value=\"".i18n("Add")."\" /></td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
echo "</td><td width=\"40\"> </td><td>";
|
||||
|
||||
echo "<h4>".i18n("Add Committee Member")."</h4>\n";
|
||||
echo "<form method=\"post\" action=\"committees.php\">\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><td>".i18n("Member Name").": </td><td>";
|
||||
echo "<input type=\"text\" size=\"15\" name=\"add_member\" />\n";
|
||||
echo "</td>\n";
|
||||
echo " <td><input type=\"submit\" value=\"".i18n("Add")."\" /></td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
|
||||
echo "<hr />";
|
||||
echo "<h4>".i18n("Committee Member Management")."</h4>\n";
|
||||
echo "<form name=\"memberaction\" method=\"post\" action=\"committees.php\" onsubmit=\"return actionSubmit()\">\n";
|
||||
echo "<table>";
|
||||
echo "<tr><td>";
|
||||
echo "<select name=\"action\" onchange=\"javascript:actionChanged()\">";
|
||||
echo "<option value=\"\">".i18n("Choose")."</option>\n";
|
||||
echo "<option value=\"assign\">".i18n("Assign")."</option>\n";
|
||||
echo "<option value=\"edit\">".i18n("Edit")."</option>\n";
|
||||
echo "<option value=\"remove\">".i18n("Remove")."</option>\n";
|
||||
echo "</select>";
|
||||
|
||||
echo "</td><td>";
|
||||
$q=mysql_query("SELECT * FROM users WHERE types LIKE '%committee%' ORDER BY firstname");
|
||||
echo "<select name=\"users_id\">";
|
||||
echo "<option value=\"\">".i18n("Select a Member")."</option>\n";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
$name = $r->firstname.' '.$r->lastname;
|
||||
echo "<option value=\"$r->id\">$name</option>\n";
|
||||
}
|
||||
echo "</select>";
|
||||
|
||||
echo "</td><td>";
|
||||
|
||||
|
||||
//The Assign Div
|
||||
echo "<div id=\"assigndiv\">";
|
||||
echo i18n("To Committee").": ";
|
||||
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
||||
echo "<select name=\"committees_id\">";
|
||||
echo "<option value=\"\">".i18n("Select a Committee")."</option>\n";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<option value=\"$r->id\">$r->name</option>\n";
|
||||
}
|
||||
echo "</select>";
|
||||
echo "</div>";
|
||||
|
||||
|
||||
//The Edit or Remove Div
|
||||
|
||||
echo "</td><td><input type=\"submit\" value=\"".i18n("Go")."\" /></td></tr>";
|
||||
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
|
||||
echo "<script language=\"javascript\" type=\"text/javascript\">actionChanged()</script>";
|
||||
echo "<hr />";
|
||||
|
||||
|
||||
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
echo "<h4>".i18n("Committees")."</h4>";
|
||||
echo "<form method=\"post\" action=\"committees.php\">\n";
|
||||
echo "<table>";
|
||||
echo "<tr><td colspan=\"2\"></td><td><b>".i18n("Public Email / Private Email")."</b></td></tr>";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"3\">";
|
||||
echo "<input type=\"hidden\" name=\"committees_id[]\" value=\"$r->id\" />";
|
||||
echo "<input size=\"2\" type=\"text\" name=\"committees_ord[]\" value=\"$r->ord\" />";
|
||||
echo " <b>$r->name</b>";
|
||||
|
||||
$q2=mysql_query("SELECT
|
||||
users.id,
|
||||
users.firstname,users.lastname,
|
||||
users.email,
|
||||
users_committee.emailprivate,
|
||||
committees_link.title,
|
||||
committees_link.ord
|
||||
FROM
|
||||
users, users_committee, committees_link
|
||||
WHERE
|
||||
users_committee.users_id=users.id
|
||||
AND committees_link.users_id=users.id
|
||||
AND committees_link.committees_id='$r->id'
|
||||
ORDER BY
|
||||
ord,firstname");
|
||||
|
||||
if(mysql_num_rows($q2)==0)
|
||||
{
|
||||
echo " ";
|
||||
echo "<a title=\"Remove Committee\" onclick=\"return confirmClick('Are you sure you want to remove this committee?');\" href=\"committees.php?deletecommittee=$r->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=\"0\" alt=\"Remove Committee\" /></a>";
|
||||
}
|
||||
|
||||
echo "</td></tr>\n";
|
||||
echo mysql_error();
|
||||
while($r2=mysql_fetch_object($q2))
|
||||
{
|
||||
echo "<tr><td align=\"right\"> ";
|
||||
echo "<a title=\"Edit Member\" href=\"{$config['SFIABDIRECTORY']}/user_personal.php?edit={$r2->id}\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/edit.{$config['icon_extension']}\" border=\"0\" alt=\"Edit\" /></a>";
|
||||
echo " ";
|
||||
echo "<a title=\"Unlink Member from Committee\" onclick=\"return confirmClick('Are you sure you want to unlink this member from this committee?');\" href=\"committees.php?unlinkmember=$r2->id&unlinkcommittee={$r->id}\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/undo.{$config['icon_extension']}\" border=\"0\" alt=\"Unlink\" /></a>";
|
||||
echo "</td>";
|
||||
echo "<td valign=\"top\">";
|
||||
$name = $r2->firstname.' '.$r2->lastname;
|
||||
echo " <b>$name</b>";
|
||||
|
||||
if($r2->title) echo " - $r2->title ";
|
||||
|
||||
echo "</td><td>";
|
||||
|
||||
if($r2->email)
|
||||
{
|
||||
list($b,$a)=split("@",$r2->email);
|
||||
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
||||
}
|
||||
|
||||
if($r2->emailprivate)
|
||||
{
|
||||
if($r2->email) echo " <b>/</b> ";
|
||||
list($b,$a)=split("@",$r2->emailprivate);
|
||||
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
||||
}
|
||||
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
echo "<tr><td colspan=\"2\"> </td></tr>\n";
|
||||
}
|
||||
echo "<tr><td colspan=\"2\"><input type=\"submit\" value=\"".i18n("Re-Order Committees")."\" /></td></tr>\n";
|
||||
echo "</table>";
|
||||
echo "</form>\n";
|
||||
}
|
||||
|
||||
send_footer();
|
||||
?>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?
|
||||
$mailqueries=array(
|
||||
"committee_all"=>array("name"=>"Committee Members (all)","query"=>
|
||||
"SELECT name, organization, email FROM committees_members WHERE deleted='N'"),
|
||||
"SELECT firstname, lastname, organization, email FROM users WHERE types LIKE '%committee' AND deleted='no'"),
|
||||
|
||||
"judges_all"=>array("name"=>"Judges from all years","query"=>
|
||||
"SELECT firstname, lastname, email FROM judges ORDER BY email"),
|
||||
|
@ -22,9 +22,13 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
auth_required('admin');
|
||||
send_header("Administration");
|
||||
require_once("../common.inc.php");
|
||||
require_once("../committee.inc.php");
|
||||
|
||||
user_auth_required('committee','admin');
|
||||
|
||||
send_header("Administration",
|
||||
array('Committee Main' => 'committee_main.php') );
|
||||
|
||||
echo "<br />";
|
||||
echo "<a href=\"registration.php\">".i18n("Participant Registration")."</a> <br />";
|
||||
|
@ -26,37 +26,37 @@ $report_committees_fields = array(
|
||||
'name' => 'Committee -- Full Name ',
|
||||
'header' => 'Name',
|
||||
'width' => 1.75,
|
||||
'table' => 'committees_members.name'),
|
||||
'table' => "CONCAT(users.firstname, ' ', users.lastname)",
|
||||
|
||||
'email' => array(
|
||||
'name' => 'Committee -- Email',
|
||||
'header' => 'Email',
|
||||
'width' => 2.0,
|
||||
'table' => 'committees_members.email'),
|
||||
'table' => 'users.email'),
|
||||
|
||||
'phone_home' => array(
|
||||
'name' => 'Committees -- Phone (Home)',
|
||||
'header' => 'Phone(Home)',
|
||||
'width' => 1,
|
||||
'table' => 'committees_members.phonehome'),
|
||||
'table' => 'users.phonehome'),
|
||||
|
||||
'phone_work' => array(
|
||||
'name' => 'Committees -- Phone (Work)',
|
||||
'header' => 'Phone(Work)',
|
||||
'width' => 1.25,
|
||||
'table' => 'committees_members.phonework'),
|
||||
'table' => 'users.phonework'),
|
||||
|
||||
'phone_cel' => array(
|
||||
'name' => 'Committees -- Phone (Cel)',
|
||||
'header' => 'Phone(Cel)',
|
||||
'width' => 1,
|
||||
'table' => 'committees_members.phonecel'),
|
||||
'table' => 'users.phonecell'),
|
||||
|
||||
'organization' => array(
|
||||
'name' => 'Committees -- Organization',
|
||||
'header' => 'Organization',
|
||||
'width' => 2,
|
||||
'table' => 'committees_members.organization'),
|
||||
'table' => 'users.organization'),
|
||||
|
||||
'static_text' => array(
|
||||
'name' => 'Static Text (useful for labels)',
|
||||
@ -78,14 +78,14 @@ $report_committees_fields = array(
|
||||
$teams_where = '';
|
||||
if(in_array('teams', $components)) {
|
||||
$teams_from = ",committees_teams_link, committees_teams";
|
||||
$teams_where = "AND committees_teams_link.committees_id=committees_members.id
|
||||
$teams_where = "AND committees_teams_link.committees_id=users.id
|
||||
AND committees_teams_link.year='$year'
|
||||
AND committees_teams.id=committees_teams_link.committees_teams_id
|
||||
AND committees_teams.year='$year'";
|
||||
}
|
||||
*/
|
||||
$q = " FROM
|
||||
committees_members
|
||||
users
|
||||
WHERE
|
||||
1
|
||||
";
|
||||
|
17
committee.inc.php
Normal file
17
committee.inc.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?
|
||||
require_once("user.inc.php");
|
||||
|
||||
function committee_auth_has_access($access="")
|
||||
{
|
||||
|
||||
switch($access) {
|
||||
case 'config': return ($_SESSION['access_config'] == 'yes') ? true : false;
|
||||
case 'admin': return ($_SESSION['access_admin'] == 'yes') ? true : false;
|
||||
case 'super': return ($_SESSION['access_super'] == 'yes') ? true : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -1,5 +1,21 @@
|
||||
<?
|
||||
|
||||
require_once('committee.inc.php');
|
||||
require_once('user.inc.php');
|
||||
|
||||
function auth_has_access($access="")
|
||||
{
|
||||
return committee_auth_has_access($access);
|
||||
}
|
||||
|
||||
function auth_required($access="")
|
||||
{
|
||||
return user_auth_required('committee', $access);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$accesscache=array();
|
||||
|
||||
function auth_has_access($access="")
|
||||
@ -16,6 +32,8 @@ function auth_has_access($access="")
|
||||
$q=mysql_query("SELECT access_admin, access_config, access_super FROM committees_members WHERE email='".mysql_escape_string($_SESSION['email'])."' AND id='".$_SESSION['committee_member_id']."' AND deleted='N'");
|
||||
|
||||
$r=mysql_fetch_object($q);
|
||||
echo mysql_error();
|
||||
|
||||
$accesscache['admin']=$r->access_admin;
|
||||
$accesscache['config']=$r->access_config;
|
||||
$accesscache['super']=$r->access_super;
|
||||
@ -44,5 +62,6 @@ function auth_required($access="")
|
||||
exit;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -11,20 +11,20 @@
|
||||
$r=mysql_fetch_object($q);
|
||||
$_SESSION['email']=$r->email;
|
||||
$_SESSION['committee_member_id']=$r->id;
|
||||
send_header("Committee Login");
|
||||
send_header("Committee Login", array());
|
||||
echo happy(i18n("Successfully logged in"));
|
||||
echo i18n("Use the menu on the left to access the committee pages");
|
||||
}
|
||||
else
|
||||
{
|
||||
send_header("Committee Login");
|
||||
send_header("Committee Login", array());
|
||||
echo error(i18n("Invalid Email/Password"));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
send_header("Committee Login");
|
||||
send_header("Committee Login", array());
|
||||
echo error(i18n("Email/Password missing"));
|
||||
}
|
||||
}
|
||||
@ -32,13 +32,13 @@
|
||||
{
|
||||
unset($_SESSION['email']);
|
||||
unset($_SESSION['committee_member_id']);
|
||||
send_header("Committee Login");
|
||||
send_header("Committee Login", array());
|
||||
echo notice(i18n("You have been successfully logged out"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
send_header("Committee Login");
|
||||
send_header("Committee Login", array());
|
||||
|
||||
?>
|
||||
<form method="post" action="committee_login.php">
|
||||
|
64
committee_main.php
Normal file
64
committee_main.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||
Copyright (C) 2007 David Grant <dave@lightbox.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation, version 2.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require_once("common.inc.php");
|
||||
require_once("user.inc.php");
|
||||
require_once("user_page.inc.php");
|
||||
|
||||
user_auth_required('committee');
|
||||
|
||||
send_header("Committee Main", array());
|
||||
|
||||
switch($_GET['notice']) {
|
||||
case 'password_changed':
|
||||
echo happy(i18n('Your password has been successfully updated'));
|
||||
break;
|
||||
case 'already_logged_in':
|
||||
echo error(i18n('You are already logged in, please use the [Logout] link in the upper right to logout'));
|
||||
break;
|
||||
case 'no_auth':
|
||||
echo error(i18n('You do not have permission to view that page'));
|
||||
break;
|
||||
}
|
||||
|
||||
//only display the named greeting if we have their name
|
||||
echo i18n("Hello <b>%1</b>",array($_SESSION['name']));
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
|
||||
echo i18n('Things you can do').':<br />';
|
||||
echo '<ul>';
|
||||
echo '<li><a href="user_personal.php">'.i18n('Edit My Profile').'</a></li>';
|
||||
if(committee_auth_has_access('admin')) {
|
||||
echo '<li><a href="admin/">'.i18n('Administer the Fair').'</a></li>';
|
||||
}
|
||||
if(committee_auth_has_access('config')) {
|
||||
echo '<li><a href="config/">'.i18n('Configure SFIAB').'</a></li>';
|
||||
}
|
||||
echo '<li><a href="user_password.php">'.i18n('Change My Password').'</a></li>';
|
||||
echo '</ul>';
|
||||
|
||||
send_footer();
|
||||
?>
|
@ -23,25 +23,28 @@
|
||||
?>
|
||||
<?
|
||||
require("common.inc.php");
|
||||
send_header("Committee List");
|
||||
send_header("Committee List", array());
|
||||
|
||||
echo "<table>";
|
||||
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
$q2=mysql_query("SELECT ".
|
||||
"committees_members.id,".
|
||||
"committees_members.name,".
|
||||
"committees_members.email,".
|
||||
"committees_members.emailprivate,".
|
||||
"committees_members.displayemail,".
|
||||
"committees_link.title, ".
|
||||
"committees_link.ord ".
|
||||
"FROM committees_members, committees_link ".
|
||||
"WHERE committees_link.committees_members_id=committees_members.id ".
|
||||
" AND committees_link.committees_id='$r->id'".
|
||||
" ORDER BY ord,name");
|
||||
|
||||
$q2=mysql_query("SELECT
|
||||
users.id,
|
||||
users.firstname,users.lastname,
|
||||
users.email,
|
||||
users_committee.emailprivate,
|
||||
users_committee.displayemail,
|
||||
committees_link.title,
|
||||
committees_link.ord
|
||||
FROM
|
||||
users, users_committee, committees_link
|
||||
WHERE
|
||||
users_committee.users_id=users.id
|
||||
AND committees_link.users_id=users.id
|
||||
AND committees_link.committees_id='$r->id'
|
||||
ORDER BY
|
||||
ord,firstname");
|
||||
|
||||
//if there's nobody in this committee, then just skip it and go on to the next one.
|
||||
if(mysql_num_rows($q2)==0)
|
||||
@ -56,11 +59,12 @@
|
||||
{
|
||||
$output=$config['committee_publiclayout'];
|
||||
|
||||
$output=str_replace("name",$r2->name,$output);
|
||||
$name=$r2->firstname.' '.$r2->lastname;
|
||||
$output=str_replace("name",$name,$output);
|
||||
$output=str_replace("title",$r2->title,$output);
|
||||
|
||||
//make sure we do emailprivate before email so we dont match the wrong thing
|
||||
if($r2->emailprivate && $r2->displayemail=='Y')
|
||||
if($r2->emailprivate && $r2->displayemail=='yes')
|
||||
{
|
||||
list($b,$a)=split("@",$r2->emailprivate);
|
||||
$output=str_replace("emailprivate","<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>",$output);
|
||||
@ -68,7 +72,7 @@
|
||||
else
|
||||
$output=str_replace("emailprivate","",$output);
|
||||
|
||||
if($r2->email && $r2->displayemail=='Y')
|
||||
if($r2->email && $r2->displayemail=='yes')
|
||||
{
|
||||
list($b,$a)=split("@",$r2->email);
|
||||
$output=str_replace("email","<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>",$output);
|
||||
|
@ -515,7 +515,7 @@ if(auth_has_access("admin") || auth_has_access("config") || auth_has_access("sup
|
||||
}
|
||||
else
|
||||
{
|
||||
?><li><a href="<?=$config['SFIABDIRECTORY']?>/committee_login.php"><?=i18n("Committee Login")?></a></li><?
|
||||
?><li><a href="<?=$config['SFIABDIRECTORY']?>/user_login.php?type=committee"><?=i18n("Committee Login")?></a></li><?
|
||||
}
|
||||
?></ul>
|
||||
<br />
|
||||
|
@ -1 +1 @@
|
||||
61
|
||||
63
|
||||
|
87
db/db.update.62.php
Normal file
87
db/db.update.62.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?
|
||||
|
||||
/* This file may contain 2 functions, a db_update_pre() and a db_update_post()
|
||||
* db_update_pre() is called before the SQL patch is applied, and as expected,
|
||||
* db_update_post() is called after.
|
||||
*
|
||||
* These functions are called from the main db_update.php file, and included
|
||||
* once, so any global variables declared in here WILL REMAIN across both
|
||||
* calls. meaning you can pull some stuff out of the database in _pre(), and
|
||||
* then the patch will be applied, and they it can be inserted back into the
|
||||
* database in _post(). */
|
||||
|
||||
$committee = array();
|
||||
function db_update_pre()
|
||||
{
|
||||
global $committee;
|
||||
$q = mysql_query("SELECT * FROM committees_members");
|
||||
while($r = mysql_fetch_assoc($q)) {
|
||||
$committee[] = $r;
|
||||
}
|
||||
}
|
||||
|
||||
function db_update_post()
|
||||
{
|
||||
global $committee;
|
||||
global $config;
|
||||
|
||||
foreach($committee as $c) {
|
||||
list($fn, $ln) = split(' ', $c['name'], 2);
|
||||
$username = $c['email'];
|
||||
$fn = mysql_escape_string($fn);
|
||||
$ln = mysql_escape_string($ln);
|
||||
if($config['committee_password_expiry_days'] > 0) {
|
||||
$passwordexpiry = "DATE_ADD(CURDATE(),
|
||||
INTERVAL {$config['committee_password_expiry_days']} DAY)";
|
||||
} else {
|
||||
$passwordexpiry = "'0000-00-00'";
|
||||
}
|
||||
|
||||
$deleted = ($c['deleted'] == 'Y') ? 'yes' : 'no';
|
||||
$q = "INSERT INTO users
|
||||
(`types`,`firstname`,`lastname`,`username`,`password`,`passwordexpiry`,
|
||||
`email`,`phonehome`,`phonework`,`phonecell`,`fax`,`organization`,
|
||||
`created`,`deleted`)
|
||||
VALUES ('committee','$fn', '$ln', '$username',
|
||||
'".mysql_escape_string($c['password'])."',
|
||||
$passwordexpiry,
|
||||
'{$c['email']}',
|
||||
'{$c['phonehome']}',
|
||||
'{$c['phonework']}',
|
||||
'{$c['phonecell']}',
|
||||
'{$c['fax']}',
|
||||
'".mysql_escape_string($c['organization'])."',
|
||||
NOW(),
|
||||
'$deleted')";
|
||||
mysql_query($q);
|
||||
echo "$q\n";
|
||||
$id = mysql_insert_id();
|
||||
|
||||
$access_admin = ($c['access_admin'] == 'Y') ? 'yes' : 'no';
|
||||
$access_config = ($c['access_config'] == 'Y') ? 'yes' : 'no';
|
||||
$access_super = ($c['access_super'] == 'Y') ? 'yes' : 'no';
|
||||
$displayemail = ($c['displayemail'] == 'Y') ? 'yes' : 'no';
|
||||
$q = "INSERT INTO users_committee(`users_id`,`emailprivate`,
|
||||
`ord`,`displayemail`,`access_admin`,`access_config`,
|
||||
`access_super`) VALUES (
|
||||
'$id', '{$c['emailprivate']}',
|
||||
'{$c['ord']}',
|
||||
'$displayemail',
|
||||
'$access_admin',
|
||||
'$access_config',
|
||||
'$access_super')";
|
||||
mysql_query($q);
|
||||
echo "$q\n";
|
||||
echo mysql_error();
|
||||
|
||||
/* Update committee links */
|
||||
$q = "UPDATE committees_link SET users_id='$id'
|
||||
WHERE committees_members_id='{$c['id']}'";
|
||||
mysql_query($q);
|
||||
echo "$q\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
12
db/db.update.62.sql
Normal file
12
db/db.update.62.sql
Normal file
@ -0,0 +1,12 @@
|
||||
ALTER TABLE `users_committee` CHANGE `displayemail` `displayemail` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no',
|
||||
CHANGE `access_admin` `access_admin` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no',
|
||||
CHANGE `access_config` `access_config` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no',
|
||||
CHANGE `access_super` `access_super` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
|
||||
|
||||
ALTER TABLE `committees_link` ADD `users_id` INT NOT NULL AFTER `committees_members_id` ;
|
||||
|
||||
INSERT INTO `emails` ( `id` , `val` , `name` , `description` , `from` , `subject` , `body` , `type` )
|
||||
VALUES (
|
||||
'', 'committee_recover_password', 'Committee Members - Recover Password', 'Recover the password for a committee member if they submit a ''forgot password'' request', '', 'Committee Member for [FAIRNAME]', 'We have received a request for the recovery of your password from this email address. Please find your new password below:\n\nCommittee Member Email Address: [EMAIL]\nCommittee Member Password: [PASSWORD] ', 'system'
|
||||
);
|
||||
|
12
db/db.update.63.sql
Normal file
12
db/db.update.63.sql
Normal file
@ -0,0 +1,12 @@
|
||||
ALTER TABLE `committees_link` DROP `committees_members_id` ;
|
||||
|
||||
DROP TABLE `committees_members` ;
|
||||
|
||||
ALTER TABLE `users` ADD `oldpassword` VARCHAR( 32 ) NOT NULL AFTER `passwordexpiry` ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
202
user.inc.php
202
user.inc.php
@ -31,7 +31,6 @@ $user_what = array('student'=>'Participant', 'judge' => 'Judge',
|
||||
'committee'=>'Committee Member','volunteer' => 'Volunteer',
|
||||
'region'=>'Region');
|
||||
|
||||
|
||||
function user_load_region($u)
|
||||
{
|
||||
/* Double check, make sure the user is of this type */
|
||||
@ -72,14 +71,15 @@ function user_load_committee($u)
|
||||
WHERE users_id='{$u['id']}'");
|
||||
if(mysql_num_rows($q)!=1) return false;
|
||||
|
||||
$r = mysel_fetch_object($q);
|
||||
$r = mysql_fetch_object($q);
|
||||
$ret = array();
|
||||
$ret['emailprivate'] = $r->emailprivate;
|
||||
$ret['ord'] = intval($r->ord);
|
||||
$ret['displayemail'] = ($r->displayemail == 'Y') ? 'Y' : 'N';
|
||||
$ret['access_admin'] = ($r->access_admin == 'Y') ? 'Y' : 'N';
|
||||
$ret['access_config'] = ($r->access_config == 'Y') ? 'Y' : 'N';
|
||||
$ret['access_super'] = ($r->access_super == 'Y') ? 'Y' : 'N';
|
||||
$ret['displayemail'] = ($r->displayemail == 'yes') ? 'yes' : 'no';
|
||||
$ret['access_admin'] = ($r->access_admin == 'yes') ? 'yes' : 'no';
|
||||
$ret['access_config'] = ($r->access_config == 'yes') ? 'yes' : 'no';
|
||||
$ret['access_super'] = ($r->access_super == 'yes') ? 'yes' : 'no';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ function user_load_volunteer($u)
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function user_load($user, $load_full=false, $force_type=false)
|
||||
function user_load($user, $load_full=false)
|
||||
{
|
||||
$id = 0;
|
||||
|
||||
@ -136,13 +136,6 @@ function user_load($user, $load_full=false, $force_type=false)
|
||||
/* Turn the type into an array, because there could be more than one */
|
||||
$ts = explode(',', $ret['types']);
|
||||
$ret['types'] = $ts; /* Now we can use in_array($ret['type'], 'judge') ; */
|
||||
|
||||
/* Set the current type if there's only one */
|
||||
if(count($ret['types']) == 1) {
|
||||
$ret['type'] = $ret['types'][0];
|
||||
} else {
|
||||
$ret['type'] = false;
|
||||
}
|
||||
} else {
|
||||
$ret = $user;
|
||||
}
|
||||
@ -150,16 +143,17 @@ function user_load($user, $load_full=false, $force_type=false)
|
||||
if($load_full) {
|
||||
$r = true;
|
||||
foreach($ret['types'] as $t) {
|
||||
if($ret['load_full'] == true) continue;
|
||||
/* These all pass $ret by reference, and can modify
|
||||
* $ret */
|
||||
$r = call_user_func("user_load_$type", $ret);
|
||||
if($r == false) return false;
|
||||
$r = call_user_func("user_load_$t", $ret);
|
||||
if(!is_array($r)) return false;
|
||||
|
||||
/* It is important that each type database doesn't
|
||||
have conflicting column names */
|
||||
foreach($r as $k->$v) {
|
||||
foreach($r as $k=>$v) {
|
||||
if(array_key_exists($k, $ret)) {
|
||||
echo "DATABSE DESIGN ERROR, duplicate user key $k";
|
||||
echo "DATABASE DESIGN ERROR, duplicate user key $k";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -171,13 +165,57 @@ function user_load($user, $load_full=false, $force_type=false)
|
||||
}
|
||||
|
||||
/* Do this assignment without recursion :) */
|
||||
unset($ret['orig']);
|
||||
$orig = $ret;
|
||||
$ret['orig'] = $orig;
|
||||
|
||||
// echo "<pre>User load returning:\n";
|
||||
// print_r($ret);
|
||||
// echo "</pre>";
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
function user_save_volunteer($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_save_committee($u)
|
||||
{
|
||||
$fields = array('emailprivate','ord','displayemail','access_admin',
|
||||
'access_config','access_super');
|
||||
//echo "<pre>";
|
||||
// print_r($u);
|
||||
// echo "</pre>";
|
||||
$set = '';
|
||||
|
||||
foreach($fields as $f) {
|
||||
if($u[$f] == $u['orig'][$f]) continue;
|
||||
|
||||
if($set != '') $set .=',';
|
||||
|
||||
$data = mysql_escape_string(stripslashes($u[$f]));
|
||||
$set .= "$f='$data'";
|
||||
}
|
||||
if($set != "") {
|
||||
$query = "UPDATE users_committee SET $set WHERE users_id='{$u['id']}'";
|
||||
mysql_query($query);
|
||||
}
|
||||
}
|
||||
|
||||
function user_save_judge($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_save_student($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_save_region($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_save($u)
|
||||
{
|
||||
$fields = array('firstname','lastname','username','password',
|
||||
@ -206,6 +244,92 @@ function user_save($u)
|
||||
// echo "query=[$query]";
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
/* If this was a full load, do a full save */
|
||||
if($u['load_full'] == true) {
|
||||
foreach($u['types'] as $t) {
|
||||
call_user_func("user_save_$t", $u);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function user_delete_committee($u)
|
||||
{
|
||||
mysql_query("DELETE FROM users_committee WHERE users_id='{$u['id']}'");
|
||||
mysql_query("DELETE FROM committees_link WHERE users_id='{$u['id']}'");
|
||||
}
|
||||
|
||||
function user_delete_volunteer($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_delete_judge($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_delete_region($u)
|
||||
{
|
||||
}
|
||||
function user_delete_student($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_delete($u, $type=false)
|
||||
{
|
||||
$finish_delete = false;
|
||||
|
||||
if(!is_array($u)) {
|
||||
$u = user_load($u);
|
||||
}
|
||||
if($type != false) {
|
||||
if(!in_array($type, $u['types'])) {
|
||||
/* Hum, type specified, but the user is not this type,
|
||||
* so, i guess we're done. */
|
||||
return;
|
||||
}
|
||||
if(count($u['types']) > 1) {
|
||||
/* Don't delete the whole user */
|
||||
$types='';
|
||||
foreach($u['types'] as $t) {
|
||||
if($t == $type) continue;
|
||||
if($types != '') $types .= ',';
|
||||
$types .= $t;
|
||||
}
|
||||
mysql_query("UPDATE users SET types='$types' WHERE id='{$u['id']}'");
|
||||
} else {
|
||||
$finish_delete = true;
|
||||
}
|
||||
call_user_func("user_delete_$type", $u);
|
||||
} else {
|
||||
/* Delete the whole user */
|
||||
foreach($u['types'] as $t) call_user_func("user_delete_$t", $u);
|
||||
|
||||
$finish_delete = true;
|
||||
}
|
||||
if($finish_delete == true) {
|
||||
mysql_query("DELETE FROM users WHERE id='{$u['id']}'");
|
||||
}
|
||||
}
|
||||
|
||||
function user_create($type)
|
||||
{
|
||||
mysql_query("INSERT INTO users (`types`,`created`) VALUES ('$type', NOW())");
|
||||
$uid = mysql_insert_id();
|
||||
|
||||
switch($type) {
|
||||
case 'volunteer':
|
||||
case 'student':
|
||||
case 'judge':
|
||||
case 'region':
|
||||
break;
|
||||
case 'committee':
|
||||
mysql_query("INSERT INTO users_committee(`users_id`) VALUES ('$uid')");
|
||||
break;
|
||||
}
|
||||
return user_load($uid, true);
|
||||
}
|
||||
|
||||
|
||||
@ -235,7 +359,7 @@ function user_valid_password($pass)
|
||||
/* Perform some checks. Make sure the person is logged in, and that their
|
||||
* password hasn't expired (the password_expired var is set in the login page)
|
||||
*/
|
||||
function user_auth_required($type, $check_expiry=true)
|
||||
function user_auth_required($type, $access='')
|
||||
{
|
||||
if(!isset($_SESSION['users_type'])) {
|
||||
header("location: user_login.php?type=$type¬ice=auth_required");
|
||||
@ -247,10 +371,22 @@ function user_auth_required($type, $check_expiry=true)
|
||||
exit;
|
||||
}
|
||||
|
||||
if($_SESSION['password_expired'] == true && $check_expiry==true) {
|
||||
if($_SESSION['password_expired'] == true) {
|
||||
header("location: user_password.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($access != '') {
|
||||
if($type != 'committee') {
|
||||
echo "CRITICAL ERROR, cannot check access in user_auth_required without specifying type=committee";
|
||||
exit;
|
||||
}
|
||||
|
||||
if(committee_auth_has_access($access) == false) {
|
||||
header("Location: ".$config['SFIABDIRECTORY']."/committee_main.php?notice=no_auth");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -280,17 +416,21 @@ function user_personal_fields($type)
|
||||
switch($type) {
|
||||
case 'volunteer':
|
||||
$f = array();
|
||||
break;
|
||||
case 'committee':
|
||||
$f = array('workphone','fax');
|
||||
$f = array('phonework','fax');
|
||||
break;
|
||||
case 'judge':
|
||||
$f = array();
|
||||
break;
|
||||
case 'student':
|
||||
$f = array();
|
||||
break;
|
||||
case 'region':
|
||||
$f = array();
|
||||
break;
|
||||
}
|
||||
return array_merge($all_fields, $f);
|
||||
return null;
|
||||
}
|
||||
|
||||
function user_personal_required_fields($type)
|
||||
@ -299,17 +439,21 @@ function user_personal_required_fields($type)
|
||||
switch($type) {
|
||||
case 'volunteer':
|
||||
$f = array();
|
||||
break;
|
||||
case 'committee':
|
||||
$f = array();
|
||||
break;
|
||||
case 'judge':
|
||||
$f = array();
|
||||
break;
|
||||
case 'student':
|
||||
$f = array();
|
||||
break;
|
||||
case 'region':
|
||||
$f = array();
|
||||
break;
|
||||
}
|
||||
return array_merge($all_fields, $f);
|
||||
return null;
|
||||
}
|
||||
|
||||
function user_personal_info_status($u = false)
|
||||
@ -350,13 +494,15 @@ function user_update_complete(&$u, $status)
|
||||
function user_committee_login($u)
|
||||
{
|
||||
/* Double check, make sure the user is of this type */
|
||||
if(!in_array('committee', $u['types'])) return false;
|
||||
if(!in_array('committee', $u['types'])) {
|
||||
echo "ERROR: attempted to login committee on a non-committee user\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$u = user_load($u, true);
|
||||
|
||||
$_SESSION['access_admin'] = ($u['access_admin'] == 'Y') ? true : false;
|
||||
$_SESSION['access_config'] = ($u['access_config'] == 'Y') ? true : false;
|
||||
$_SESSION['access_super'] = ($u['access_super'] == 'Y') ? true : false;
|
||||
$_SESSION['access_admin'] = $u['access_admin'];// == 'yes') ? true : false;
|
||||
$_SESSION['access_config'] = $u['access_config'];// == 'yes') ? true : false;
|
||||
$_SESSION['access_super'] = $u['access_super'];// == 'yes') ? true : false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,7 +81,6 @@
|
||||
$reg_open = user_volunteer_registration_status();
|
||||
break;
|
||||
case 'committee':
|
||||
exit;
|
||||
$reg_open = 'notpermitted';
|
||||
break;
|
||||
case 'judge':
|
||||
@ -105,33 +104,53 @@
|
||||
exit;
|
||||
} else {
|
||||
$u = user_load($id);
|
||||
|
||||
/* Make sure $type is in their types */
|
||||
if(!in_array($type, $u['types'])) {
|
||||
/* Huh, someone is fudging with the HTML, get
|
||||
* out before touching the session */
|
||||
header("location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SESSION['name']="{$u['firstname']} {$u['lastname']}";
|
||||
$_SESSION['username']=$u['username'];
|
||||
$_SESSION['email']=$u['email'];
|
||||
$_SESSION['users_id']=$u['id'];
|
||||
$_SESSION['users_type']=$u['type'];
|
||||
$_SESSION['users_type']=$type;
|
||||
|
||||
/* Check for an expired password */
|
||||
$now = date('Y-m-d H:i:s');
|
||||
if($now > $u['passwordexpiry']) {
|
||||
$_SESSION['password_expired'] = true;
|
||||
/* The main page (or any other user page) will catch this now and
|
||||
* require them to set a password */
|
||||
if($u['passwordexpiry'] == NULL) {
|
||||
unset($_SESSION['password_expired']);
|
||||
} else {
|
||||
$now = date('Y-m-d H:i:s');
|
||||
if($now > $u['passwordexpiry']) {
|
||||
$_SESSION['password_expired'] = true;
|
||||
/* The main page (or any other user page) will catch this now and
|
||||
* require them to set a password */
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: call a type sepcific function
|
||||
to set type specific session variables */
|
||||
/* Call login functions for each type, so multirole
|
||||
* users can easily switch */
|
||||
foreach($u['types'] as $t) {
|
||||
if(is_callable("user_{$t}_login")) {
|
||||
call_user_func_array("user_{$t}_login", array($u));
|
||||
}
|
||||
}
|
||||
|
||||
mysql_query("UPDATE users SET lastlogin=NOW()
|
||||
WHERE id={$u['id']}");
|
||||
|
||||
if(count($u['types']) > 1) {
|
||||
/* Setup multirole so a multirole user can switch if they want to
|
||||
* without logging in/out */
|
||||
if($u['types'] > 1) {
|
||||
$_SESSION['multirole'] = true;
|
||||
header("location: user_multirole.php");
|
||||
} else {
|
||||
$_SESSION['multirole'] = false;
|
||||
header("location: {$type}_main.php");
|
||||
}
|
||||
/* Now finally, take them to whatever main page they logged in for */
|
||||
header("location: {$type}_main.php");
|
||||
|
||||
exit;
|
||||
}
|
||||
@ -152,7 +171,10 @@
|
||||
$keys = array_keys($_SESSION);
|
||||
foreach($keys as $k) unset($_SESSION[$k]);
|
||||
|
||||
header("location: user_login.php?type=$type¬ice=logged_out");
|
||||
if($type != '')
|
||||
header("location: user_login.php?type=$type¬ice=logged_out");
|
||||
if($type != '')
|
||||
header("location: user_login.php?type=$type¬ice=logged_out");
|
||||
exit;
|
||||
}
|
||||
else if($_GET['action']=="recover")
|
||||
@ -210,6 +232,11 @@
|
||||
$pchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
for($x=0;$x<12;$x++) $password .= $pchars{rand(0,61)};
|
||||
|
||||
/* Save their old password so it can be recovered if someone is just trying
|
||||
* to reset someones password */
|
||||
mysql_query("UPDATE users SET oldpassword=password WHERE id={$r->id}");
|
||||
|
||||
/* Set the new password, and force it to expire */
|
||||
mysql_query("UPDATE users SET password='$password',passwordexpiry='0000-00-00' WHERE id={$r->id}");
|
||||
|
||||
/* volunteer_recover_password, judge_recover_password, student_recover_password,
|
||||
@ -220,6 +247,7 @@
|
||||
array( "PASSWORD"=>$password,
|
||||
"EMAIL"=>$email)
|
||||
);
|
||||
|
||||
header("Location: user_login.php?type=$type¬ice=recover_sent");
|
||||
exit;
|
||||
} else {
|
||||
|
@ -31,12 +31,21 @@
|
||||
if(isset($_SESSION['users_type'])) {
|
||||
$type = $_SESSION['users_type'];
|
||||
} else {
|
||||
header("location: index.php");
|
||||
header("location: index.php?notice=auth_requird");
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Make sure the user is logged in, but don't check passwd expiry */
|
||||
user_auth_required($type, false);
|
||||
if(!isset($_SESSION['users_type'])) {
|
||||
header("location: user_login.php?type=$type¬ice=auth_required");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($_SESSION['users_type'] != $type) {
|
||||
header("location: user_login.php?type=$type¬ice=auth_required");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$notice=$_GET['notice'];
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
<?
|
||||
require_once("common.inc.php");
|
||||
require_once("user.inc.php");
|
||||
require_once("committee.inc.php");
|
||||
|
||||
if(!isset($_SESSION['users_type'])) {
|
||||
/* No type set, invalid session */
|
||||
@ -32,7 +33,22 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
$u = user_load($_SESSION['users_id']);
|
||||
/* See if there is an edit request */
|
||||
$eid = intval($_GET['edit']);
|
||||
|
||||
if($eid != 0) {
|
||||
/* There is an edit request, the user must be:
|
||||
* - on the committee
|
||||
* - with admin access */
|
||||
user_auth_required('committee', 'admin');
|
||||
$u = user_load($eid, true);
|
||||
|
||||
} else {
|
||||
/* Else, force them to edit themselves */
|
||||
$eid = false;
|
||||
$u = user_load($_SESSION['users_id'], true);
|
||||
}
|
||||
|
||||
|
||||
/* Load the fields the user can edit, and theones that are required */
|
||||
$fields = array();
|
||||
@ -44,36 +60,96 @@
|
||||
user_personal_required_fields($t));
|
||||
}
|
||||
|
||||
//send the header
|
||||
$type = $_SESSION['users_type'];
|
||||
send_header("{$user_what[$type]} - Personal Information",
|
||||
array("{$user_what[$type]} Registration" => "{$type}_main.php")
|
||||
);
|
||||
|
||||
if(committee_auth_has_access('super')) {
|
||||
/* If the editer is super, let them see/edit/save the password */
|
||||
$fields[] = 'password';
|
||||
}
|
||||
|
||||
if($_POST['action']=="save")
|
||||
{
|
||||
|
||||
|
||||
/* Set values */
|
||||
foreach($fields as $f) {
|
||||
$u[$f] = mysql_escape_string(stripslashes($_POST[$f]));
|
||||
}
|
||||
|
||||
user_save($u);
|
||||
if(in_array('committee', $u['types'])) {
|
||||
/* Trying to save a committee member eh? Well, we established above
|
||||
* that we're allowed to be here, so go ahead and save it */
|
||||
$u['displayemail'] = ($_POST['displayemail'] == 'yes') ? 'yes' : 'no';
|
||||
$u['emailprivate'] = mysql_escape_string(stripslashes($_POST['emailprivate']));
|
||||
|
||||
if(committee_auth_has_access('super')) {
|
||||
/* But only superusers can save these ones */
|
||||
$u['access_admin'] = ($_POST['access_admin'] == 'yes') ? 'yes' : 'no';
|
||||
$u['access_config'] = ($_POST['access_config'] == 'yes') ? 'yes' : 'no';
|
||||
$u['access_super'] = ($_POST['access_super'] == 'yes') ? 'yes' : 'no';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check for an email collision */
|
||||
$em = mysql_escape_string(stripslashes($_POST['email']));
|
||||
$q=mysql_query("SELECT id FROM users WHERE email='$em'");
|
||||
if(mysql_num_rows($q) > 0) {
|
||||
$notice = 'email_exists';
|
||||
} else {
|
||||
user_save($u);
|
||||
if($_SESSION['last_page'] == 'committee_management') {
|
||||
header("location: {$config['SFIABDIRECTORY']}/admin/committees.php");
|
||||
exit;
|
||||
}
|
||||
$notice = 'success';
|
||||
}
|
||||
|
||||
|
||||
echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname'])));
|
||||
}
|
||||
|
||||
// updateJudgeCompleteStatus($judgeinfo);
|
||||
//send the header
|
||||
if($eid == false) {
|
||||
$type = $_SESSION['users_type'];
|
||||
send_header("{$user_what[$type]} - Personal Information",
|
||||
array("{$user_what[$type]} Registration" => "{$type}_main.php")
|
||||
);
|
||||
} else {
|
||||
if($_SESSION['last_page'] == 'committee_management') {
|
||||
send_header("Personal Information for {$u['firstname']} {$u['lastname']}",
|
||||
array('Committee Main' => 'committee_main.php',
|
||||
'Administration' => 'admin/index.php',
|
||||
'Committee Management' => 'admin/committees.php')
|
||||
);
|
||||
} else {
|
||||
send_header("Personal Information for {$u['firstname']} {$u['lastname']}",
|
||||
array("Committee Main" => "committee_main.php")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//output the current status
|
||||
$newstatus=user_personal_info_status($u);
|
||||
if($newstatus!='complete')
|
||||
{
|
||||
echo error(i18n("Personal Information Incomplete"));
|
||||
switch($notice) {
|
||||
case 'success':
|
||||
echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname'])));
|
||||
break;
|
||||
case 'email_exists':
|
||||
echo notice(i18n("That email address is in use by another user"));
|
||||
break;
|
||||
}
|
||||
|
||||
if($eid == false) {
|
||||
//output the current status
|
||||
$newstatus=user_personal_info_status($u);
|
||||
if($newstatus!='complete')
|
||||
echo error(i18n("Personal Information Incomplete"));
|
||||
else
|
||||
echo happy(i18n("Personal Information Complete"));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo happy(i18n("Personal Information Complete"));
|
||||
|
||||
if(count($u['types']) > 1) {
|
||||
$roles='';
|
||||
foreach($u['types'] as $t) {
|
||||
$roles.= (($roles=='')?'':', ').i18n($user_what[$t]);
|
||||
}
|
||||
echo notice(i18n('This user has multiple roles, the fields shown below are a combination of every role. Some may not apply to some roles. This user has the following roles:').' '.$roles);
|
||||
}
|
||||
|
||||
function item($user, $text, $fname)
|
||||
@ -91,8 +167,11 @@ function item($user, $text, $fname)
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo "<form name=\"personalform\" method=\"post\" action=\"user_personal.php\">\n";
|
||||
$eidstr = '';
|
||||
if($eid != false) {
|
||||
$eidstr="?edit=$eid";
|
||||
}
|
||||
echo "<form name=\"personalform\" method=\"post\" action=\"user_personal.php$eidstr\">\n";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n";
|
||||
echo "<table>\n";
|
||||
|
||||
@ -102,7 +181,7 @@ item($u, "Last Name", 'lastname');
|
||||
echo "</tr>\n";
|
||||
echo "<tr>\n";
|
||||
item($u, "Email Address", 'email');
|
||||
echo "<td></td><td></td>";
|
||||
item($u, "Password", 'password');
|
||||
echo "</tr>\n";
|
||||
echo "<tr>\n";
|
||||
item($u, "Address 1", 'address');
|
||||
@ -138,10 +217,43 @@ item($u, "Fax", 'fax');
|
||||
echo '<td></td><td></td>';
|
||||
echo "</tr>";
|
||||
|
||||
|
||||
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
|
||||
|
||||
echo "</table>";
|
||||
|
||||
/* Committee specific fields */
|
||||
if(in_array('committee', $u['types'])) {
|
||||
echo "<table><tr>\n";
|
||||
item($u, "Email (Private)", 'emailprivate');
|
||||
echo "</tr>";
|
||||
|
||||
echo "<tr><td>".i18n("Email (Private)").":</td><td><input size=\"25\" type=\"text\" name=\"emailprivate\" value=\"{$u['emailprivate']}\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Display Emails").":</td><td>";
|
||||
if($u['displayemail']=="no") $checked="checked=\"checked\""; else $checked="";
|
||||
echo "<input type=\"radio\" name=\"displayemail\" value=\"no\" $checked />".i18n("No");
|
||||
echo " ";
|
||||
if($u['displayemail']=="yes") $checked="checked=\"checked\""; else $checked="";
|
||||
echo "<input type=\"radio\" name=\"displayemail\" value=\"yes\" $checked />".i18n("Yes");
|
||||
|
||||
if(committee_auth_has_access("super"))
|
||||
{
|
||||
/* If the user is a committee member, only print these fields
|
||||
* if the editer has super access */
|
||||
echo "<tr><td align=\"center\" colspan=\"2\"><hr /></td></tr>";
|
||||
echo "<tr><td>".i18n("Access Controls").":</td><td>";
|
||||
$ch = ($u['access_admin']=="yes") ? 'checked="checked"' : '';
|
||||
echo "<input type=\"checkbox\" name=\"access_admin\" value=\"yes\" $ch /> ".i18n("Administration")."<br />";
|
||||
$ch = ($u['access_config']=="yes") ? 'checked="checked"' : '';
|
||||
echo "<input type=\"checkbox\" name=\"access_config\" value=\"yes\" $ch /> ".i18n("Configuration")."<br />";
|
||||
$ch = ($u['access_super']=="yes") ? 'checked="checked"' : '';
|
||||
echo "<input type=\"checkbox\" name=\"access_super\" value=\"yes\" $ch /> ".i18n("Superuser")."<br />";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo "<input type=\"submit\" value=\"".i18n("Save Personal Information")."\" />\n";
|
||||
echo "</form>";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user