";
$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 "
";
echo "\n";
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
- while($r=mysql_fetch_object($q))
- {
- $q2=mysql_query("SELECT
- users.id,
- users.firstname,users.lastname,
- users.email,
- 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");
-
+ while($r=mysql_fetch_object($q)) {
+
+ /* Select everyone in this committee, attach the user data using MAX(year) so we only get the most recent
+ * user data */
+ $q2=mysql_query("SELECT committees_link.*,users.uid,MAX(users.year),users.firstname,users.lastname,users.email,users.deleted
+ 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)
continue;
- echo "\n";
+ echo "\n";
echo mysql_error();
while($r2=mysql_fetch_object($q2))
{
+ if($r2->deleted != 'no') continue;
+
if($r2->email) {
$name=$r2->firstname.' '.$r2->lastname;
if($r2->title) $titlestr=" ($r2->title)"; else $titlestr="";
diff --git a/db/db.code.version.txt b/db/db.code.version.txt
index 52bd8e4..9289ddc 100644
--- a/db/db.code.version.txt
+++ b/db/db.code.version.txt
@@ -1 +1 @@
-120
+121
diff --git a/db/db.update.121.sql b/db/db.update.121.sql
new file mode 100644
index 0000000..a292535
--- /dev/null
+++ b/db/db.update.121.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `committees_link` CHANGE `users_id` `users_uid` INT( 11 ) NOT NULL DEFAULT '0' ;
+
diff --git a/user.inc.php b/user.inc.php
index 6a2c759..931d8cc 100644
--- a/user.inc.php
+++ b/user.inc.php
@@ -361,7 +361,7 @@ function user_save($u)
function user_delete_committee($u)
{
- mysql_query("DELETE FROM committees_link WHERE users_id='{$u['id']}'");
+ mysql_query("DELETE FROM committees_link WHERE users_uid='{$u['uid']}'");
}
function user_delete_volunteer($u)