diff --git a/admin/committees.php b/admin/committees.php index 2e72694..b752520 100644 --- a/admin/committees.php +++ b/admin/committees.php @@ -28,8 +28,8 @@ user_auth_required('committee', 'admin'); -if($_POST['users_id']) - $uid = intval($_POST['users_id']); +if($_POST['users_uid']) + $uid = intval($_POST['users_uid']); /* Some actions we want to redirect to the personal editor, so deal with those first */ if($_POST['add_member']) @@ -106,7 +106,7 @@ function actionSubmit() alert('You must choose an action'); return false; } - if(document.forms.memberaction.users_id.selectedIndex==0) + if(document.forms.memberaction.users_uid.selectedIndex==0) { alert('You must choose a member'); return false; @@ -114,7 +114,7 @@ function actionSubmit() if(document.forms.memberaction.action.selectedIndex == 2) { // Edit - var id = document.forms.memberaction.users_id.options[document.forms.memberaction.users_id.selectedIndex]; + var id = document.forms.memberaction.users_uid.options[document.forms.memberaction.users_uid.selectedIndex]; openeditor(id.value); // alert("id="+id.value); return false; @@ -165,7 +165,7 @@ if($_POST['committees_id'] && $_POST['committees_ord']) $t = mysql_escape_string(stripslashes($title)); $u = intval($uid); $q = "UPDATE committees_link SET title='$t', ord='$o' - WHERE committees_id='$cid' AND users_id='$u'"; + WHERE committees_id='$cid' AND users_uid='$u'"; mysql_query($q); } @@ -176,14 +176,14 @@ if($_POST['committees_id'] && $_POST['committees_ord']) if($_POST['action']=="assign") { - if($_POST['committees_id'] && $_POST['users_id']) + if($_POST['committees_id'] && $_POST['users_uid']) { $cid = intval($_POST['committees_id']); - $q=mysql_query("SELECT * FROM committees_link WHERE committees_id='$cid' AND users_id='$uid'"); + $q=mysql_query("SELECT * FROM committees_link WHERE committees_id='$cid' AND users_uid='$uid'"); if(!mysql_num_rows($q)) { - mysql_query("INSERT INTO committees_link (committees_id,users_id) VALUES ('$cid','$uid')"); + mysql_query("INSERT INTO committees_link (committees_id,users_uid) VALUES ('$cid','$uid')"); echo happy(i18n("Successfully added member to committee")); } else @@ -214,7 +214,7 @@ 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'"); + mysql_query("DELETE FROM committees_link WHERE users_uid='$mem' AND committees_id='$com'"); echo happy(i18n("Committee member unlinked from committee")); } @@ -222,7 +222,7 @@ if($_GET['unlinkmember'] && $_GET['unlinkcommittee']) 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')"); + mysql_query("INSERT INTO committees_link (committees_id,users_uid) VALUES ('$add')"); $edit=$_POST['committees_members_id']; } */ @@ -268,13 +268,14 @@ if($_POST['add_member_to_committees_id']) echo ""; echo ""; - $q=mysql_query("SELECT * FROM users WHERE types LIKE '%committee%' ORDER BY firstname"); - echo ""; echo "\n"; while($r=mysql_fetch_object($q)) { + if($r->deleted != 'no') continue; $displayname = $r->firstname.' '.$r->lastname; - echo "\n"; + echo "\n"; } echo ""; @@ -323,56 +324,43 @@ if($_POST['add_member_to_committees_id']) echo "ord\" />"; echo "  $r->name"; - $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) - { + $q2=mysql_query("SELECT committees_link.title,committees_link.ord,users.uid,MAX(users.year),users.lastname + FROM committees_link LEFT JOIN users ON users.uid = committees_link.users_uid + WHERE committees_id='{$r->id}' + GROUP BY users.uid ORDER BY ord,users.lastname "); + + if(mysql_num_rows($q2)==0) { echo "   "; echo "id\">\"Remove"; } echo "\n"; echo mysql_error(); - while($r2=mysql_fetch_object($q2)) - { + while($r2=mysql_fetch_object($q2)) { + $u = user_load_by_uid($r2->uid); echo "    "; - echo "id)\">\"Edit\""; + echo "\"Edit\""; echo " "; - echo "id&unlinkcommittee={$r->id}\">\"Unlink\""; + echo "id}\">\"Unlink\""; echo ""; echo ""; - echo "{$r2->firstname} {$r2->lastname}"; + echo "{$u['name']}"; echo ""; - echo "title}\" name=\"title[{$r->id}][{$r2->id}]\" size=\"15\">"; + echo "title}\" name=\"title[{$r->id}][{$u['id']}]\" size=\"15\">"; echo ""; - echo "ord}\" name=\"order[{$r->id}][{$r2->id}]\" size=\"2\">"; + echo "ord}\" name=\"order[{$r->id}][{$u['id']}]\" size=\"2\">"; echo ""; - if($r2->email) - { - list($b,$a)=split("@",$r2->email); + if($u['email']) { + list($b,$a)=split("@",$u['email']); echo ""; } - if($r2->emailprivate) - { - if($r2->email) echo " / "; - list($b,$a)=split("@",$r2->emailprivate); + if($u['emailprivate']) { + if($u['email']) echo " / "; + list($b,$a)=split("@",$u['emailprivate']); echo ""; } diff --git a/committees.php b/committees.php index ed3baaa..d3d473f 100644 --- a/committees.php +++ b/committees.php @@ -29,9 +29,11 @@ echo ""; $q=mysql_query("SELECT * FROM committees ORDER BY ord,name"); while($r=mysql_fetch_object($q)) { - $q2=mysql_query("SELECT * FROM committees_link - LEFT JOIN users ON users.id = committees_link.users_id - WHERE committees_id='{$r->id}' ORDER BY ord,users.lastname"); + /* Select all the users in the committee, using MAX(year) for the most recent year */ + $q2=mysql_query("SELECT committees_link.*,users.uid,MAX(users.year),users.lastname + FROM committees_link LEFT JOIN users ON users.uid = committees_link.users_uid + WHERE committees_id='{$r->id}' + GROUP BY users.uid ORDER BY ord,users.lastname "); //if there's nobody in this committee, then just skip it and go on to the next one. if(mysql_num_rows($q2)==0) @@ -44,7 +46,7 @@ echo mysql_error(); while($r2=mysql_fetch_object($q2)) { - $uid = $r2->users_id; + $uid = $r2->users_uid; $u = user_load_by_uid($uid); $output=$config['committee_publiclayout']; diff --git a/contact.php b/contact.php index fdb2579..e7732e2 100644 --- a/contact.php +++ b/contact.php @@ -81,32 +81,26 @@ function tochange() { echo "