forked from science-ation/science-ation
- Use the unique user id (users_uid) instead of the user id (that changes every year) when linking users to committees.
- Also use the uid when displaying committees and contact info.
This commit is contained in:
parent
94d0e5022a
commit
ad27a96874
@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
user_auth_required('committee', 'admin');
|
user_auth_required('committee', 'admin');
|
||||||
|
|
||||||
if($_POST['users_id'])
|
if($_POST['users_uid'])
|
||||||
$uid = intval($_POST['users_id']);
|
$uid = intval($_POST['users_uid']);
|
||||||
|
|
||||||
/* Some actions we want to redirect to the personal editor, so deal with those first */
|
/* Some actions we want to redirect to the personal editor, so deal with those first */
|
||||||
if($_POST['add_member'])
|
if($_POST['add_member'])
|
||||||
@ -106,7 +106,7 @@ function actionSubmit()
|
|||||||
alert('You must choose an action');
|
alert('You must choose an action');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(document.forms.memberaction.users_id.selectedIndex==0)
|
if(document.forms.memberaction.users_uid.selectedIndex==0)
|
||||||
{
|
{
|
||||||
alert('You must choose a member');
|
alert('You must choose a member');
|
||||||
return false;
|
return false;
|
||||||
@ -114,7 +114,7 @@ function actionSubmit()
|
|||||||
|
|
||||||
if(document.forms.memberaction.action.selectedIndex == 2) {
|
if(document.forms.memberaction.action.selectedIndex == 2) {
|
||||||
// Edit
|
// 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);
|
openeditor(id.value);
|
||||||
// alert("id="+id.value);
|
// alert("id="+id.value);
|
||||||
return false;
|
return false;
|
||||||
@ -165,7 +165,7 @@ if($_POST['committees_id'] && $_POST['committees_ord'])
|
|||||||
$t = mysql_escape_string(stripslashes($title));
|
$t = mysql_escape_string(stripslashes($title));
|
||||||
$u = intval($uid);
|
$u = intval($uid);
|
||||||
$q = "UPDATE committees_link SET title='$t', ord='$o'
|
$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);
|
mysql_query($q);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,14 +176,14 @@ if($_POST['committees_id'] && $_POST['committees_ord'])
|
|||||||
|
|
||||||
if($_POST['action']=="assign")
|
if($_POST['action']=="assign")
|
||||||
{
|
{
|
||||||
if($_POST['committees_id'] && $_POST['users_id'])
|
if($_POST['committees_id'] && $_POST['users_uid'])
|
||||||
{
|
{
|
||||||
$cid = intval($_POST['committees_id']);
|
$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))
|
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"));
|
echo happy(i18n("Successfully added member to committee"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -214,7 +214,7 @@ if($_GET['unlinkmember'] && $_GET['unlinkcommittee'])
|
|||||||
$mem = intval($_GET['unlinkmember']);
|
$mem = intval($_GET['unlinkmember']);
|
||||||
$com = intval($_GET['unlinkcommittee']);
|
$com = intval($_GET['unlinkcommittee']);
|
||||||
//unlink the member from the committee
|
//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"));
|
echo happy(i18n("Committee member unlinked from committee"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ if($_GET['unlinkmember'] && $_GET['unlinkcommittee'])
|
|||||||
if($_POST['add_member_to_committees_id'])
|
if($_POST['add_member_to_committees_id'])
|
||||||
{
|
{
|
||||||
$add = intval($_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'];
|
$edit=$_POST['committees_members_id'];
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@ -268,13 +268,14 @@ if($_POST['add_member_to_committees_id'])
|
|||||||
echo "</select>";
|
echo "</select>";
|
||||||
|
|
||||||
echo "</td><td>";
|
echo "</td><td>";
|
||||||
$q=mysql_query("SELECT * FROM users WHERE types LIKE '%committee%' ORDER BY firstname");
|
$q=mysql_query("SELECT uid,MAX(year),firstname,lastname,deleted FROM users WHERE types LIKE '%committee%' GROUP BY uid ORDER BY firstname");
|
||||||
echo "<select name=\"users_id\">";
|
echo "<select name=\"users_uid\">";
|
||||||
echo "<option value=\"\">".i18n("Select a Member")."</option>\n";
|
echo "<option value=\"\">".i18n("Select a Member")."</option>\n";
|
||||||
while($r=mysql_fetch_object($q))
|
while($r=mysql_fetch_object($q))
|
||||||
{
|
{
|
||||||
|
if($r->deleted != 'no') continue;
|
||||||
$displayname = $r->firstname.' '.$r->lastname;
|
$displayname = $r->firstname.' '.$r->lastname;
|
||||||
echo "<option value=\"$r->id\">$displayname</option>\n";
|
echo "<option value=\"$r->uid\">$displayname</option>\n";
|
||||||
}
|
}
|
||||||
echo "</select>";
|
echo "</select>";
|
||||||
|
|
||||||
@ -323,56 +324,43 @@ if($_POST['add_member_to_committees_id'])
|
|||||||
echo "<input size=\"1\" type=\"text\" name=\"committees_ord[]\" value=\"$r->ord\" />";
|
echo "<input size=\"1\" type=\"text\" name=\"committees_ord[]\" value=\"$r->ord\" />";
|
||||||
echo " <b>$r->name</b>";
|
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)
|
$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 " ";
|
||||||
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 "<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 "</td></tr>\n";
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
while($r2=mysql_fetch_object($q2))
|
while($r2=mysql_fetch_object($q2)) {
|
||||||
{
|
$u = user_load_by_uid($r2->uid);
|
||||||
echo "<tr><td align=\"right\"> ";
|
echo "<tr><td align=\"right\"> ";
|
||||||
echo "<a title=\"Edit Member\" href=\"#\" onclick=\"openeditor($r2->id)\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/edit.{$config['icon_extension']}\" border=\"0\" alt=\"Edit\" /></a>";
|
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 " ";
|
||||||
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 "<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['id']}&unlinkcommittee={$r->id}\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/undo.{$config['icon_extension']}\" border=\"0\" alt=\"Unlink\" /></a>";
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
echo "<td valign=\"top\">";
|
echo "<td valign=\"top\">";
|
||||||
echo "<b>{$r2->firstname} {$r2->lastname}</b>";
|
echo "<b>{$u['name']}</b>";
|
||||||
echo "</td><td>";
|
echo "</td><td>";
|
||||||
echo "<input type=\"text\" value=\"{$r2->title}\" name=\"title[{$r->id}][{$r2->id}]\" size=\"15\">";
|
echo "<input type=\"text\" value=\"{$r2->title}\" name=\"title[{$r->id}][{$u['id']}]\" size=\"15\">";
|
||||||
echo "</td><td>";
|
echo "</td><td>";
|
||||||
echo "<input type=\"text\" value=\"{$r2->ord}\" name=\"order[{$r->id}][{$r2->id}]\" size=\"2\">";
|
echo "<input type=\"text\" value=\"{$r2->ord}\" name=\"order[{$r->id}][{$u['id']}]\" size=\"2\">";
|
||||||
|
|
||||||
echo "</td><td>";
|
echo "</td><td>";
|
||||||
|
|
||||||
if($r2->email)
|
if($u['email']) {
|
||||||
{
|
list($b,$a)=split("@",$u['email']);
|
||||||
list($b,$a)=split("@",$r2->email);
|
|
||||||
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($r2->emailprivate)
|
if($u['emailprivate']) {
|
||||||
{
|
if($u['email']) echo " <b>/</b> ";
|
||||||
if($r2->email) echo " <b>/</b> ";
|
list($b,$a)=split("@",$u['emailprivate']);
|
||||||
list($b,$a)=split("@",$r2->emailprivate);
|
|
||||||
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,9 +29,11 @@
|
|||||||
echo "<table>";
|
echo "<table>";
|
||||||
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
||||||
while($r=mysql_fetch_object($q)) {
|
while($r=mysql_fetch_object($q)) {
|
||||||
$q2=mysql_query("SELECT * FROM committees_link
|
/* Select all the users in the committee, using MAX(year) for the most recent year */
|
||||||
LEFT JOIN users ON users.id = committees_link.users_id
|
$q2=mysql_query("SELECT committees_link.*,users.uid,MAX(users.year),users.lastname
|
||||||
WHERE committees_id='{$r->id}' ORDER BY ord,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 there's nobody in this committee, then just skip it and go on to the next one.
|
||||||
if(mysql_num_rows($q2)==0)
|
if(mysql_num_rows($q2)==0)
|
||||||
@ -44,7 +46,7 @@
|
|||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
while($r2=mysql_fetch_object($q2)) {
|
while($r2=mysql_fetch_object($q2)) {
|
||||||
|
|
||||||
$uid = $r2->users_id;
|
$uid = $r2->users_uid;
|
||||||
$u = user_load_by_uid($uid);
|
$u = user_load_by_uid($uid);
|
||||||
|
|
||||||
$output=$config['committee_publiclayout'];
|
$output=$config['committee_publiclayout'];
|
||||||
|
30
contact.php
30
contact.php
@ -81,32 +81,26 @@ function tochange() {
|
|||||||
echo "<td><select name=\"to\" onchange=\"tochange()\">";
|
echo "<td><select name=\"to\" onchange=\"tochange()\">";
|
||||||
echo "<option value=\"\">".i18n("Choose a person to contact")."</option>\n";
|
echo "<option value=\"\">".i18n("Choose a person to contact")."</option>\n";
|
||||||
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
||||||
while($r=mysql_fetch_object($q))
|
while($r=mysql_fetch_object($q)) {
|
||||||
{
|
|
||||||
$q2=mysql_query("SELECT
|
/* Select everyone in this committee, attach the user data using MAX(year) so we only get the most recent
|
||||||
users.id,
|
* user data */
|
||||||
users.firstname,users.lastname,
|
$q2=mysql_query("SELECT committees_link.*,users.uid,MAX(users.year),users.firstname,users.lastname,users.email,users.deleted
|
||||||
users.email,
|
FROM committees_link LEFT JOIN users ON users.uid = committees_link.users_uid
|
||||||
committees_link.title,
|
WHERE committees_id='{$r->id}'
|
||||||
committees_link.ord
|
GROUP BY users.uid ORDER BY ord,users.lastname ");
|
||||||
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 there's nobody in this committee, then just skip it and go on to the next one.
|
||||||
if(mysql_num_rows($q2)==0)
|
if(mysql_num_rows($q2)==0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
echo "<option value=\"\">$r->name</option>\n";
|
echo "<option value=\"\">{$r->name}</option>\n";
|
||||||
|
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
while($r2=mysql_fetch_object($q2))
|
while($r2=mysql_fetch_object($q2))
|
||||||
{
|
{
|
||||||
|
if($r2->deleted != 'no') continue;
|
||||||
|
|
||||||
if($r2->email) {
|
if($r2->email) {
|
||||||
$name=$r2->firstname.' '.$r2->lastname;
|
$name=$r2->firstname.' '.$r2->lastname;
|
||||||
if($r2->title) $titlestr=" ($r2->title)"; else $titlestr="";
|
if($r2->title) $titlestr=" ($r2->title)"; else $titlestr="";
|
||||||
|
@ -1 +1 @@
|
|||||||
120
|
121
|
||||||
|
2
db/db.update.121.sql
Normal file
2
db/db.update.121.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE `committees_link` CHANGE `users_id` `users_uid` INT( 11 ) NOT NULL DEFAULT '0' ;
|
||||||
|
|
@ -361,7 +361,7 @@ function user_save($u)
|
|||||||
|
|
||||||
function user_delete_committee($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)
|
function user_delete_volunteer($u)
|
||||||
|
Loading…
Reference in New Issue
Block a user