From 541ed0f389297e62f1624e6453d46d620a6369d8 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 28 May 2006 00:20:25 +0000 Subject: [PATCH] r850: Adding email options interface and backbone, though it doesn't send anything at the moment --- docs/schema_changes.sql | 7 +++ docs/template_changes.txt | 107 ++++++++++++++++++++++++++++++++++++++ global.php | 2 + includes/permissions.php | 38 ++++++++------ templates/userctrl.tpl | 92 ++++++++++++++++++++++++++++++++ userctrl.php | 50 ++++++++++++++++++ 6 files changed, 279 insertions(+), 17 deletions(-) diff --git a/docs/schema_changes.sql b/docs/schema_changes.sql index a5bc203..010ed97 100644 --- a/docs/schema_changes.sql +++ b/docs/schema_changes.sql @@ -5,3 +5,10 @@ ALTER TABLE bug ADD username varchar(255) NOT NULL; ALTER TABLE bug ADD lastpostbyname varchar(255) NOT NULL; ALTER TABLE bug ADD hiddenlastpostbyname varchar(255) NOT NULL; + +CREATE TABLE useremail +( + userid int unsigned not null, + relation int unsigned not null, + mask int unsigned not null +); diff --git a/docs/template_changes.txt b/docs/template_changes.txt index 9fee9c5..c00a737 100644 --- a/docs/template_changes.txt +++ b/docs/template_changes.txt @@ -144,4 +144,111 @@ Index: templates/global.css + font-size: 12px; background-color: rgb(102, 102, 102); } +################################################################### + +################################################################### +userctrl.tpl (added email reporting options) +------------------------------------------------------------------- +Index: templates/userctrl.tpl +=================================================================== +--- templates/userctrl.tpl (revision 846) ++++ templates/userctrl.tpl (working copy) +@@ -105,6 +105,98 @@ + + + ++
++ ++
++
{@"Email Options"}
++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
{@"Reporter"}{@"Assignee"}{@"Favourite"}{@"Voter"}{@"Commenter"}
{@"I am made the assignee"}
{@"Status or resolution changes"}
{@"'Duplicates' field is changed"}
{@"A new comment is added"}
{@"A new attachment is added"}
{@"Any other field changes"}
{@"NOT IF an unconfirmed bug"}
{@"NOT IF change was by me"}
++
++
++ ++
++ ++
++ ++ ++
++ + + ################################################################### \ No newline at end of file diff --git a/global.php b/global.php index db51b7d..03a3703 100755 --- a/global.php +++ b/global.php @@ -21,6 +21,8 @@ require_once('./includes/init.php'); +define('HTML_CHECKED', ' checked="checked"'); + // ################################################################### // initialize template system $bugsys->load('template_fs', 'template', true); diff --git a/includes/permissions.php b/includes/permissions.php index 9015e4e..0e56279 100644 --- a/includes/permissions.php +++ b/includes/permissions.php @@ -52,24 +52,28 @@ foreach ($_PERMISSION AS $name => $maskvalue) } $bugsys->emailoptions = array( - // a user's relation to the bug - 'reporter' => 1, // report the bug - 'assignee' => 2, // assigned to the bug - 'favourite' => 4, // on the favourites list - 'voter' => 8, // voted for the bug - 'commenter' => 16, // left a comment on the bug + 'relations' => array( + // a user's relation to the bug + 'reporter' => 1, // report the bug + 'assignee' => 2, // assigned to the bug + 'favourite' => 4, // on the favourites list + 'voter' => 8, // voted for the bug + 'commenter' => 16 // left a comment on the bug + ), - // notifiaction message types - 'assignedto' => 32, // I am made the assignee - 'statusresolve' => 64, // status or resolution changes - 'duplicates' => 128, // a duplicate bug is added - 'newcomment' => 256, // new comment - 'newattachment' => 512, // new attachment - 'otherfield' => 1024, // any other field changes - - // exclusionary - 'notunconfirmed' => 2048, // not for unconfirmed bugs - 'notbyme' => 4096 // not for changes by me + 'notifications' => array( + // notifiaction message types + 'assignedto' => 32, // I am made the assignee + 'statusresolve' => 64, // status or resolution changes + 'duplicates' => 128, // a duplicate bug is added + 'newcomment' => 256, // new comment + 'newattachment' => 512, // new attachment + 'otherfield' => 1024, // any other field changes + + // exclusionary + 'notunconfirmed' => 2048, // not for unconfirmed bugs + 'notbyme' => 4096 // not for changes by me + ) ); /*=====================================================================*\ diff --git a/templates/userctrl.tpl b/templates/userctrl.tpl index 8c37fee..4f8ca57 100644 --- a/templates/userctrl.tpl +++ b/templates/userctrl.tpl @@ -105,6 +105,98 @@ $header +
+ +
+
{@"Email Options"}
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{@"Reporter"}{@"Assignee"}{@"Favourite"}{@"Voter"}{@"Commenter"}
{@"I am made the assignee"}
{@"Status or resolution changes"}
{@"'Duplicates' field is changed"}
{@"A new comment is added"}
{@"A new attachment is added"}
{@"Any other field changes"}
{@"NOT IF an unconfirmed bug"}
{@"NOT IF change was by me"}
+
+
+ +
+ +
+ + +
+ diff --git a/userctrl.php b/userctrl.php index ca5f7c3..09cd937 100644 --- a/userctrl.php +++ b/userctrl.php @@ -148,6 +148,18 @@ if ($_POST['do'] == 'update') build_assignedto(); } + $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)"); + } + $message->redirect($lang->string('The changes to your account have been made.'), 'userctrl.php'); } } @@ -164,6 +176,44 @@ if ($_REQUEST['do'] == 'modify') eval('$tzselect .= "' . $template->fetch('selectoption') . '";'); } + $checked = array(); + if (!is_array($bugsys->in['emailopts'])) + { + $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) + { + if ($opt['mask'] == $notif) + { + $checked[0]["$notif"] = HTML_CHECKED; + break; + } + foreach ($bugsys->emailoptions['relations'] AS $name => $relation) + { + if ($opt['mask'] & $notif AND $opt['relation'] == $relation) + { + $checked["$relation"]["$notif"] = HTML_CHECKED; + } + } + } + } + } + else + { + $checked = $bugsys->in['emailopts']; + foreach ($checked AS $key1 => $value1) + { + foreach ($value1 AS $key2 => $value2) + { + if ($value2) + { + $checked["$key1"]["$key2"] = HTML_CHECKED; + } + } + } + } + eval('$template->flush("' . $template->fetch('userctrl') . '");'); } -- 2.22.5