Updates to work with new user system. Also updated the committees_link table fieldname to use "accounts_id" instead of "users_uid" and updated code accordingly.

This commit is contained in:
jacob 2010-07-14 21:04:50 +00:00
parent 004c9b64d2
commit a403202786
6 changed files with 35 additions and 33 deletions

View File

@ -28,8 +28,8 @@
user_auth_required('admin');
if($_POST['users_uid'])
$uid = intval($_POST['users_uid']);
if($_POST['accounts_id'])
$accounts_id = intval($_POST['accounts_id']);
/* Now, start the output for this page */
@ -101,7 +101,7 @@ function actionSubmit()
alert('You must choose an action');
return false;
}
if(document.forms.memberaction.users_uid.selectedIndex==0)
if(document.forms.memberaction.accounts_id.selectedIndex==0)
{
alert('You must choose a member');
return false;
@ -109,7 +109,7 @@ function actionSubmit()
if(document.forms.memberaction.action.selectedIndex == 2) {
// Edit
var id = document.forms.memberaction.users_uid.options[document.forms.memberaction.users_uid.selectedIndex];
var id = document.forms.memberaction.accounts_id.options[document.forms.memberaction.accounts_id.selectedIndex];
openeditor(id.value);
// alert("id="+id.value);
return false;
@ -153,12 +153,12 @@ if($_POST['committees_id'] && $_POST['committees_ord']) {
if(!is_array($ctitle)) continue;
// print_r($ctitle);
foreach($ctitle as $uid=>$title) {
$o = intval($cord[$uid]);
foreach($ctitle as $accounts_id=>$title) {
$o = intval($cord[$accounts_id]);
$t = mysql_escape_string(stripslashes($title));
$u = intval($uid);
$u = intval($accounts_id);
$q = "UPDATE committees_link SET title='$t', ord='$o'
WHERE committees_id='$cid' AND users_uid='$u'";
WHERE committees_id='$cid' AND accounts_id='$u'";
// echo $q;
mysql_query($q);
}
@ -170,12 +170,12 @@ if($_POST['committees_id'] && $_POST['committees_ord']) {
if($_POST['action']=="assign")
{
if($_POST['committees_id'] && $_POST['users_uid']) {
if($_POST['committees_id'] && $_POST['accounts_id']) {
$cid = intval($_POST['committees_id']);
$q=mysql_query("SELECT * FROM committees_link WHERE committees_id='$cid' AND users_uid='$uid'");
$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,users_uid) VALUES ('$cid','$uid')");
mysql_query("INSERT INTO committees_link (committees_id,accounts_id) VALUES ('$cid','$accounts_id')");
echo happy(i18n("Successfully added member to committee"));
}
else
@ -193,7 +193,7 @@ if($_GET['deletecommittee']) {
if($_POST['action']=="remove") {
/* user_delete takes care of unlinking the user in other tables */
user_delete($uid, 'committee');
user_delete($accounts_id, 'committee');
echo happy(i18n("Committee member deleted"));
}
@ -201,7 +201,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_uid='$mem' AND committees_id='$com'");
mysql_query("DELETE FROM committees_link WHERE accounts_id='$mem' AND committees_id='$com'");
echo happy(i18n("Committee member unlinked from committee"));
}
@ -247,14 +247,14 @@ if($_GET['unlinkmember'] && $_GET['unlinkcommittee']) {
echo "</select>";
echo "</td><td>";
$q=mysql_query("SELECT uid,MAX(year),firstname,lastname,email,deleted FROM users WHERE types LIKE '%committee%' GROUP BY uid ORDER BY firstname");
echo "<select name=\"users_uid\">";
$q=mysql_query("SELECT accounts_id,MAX(year),firstname,lastname,email,deleted FROM users WHERE types LIKE '%committee%' GROUP BY accounts_id ORDER BY firstname");
echo "<select name=\"accounts_id\">";
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->uid\">$displayname ($r->email)</option>\n";
echo "<option value=\"$r->accounts_id\">$displayname ($r->email)</option>\n";
}
echo "</select>";
@ -308,13 +308,13 @@ if($_GET['unlinkmember'] && $_GET['unlinkcommittee']) {
$q2=mysql_query("SELECT
committees_link.title,
committees_link.ord,
users.uid,
users.accounts_id,
MAX(users.year) AS my,
users.lastname
FROM committees_link
JOIN users ON users.uid = committees_link.users_uid
JOIN users ON users.accounts_id = committees_link.accounts_id
WHERE committees_id='{$r->id}'
GROUP BY users.uid
GROUP BY users.accounts_id
ORDER BY ord,
users.lastname ");
@ -326,18 +326,18 @@ if($_GET['unlinkmember'] && $_GET['unlinkcommittee']) {
echo "</td></tr>\n";
echo mysql_error();
while($r2=mysql_fetch_object($q2)) {
$u = user_load_by_uid($r2->uid);
$u = user_load_by_accounts_id($r2->accounts_id);
echo "<tr><td align=\"right\">&nbsp;&nbsp;&nbsp;&nbsp;";
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 "&nbsp;";
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['uid']}&amp;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['accounts_id']}&amp;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['name']}</b>";
echo "</td><td>";
echo "<input type=\"text\" value=\"{$r2->title}\" name=\"title[{$r->id}][{$u['uid']}]\" size=\"15\">";
echo "<input type=\"text\" value=\"{$r2->title}\" name=\"title[{$r->id}][{$u['accounts_id']}]\" size=\"15\">";
echo "</td><td>";
echo "<input type=\"text\" value=\"{$r2->ord}\" name=\"order[{$r->id}][{$u['uid']}]\" size=\"2\">";
echo "<input type=\"text\" value=\"{$r2->ord}\" name=\"order[{$r->id}][{$u['accounts_id']}]\" size=\"2\">";
echo "</td><td>";

View File

@ -30,10 +30,10 @@
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
while($r=mysql_fetch_object($q)) {
/* 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
$q2=mysql_query("SELECT committees_link.*,users.accounts_id,MAX(users.year),users.lastname
FROM committees_link LEFT JOIN users ON users.accounts_id = committees_link.accounts_id
WHERE committees_id='{$r->id}'
GROUP BY users.uid ORDER BY ord,users.lastname ");
GROUP BY users.accounts_id 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)
@ -46,8 +46,8 @@
echo mysql_error();
while($r2=mysql_fetch_object($q2)) {
$uid = $r2->users_uid;
$u = user_load_by_uid($uid);
$accid = $r2->accounts_id;
$u = user_load_by_accounts_id($accid);
$output=$config['committee_publiclayout'];

View File

@ -85,10 +85,10 @@ function tochange() {
/* 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
$q2=mysql_query("SELECT committees_link.*,users.accounts_id,MAX(users.year),users.firstname,users.lastname,users.email,users.deleted
FROM committees_link LEFT JOIN users ON users.accounts_id = committees_link.accounts_id
WHERE committees_id='{$r->id}'
GROUP BY users.uid ORDER BY ord,users.lastname ");
GROUP BY users.accounts_id 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)

View File

@ -1 +1 @@
202
203

2
db/db.update.203.sql Normal file
View File

@ -0,0 +1,2 @@
ALTER TABLE `committees_link` CHANGE `users_uid` `accounts_id` INT( 11 ) NOT NULL DEFAULT '0';

View File

@ -297,7 +297,7 @@ function user_remove_role(&$u, $role)
/* Do role-specific remove actions */
switch($role) {
case 'committee':
mysql_query("DELETE FROM committees_link WHERE users_uid='{$u['accounts_id']}'");
mysql_query("DELETE FROM committees_link WHERE accounts_id='{$u['accounts_id']}'");
break;
case 'judge':