|
From: Jirka P. <fi...@us...> - 2002-06-18 16:36:24
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv14847/phpbt
Modified Files:
user.php
Log Message:
Added this, localized that and did some cleanup. It was mostly about personal page's checkbox which checks whether saved queries will be shown on homepage or not. I will change homepage template tomorrow (if nobody will do it until) or any other day, but not today, because as usual I'm going home.
Index: user.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/user.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- user.php 18 May 2002 02:59:32 -0000 1.26
+++ user.php 18 Jun 2002 16:36:21 -0000 1.27
@@ -25,114 +25,130 @@
include 'include.php';
function delete_vote($bug_id) {
- global $db, $u, $me, $now;
+ global $db, $u, $me, $now;
- $db->query("delete from ".TBL_BUG_VOTE." where user_id = $u and bug_id = $bug_id");
- header("Location: $me?r=$now");
+ $db->query("delete from ".TBL_BUG_VOTE." where user_id = $u and bug_id = $bug_id");
+ header("Location: $me?r=$now");
}
function change_bug_list_columns($column_list) {
- global $db, $u, $t, $HTTP_SESSION_VARS;
+ global $db, $u, $t, $HTTP_SESSION_VARS, $STRING;
- $HTTP_SESSION_VARS['db_fields'] = $column_list;
- $column_list = serialize($column_list);
- $db->query("update ".TBL_AUTH_USER." set bug_list_fields = '$column_list' where user_id = $u");
- show_text('Your bug list column preferences have been saved');
+ $HTTP_SESSION_VARS['db_fields'] = $column_list;
+ $column_list = serialize($column_list);
+ $db->query("update ".TBL_AUTH_USER." set bug_list_fields = '$column_list' where user_id = $u");
+ show_text($STRING['USER_PREF']['ColumnPreferencesSaved']);
}
function change_password($pass1, $pass2) {
- global $t, $db, $u, $STRING;
-
- if (!$pass1 = trim($pass1)) {
- $error = $STRING['givepassword'];
- } elseif ($pass1 != $pass2) {
- $error = $STRING['passwordmatch'];
- } else {
- $error = false;
- }
-
- if ($error) {
- show_preferences_form($error);
- return;
- }
-
- if (ENCRYPT_PASS) {
- $mpassword = md5($pass1);
- } else {
- $mpassword = $pass1;
- }
-
- $db->query("update ".TBL_AUTH_USER." set password = '$mpassword' where user_id = $u");
- $t->assign('changetext', $STRING['password_changed']);
- $t->wrap('changessaved.html', 'changessaved');
+ global $t, $db, $u, $STRING;
+
+ if (!$pass1 = trim($pass1)) {
+ $error = $STRING['givepassword'];
+ } elseif ($pass1 != $pass2) {
+ $error = $STRING['passwordmatch'];
+ } else {
+ $error = false;
+ }
+
+ if ($error) {
+ show_preferences_form($error);
+ return;
+ }
+
+ if (ENCRYPT_PASS) {
+ $mpassword = md5($pass1);
+ } else {
+ $mpassword = $pass1;
+ }
+
+ $db->query("update ".TBL_AUTH_USER." set password = '$mpassword' where user_id = $u");
+ $t->assign('changetext', $STRING['password_changed']);
+ $t->wrap('changessaved.html', 'changessaved');
}
// Save changes to a user's preferences
function change_preferences($prefs) {
- global $db, $u, $t;
-
- $updates = array();
-
- $old_prefs = $db->getRow("select * from ".TBL_USER_PREF." where user_id = $u");
- array_shift($old_prefs); // Drop the user_id field
- $updates = array();
- foreach ($old_prefs as $pref => $val) {
- if (in_array($pref, $prefs) and !$val) {
- $updates[] = "set $pref = 1";
- } elseif (!in_array($pref, $prefs) and $val) {
- $updates[] = "set $pref = 0";
- }
- }
- if (count($updates)) {
- $db->query("update ".TBL_USER_PREF.' '.@join(', ', $updates).
- " where user_id = $u");
- }
- $t->assign('changetext', $STRING['prefs_changed']);
- $t->wrap('changessaved.html', 'changessaved');
+ global $db, $u, $t, $STRING;
+
+ $updates = array();
+ $old_prefs = $db->getRow("select * from ".TBL_USER_PREF." where user_id = $u");
+
+ array_shift($old_prefs); // Drop the user_id field
+ $updates = array();
+ foreach ($old_prefs as $pref => $val) {
+ if (in_array($pref, $prefs) and !$val) {
+ $updates[] = "set $pref = 1";
+ } elseif (!in_array($pref, $prefs) and $val) {
+ $updates[] = "set $pref = 0";
+ }
+ }
+ if (count($updates)) {
+ $db->query("update ".TBL_USER_PREF.' '.@join(', ', $updates).
+ " where user_id = $u");
+ }
+
+ $t->assign('changetext', $STRING['prefs_changed']);
+ $t->wrap('changessaved.html', 'changessaved');
}
function show_preferences_form($error = '') {
- global $t, $all_db_fields, $default_db_fields, $_sv, $db, $u;
-
- // Display the votes (if any)
- $t->assign('votes',
- $db->getAll("select * from ".TBL_BUG_VOTE." where user_id = $u"));
-
- // Display current preference settings
- $pref_labels = array(
- 'email_notices' => 'Receive notifications of bug changes via email'
- );
- $prefs = $db->getRow("select * from ".TBL_USER_PREF." where user_id = $u");
- foreach ($pref_labels as $pref => $label) {
- $preferences[] = array(
- 'pref' => $pref,
- 'label' => $label,
- 'checked' => $prefs[$pref]
- );
- }
+ global $t, $all_db_fields, $default_db_fields, $_sv, $db, $u, $STRING;
- $t->assign(array(
- 'error' => $error,
- 'my_fields' => $_sv['db_fields'] ? $_sv['db_fields'] : $default_db_fields,
- 'field_titles' => $all_db_fields,
- 'preferences' => $preferences
- ));
+ // Display the votes (if any)
+ $t->assign('votes',
+ $db->getAll("select * from ".TBL_BUG_VOTE." where user_id = $u"));
+
+ // Display current preference settings
+ $pref_labels = array(
+ 'email_notices' => $STRING['USER_PREF']['ReceiveNotifications'],
+ 'saved_queries' => $STRING['USER_PREF']['ShowSavedQueries']
+ );
+
+ $prefs = $db->getRow("select * from ".TBL_USER_PREF." where user_id = $u");
+ foreach ($pref_labels as $pref => $label) {
+ $preferences[] = array(
+ 'pref' => $pref,
+ 'label' => $label,
+ 'checked' => $prefs[$pref]
+ );
+ }
+
+ $t->assign(array(
+ 'error' => $error,
+ 'my_fields' => $_sv['db_fields'] ? $_sv['db_fields'] : $default_db_fields,
+ 'field_titles' => $all_db_fields,
+ 'preferences' => $preferences
+ ));
- $t->wrap('user.html', 'preferences');
+ $t->wrap('user.html', 'preferences');
}
$perm->check_group('User');
-if (isset($_gv['op'])) switch ($_gv['op']) {
- case 'delvote' : delete_vote($_gv['bugid']); break;
-}
-elseif (isset($_pv['do'])) switch ($_pv['do']) {
- case 'changepassword' : change_password($_pv['pass1'], $_pv['pass2']); break;
- case 'changecolumnlist' : change_bug_list_columns($_pv['column_list']); break;
- case 'changeprefs' : change_preferences(isset($_pv['preferences']) ? $_pv['preferences'] : array()); break;
- default : show_preferences_form();
+if (isset($_gv['op'])) {
+ switch ($_gv['op']) {
+ case 'delvote':
+ delete_vote($_gv['bugid']);
+ break;
+ }
+} elseif (isset($_pv['do'])) {
+ switch ($_pv['do']) {
+ case 'changepassword':
+ change_password($_pv['pass1'], $_pv['pass2']);
+ break;
+ case 'changecolumnlist':
+ change_bug_list_columns($_pv['column_list']);
+ break;
+ case 'changeprefs':
+ change_preferences(isset($_pv['preferences']) ? $_pv['preferences'] : array());
+ break;
+ default:
+ show_preferences_form();
+ }
+} else {
+ show_preferences_form();
}
-else show_preferences_form();
?>
|