From 37703a60478c62e746db639d967c400435d9e28e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 31 Jul 2006 23:49:34 +0000 Subject: [PATCH] r983: We can now change email options for users in the ACP --- admin/user.php | 116 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/admin/user.php b/admin/user.php index 2f57cd6..6a2d650 100644 --- a/admin/user.php +++ b/admin/user.php @@ -34,6 +34,22 @@ if (!can_perform('canadminusers')) admin_login(); } +// ################################################################### +/** +* Generate an inline checkbox +* +* @access public +* +* @param string Name +* @param bool Checked? +* +* @return string HTML checkbxo +*/ +function draw_checkbox($name, $checked) +{ + return ""; +} + // ################################################################### if (empty($_REQUEST['do'])) @@ -79,6 +95,17 @@ if ($_POST['do'] == 'insert') $user->set('defaultsortas', $bugsys->in['defaultsortas']); $user->insert(); + $bugsys->input_clean('emailopts', TYPE_INT); + foreach ($bugsys->in['emailopts'] AS $relation => $bitarr) + { + $bitmask = 0; + foreach ($bitarr AS $option => $yes) + { + $bitmask += $option * $yes; + } + $db->query("INSERT INTO " . TABLE_PREFIX . "useremail (userid, relation, mask) VALUES (" . $bugsys->userinfo['userid'] . ", $relation, $bitmask)"); + } + $admin->redirect('user.php?do=edit&userid=' . $user->insertid); } @@ -103,6 +130,18 @@ if ($_POST['do'] == 'update') $user->set('defaultsortas', $bugsys->in['defaultsortas']); $user->update(); + $db->query("DELETE FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $bugsys->userinfo['userid']); + $bugsys->input_clean('emailopts', TYPE_INT); + foreach ($bugsys->in['emailopts'] AS $relation => $bitarr) + { + $bitmask = 0; + foreach ($bitarr AS $option => $yes) + { + $bitmask += $option * $yes; + } + $db->query("INSERT INTO " . TABLE_PREFIX . "useremail (userid, relation, mask) VALUES (" . $bugsys->userinfo['userid'] . ", $relation, $bitmask)"); + } + $admin->redirect('user.php?do=edit&userid=' . $user->objdata['userid']); } @@ -172,7 +211,82 @@ if ($_REQUEST['do'] == 'edit' OR $_REQUEST['do'] == 'add') $admin->row_text($lang->string('Default Sort Order Column'), construct_option_select('defaultsortkey', ListSorter::fetch_by_text(false), $user->objdata['defaultsortkey'])); $admin->row_text($lang->string('Default Sort Order Direction'), construct_option_select('defaultsortas', ListSorter::fetch_as_text(false), $user->objdata['defaultsortas'])); - $admin->row_submit(); + $admin->table_end(); + + // ------------------------------------------------------------------- + $admin->table_start(false); + $admin->table_head($lang->string('Email Options'), 6); + + $options = $db->query("SELECT * FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $bugsys->userinfo['userid']); + while ($opt = $db->fetch_array($options)) + { + foreach ($bugsys->emailoptions['notifications'] AS $name => $notif) + { + foreach ($bugsys->emailoptions['relations'] AS $name => $relation) + { + if ($opt['mask'] & $notif AND $opt['relation'] == $relation) + { + $checked["$relation"]["$notif"] = HTML_CHECKED; + } + } + } + } + + $admin->table_column_head(array('', $lang->string('Reporter'), $lang->string('Assignee'), $lang->string('Favourite'), $lang->string('Voter'), $lang->string('Commenter'))); + + // ------------------------------------------------------------------- + + $admin->row_text($lang->string('New bug is added'), '
' . draw_checkbox('emailopts[0][2048]', $checked[0][2048]) . '
', 'top', 6); + + $admin->row_text($lang->string('I am made the assignee'), '
' . draw_checkbox('emailopts[0][32]', $checked[0][32]) . '
', 'top', 6); + + $admin->row_multi_item(array( + $lang->string('Status or resolution changes') => 'l', + draw_checkbox('emailopts[1][64]', $checked[1][64]) => 'c', + draw_checkbox('emailopts[2][64]', $checked[2][64]) => 'c', + draw_checkbox('emailopts[4][64]', $checked[4][64]) => 'c', + draw_checkbox('emailopts[8][64]', $checked[8][64]) => 'c', + draw_checkbox('emailopts[16][64]', $checked[16][64]) => 'c', + )); + + $admin->row_multi_item(array( + $lang->string("'Duplicates' field is changed") => 'l', + draw_checkbox('emailopts[1][128]', $checked[1][128]) => 'c', + draw_checkbox('emailopts[2][128]', $checked[2][128]) => 'c', + draw_checkbox('emailopts[4][128]', $checked[4][128]) => 'c', + draw_checkbox('emailopts[8][128]', $checked[8][128]) => 'c', + draw_checkbox('emailopts[16][128]', $checked[16][128]) => 'c', + )); + + $admin->row_multi_item(array( + $lang->string('A new comment is added') => 'l', + draw_checkbox('emailopts[1][256]', $checked[1][256]) => 'c', + draw_checkbox('emailopts[2][256]', $checked[2][256]) => 'c', + draw_checkbox('emailopts[4][256]', $checked[4][256]) => 'c', + draw_checkbox('emailopts[8][256]', $checked[8][256]) => 'c', + draw_checkbox('emailopts[16][256]', $checked[16][256]) => 'c', + )); + + $admin->row_multi_item(array( + $lang->string('A new attachment is added') => 'l', + draw_checkbox('emailopts[1][512]', $checked[1][512]) => 'c', + draw_checkbox('emailopts[2][512]', $checked[2][512]) => 'c', + draw_checkbox('emailopts[4][512]', $checked[4][512]) => 'c', + draw_checkbox('emailopts[8][512]', $checked[8][512]) => 'c', + draw_checkbox('emailopts[16][512]', $checked[16][512]) => 'c', + )); + + $admin->row_multi_item(array( + $lang->string('Any other field changes') => 'l', + draw_checkbox('emailopts[1][1024]', $checked[1][1024]) => 'c', + draw_checkbox('emailopts[2][1024]', $checked[2][1024]) => 'c', + draw_checkbox('emailopts[4][1024]', $checked[4][1024]) => 'c', + draw_checkbox('emailopts[8][1024]', $checked[8][1024]) => 'c', + draw_checkbox('emailopts[16][1024]', $checked[16][1024]) => 'c', + )); + + // ------------------------------------------------------------------- + $admin->row_submit(null, ':save:', ':reset:', 6); $admin->table_end(); $admin->form_end(); -- 2.22.5