forked from science-ation/science-ation
483 lines
17 KiB
PHP
483 lines
17 KiB
PHP
<?
|
|
/*
|
|
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', ";
|
|
}
|
|
|
|
//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']))."', ";
|
|
|
|
$q=mysql_query("SELECT id FROM committees_members WHERE (email='".$_POST['emailprivate']."' OR emailprivate='".$_POST['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='".mysql_escape_string(stripslashes($_POST['emailprivate']))."', ";
|
|
|
|
mysql_query("UPDATE committees_members SET ".
|
|
"name='".mysql_escape_string(stripslashes($_POST['name']))."', ".
|
|
"password='".mysql_escape_string(stripslashes($_POST['password']))."', ".
|
|
"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>";
|
|
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();
|
|
?>
|
|
|