<? /* 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("../user.inc.php"); require_once("../committee.inc.php"); user_auth_required('admin'); if($_POST['accounts_id']) $accounts_id = intval($_POST['accounts_id']); /* Now, start the output for this page */ send_header("Committee Member Management", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php' ), "committee_management"); $_SESSION['last_page'] = 'committee_management'; ?> <script type="text/javascript"> <!-- function neweditor() { var username = document.forms.addmember.add_member.value; window.open("../user_editor_window.php?type=committee&username="+username,"UserEditor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes"); document.forms.addmember.add_member.value = ""; return false; } 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.accounts_id.selectedIndex==0) { alert('You must choose a member'); return false; } if(document.forms.memberaction.action.selectedIndex == 2) { // Edit var id = document.forms.memberaction.accounts_id.options[document.forms.memberaction.accounts_id.selectedIndex]; openeditor(id.value); // alert("id="+id.value); 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['committees_id']) { //re-order the committees $x=0; $ids=$_POST['committees_id']; $titles=$_POST['title']; $pords = $_POST['order']; while($ids[$x]) { $cid = intval($ids[$x]); $x++; $ctitle = $titles[$cid]; $cord = $pords[$cid]; /* If the committee has no members, don't bother trying to do * anything */ if(!is_array($ctitle)) continue; // print_r($ctitle); foreach($ctitle as $accounts_id=>$title) { $o = intval($cord[$accounts_id]); $t = mysql_escape_string(stripslashes($title)); $u = intval($accounts_id); $q = "UPDATE committees_link SET title='$t', ord='$o' WHERE committees_id='$cid' AND accounts_id='$u'"; // echo $q; mysql_query($q); } } echo happy(i18n("Committees successfully saved")); } if($_POST['action']=="assign") { if($_POST['committees_id'] && $_POST['accounts_id']) { $cid = intval($_POST['committees_id']); $q=mysql_query("SELECT * FROM committees_link WHERE committees_id='$cid' AND accounts_id='$accounts_id'"); if(!mysql_num_rows($q)) { mysql_query("INSERT INTO committees_link (committees_id,accounts_id) VALUES ('$cid','$accounts_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($_POST['action']=="remove") { /* user_delete takes care of unlinking the user in other tables */ user_delete($accounts_id, 'committee'); echo happy(i18n("Committee member deleted")); } 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 accounts_id='$mem' AND committees_id='$com'"); echo happy(i18n("Committee member unlinked from committee")); } echo '<a href="../user_invite.php?type=committee">Create a new member</a><br/>'; echo "<a href=\"committee_committees.php\">Manage Committees</a><br />"; 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>"; $query = " SELECT accounts_id, firstname, lastname, email, deleted FROM users WHERE accounts_id IN( SELECT accounts_id FROM user_roles JOIN roles ON user_roles.roles_id = roles.id WHERE roles.type = 'committee' ) AND conferences_id = " . $conference['id']; $q = mysql_query($query); echo "<select name=\"accounts_id\">"; echo "<option value=\"\">".i18n("Select a Member")."</option>\n"; while($r=mysql_fetch_object($q)) { if($r->deleted == 'yes') continue; $displayname = $r->firstname.' '.$r->lastname; echo "<option value=\"$r->accounts_id\">$displayname ($r->email)</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 "<form method=\"post\" action=\"committees.php\">\n"; echo "<table>"; echo "<tr><td colspan=\"2\"></td><th colspan=\"2\">".i18n('Title within committee / Sort order')."</th>"; echo "</tr>"; while($r=mysql_fetch_object($q)) { echo "<tr>"; echo "<td colspan=\"4\">"; echo "<input type=\"hidden\" name=\"committees_id[]\" value=\"$r->id\" />"; // echo "<input size=\"1\" type=\"text\" name=\"committees_ord[]\" value=\"$r->ord\" />"; echo "<b>".i18n($r->name)."</b>"; $q2=mysql_query("SELECT committees_link.title, committees_link.ord, committees_link.accounts_id FROM committees_link WHERE committees_id='{$r->id}' ORDER BY ord"); echo "</td></tr>\n"; echo mysql_error(); while($r2=mysql_fetch_object($q2)) { $u = user_load_by_accounts_id($r2->accounts_id); //if rollover is proper, this shouldnt be necessary, but, the simcoe rollover didnt do this, so lets do it here as a safety if(!$u) { $roleq=mysql_query("SELECT * FROM roles WHERE type='committee'"); $roler=mysql_fetch_object($roleq); //hmm thats okay,w e must have missed something in the rollover... sicne its tied to the accounts_id, we just need to add a record account_add_role($r2->accounts_id,$roler->id,$conference['id']); //and now we should be able to load them $u = user_load_by_accounts_id($r2->accounts_id); } echo "<tr><td align=\"right\"> "; echo "<a title=\"Edit Member\" href=\"#\" onclick=\"openeditor({$u['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={$u['accounts_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>{$u['firstname']} {$u['lastname']}</b>"; echo "</td><td>"; echo "<input type=\"text\" value=\"{$r2->title}\" name=\"title[{$r->id}][{$u['accounts_id']}]\" size=\"25\">"; echo "</td><td>"; echo "<input type=\"text\" value=\"{$r2->ord}\" name=\"order[{$r->id}][{$u['accounts_id']}]\" size=\"2\">"; echo "</td></tr>\n"; } echo "<tr><td colspan=\"4\"> </td></tr>\n"; } echo "<tr><td colspan=\"2\"><input type=\"submit\" value=\"".i18n("Save Committee Orders and Titles")."\" /></td></tr>\n"; echo "</table>"; echo "</form>\n"; } send_footer(); ?>