From a40320278617989b21ff3cd9a882e5be9f359d2c Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 14 Jul 2010 21:04:50 +0000 Subject: [PATCH] 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. --- admin/committees.php | 46 +++++++++++++++++++++--------------------- committees.php | 10 ++++----- contact.php | 6 +++--- db/db.code.version.txt | 2 +- db/db.update.203.sql | 2 ++ user.inc.php | 2 +- 6 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 db/db.update.203.sql diff --git a/admin/committees.php b/admin/committees.php index e64a7d3..65d6864 100644 --- a/admin/committees.php +++ b/admin/committees.php @@ -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 ""; echo ""; - $q=mysql_query("SELECT uid,MAX(year),firstname,lastname,email,deleted FROM users WHERE types LIKE '%committee%' GROUP BY uid 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 ""; @@ -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 "\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 "    "; echo "\"Edit\""; echo " "; - echo "id}\">\"Unlink\""; + echo "id}\">\"Unlink\""; echo ""; echo ""; echo "{$u['name']}"; echo ""; - echo "title}\" name=\"title[{$r->id}][{$u['uid']}]\" size=\"15\">"; + echo "title}\" name=\"title[{$r->id}][{$u['accounts_id']}]\" size=\"15\">"; echo ""; - echo "ord}\" name=\"order[{$r->id}][{$u['uid']}]\" size=\"2\">"; + echo "ord}\" name=\"order[{$r->id}][{$u['accounts_id']}]\" size=\"2\">"; echo ""; diff --git a/committees.php b/committees.php index d3d473f..de70095 100644 --- a/committees.php +++ b/committees.php @@ -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']; diff --git a/contact.php b/contact.php index 68663fb..138dd09 100644 --- a/contact.php +++ b/contact.php @@ -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) diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 8f897c8..bb2ee19 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -202 +203 diff --git a/db/db.update.203.sql b/db/db.update.203.sql new file mode 100644 index 0000000..b5a3f65 --- /dev/null +++ b/db/db.update.203.sql @@ -0,0 +1,2 @@ +ALTER TABLE `committees_link` CHANGE `users_uid` `accounts_id` INT( 11 ) NOT NULL DEFAULT '0'; + diff --git a/user.inc.php b/user.inc.php index 7dedde8..a3d819d 100644 --- a/user.inc.php +++ b/user.inc.php @@ -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':