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');
|
||||
|
||||
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 "</select>";
|
||||
|
||||
echo "</td><td>";
|
||||
$q=mysql_query("SELECT * FROM users WHERE types LIKE '%committee%' ORDER BY firstname");
|
||||
echo "<select name=\"users_id\">";
|
||||
$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_uid\">";
|
||||
echo "<option value=\"\">".i18n("Select a Member")."</option>\n";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
if($r->deleted != 'no') continue;
|
||||
$displayname = $r->firstname.' '.$r->lastname;
|
||||
echo "<option value=\"$r->id\">$displayname</option>\n";
|
||||
echo "<option value=\"$r->uid\">$displayname</option>\n";
|
||||
}
|
||||
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 " <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 "<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))
|
||||
{
|
||||
while($r2=mysql_fetch_object($q2)) {
|
||||
$u = user_load_by_uid($r2->uid);
|
||||
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 "<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 valign=\"top\">";
|
||||
echo "<b>{$r2->firstname} {$r2->lastname}</b>";
|
||||
echo "<b>{$u['name']}</b>";
|
||||
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 "<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>";
|
||||
|
||||
if($r2->email)
|
||||
{
|
||||
list($b,$a)=split("@",$r2->email);
|
||||
if($u['email']) {
|
||||
list($b,$a)=split("@",$u['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);
|
||||
if($u['emailprivate']) {
|
||||
if($u['email']) echo " <b>/</b> ";
|
||||
list($b,$a)=split("@",$u['emailprivate']);
|
||||
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,11 @@
|
||||
echo "<table>";
|
||||
$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'];
|
||||
|
28
contact.php
28
contact.php
@ -81,32 +81,26 @@ function tochange() {
|
||||
echo "<td><select name=\"to\" onchange=\"tochange()\">";
|
||||
echo "<option value=\"\">".i18n("Choose a person to contact")."</option>\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 "<option value=\"\">$r->name</option>\n";
|
||||
echo "<option value=\"\">{$r->name}</option>\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="";
|
||||
|
@ -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)
|
||||
{
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user