Commit 57cfa23b authored by Timothy Stack's avatar Timothy Stack
Browse files

Patches against the revision of flyspray we use at the moment (r502).

parent 99320434
Tweaks for notification stuff:
* Put mail addresses in the To: header so mailman doesn't get upset.
* Add meaningful subject lines, even though they aren't localized.
* Squelch notifications for some events.
Index: includes/notify.inc.php
===================================================================
--- includes/notify.inc.php (revision 502)
+++ includes/notify.inc.php (working copy)
@@ -27,9 +27,9 @@
// This function is the wrapper for the others in this class
// It addresses, creates and stores/sends the notifications
- function Create ( $type, $task_id, $info )
+ function Create ( $type, $task_id, $info = '')
{
- $to = $this->Address($task_id);
+ $to = $this->Address($type, $task_id);
$msg = $this->GenerateMsg($type, $task_id, $info);
$this->SendEmail($to[0], $msg[0], $msg[1]);
$this->StoreJabber($to[1], $msg[0], $msg[1]);
@@ -271,11 +271,11 @@
if (is_array($to))
{
- $mail->AddAddress($fs->prefs['admin_email']);
+ // $mail->AddAddress($fs->prefs['admin_email']);
foreach ($to as $key => $val)
{
// Unlike the docs say, it *does (appear to)* work with mail()
- $mail->AddBcc($val); // Add each address
+ $mail->AddAddress($val); // Add each address
}
} else {
@@ -361,6 +361,8 @@
///////////////////////////////////////////////////////////////
if ($type == '1')
{
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " '" . $task_details['item_summary'] . "' opened";
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $notify_text['newtaskopened'] . "\n\n";
$body .= $notify_text['userwho'] . ' - ' . $user->infos['real_name'] . ' (' . $user->infos['user_name'] . ")\n\n";
@@ -389,6 +391,9 @@
//////////////////////////
if ($type == '2')
{
+ // Generate the nofication message
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " changed";
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $notify_text['taskchanged'] . "\n\n";
$body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
@@ -420,6 +425,9 @@
/////////////////
if ($type == '3')
{
+ // Generate the nofication message
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " closed";
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $notify_text['taskclosed'] . "\n\n";
$body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
@@ -444,6 +452,8 @@
////////////////////
if ($type == '4')
{
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " re-opened";
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $notify_text['taskreopened'] . "\n\n";
$body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
@@ -460,8 +470,11 @@
//////////////////////
if ($type == '5')
{
+ // Generate the nofication message
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " dependency added";
+
$depend_task = $fs->getTaskDetails($arg1);
-
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $notify_text['depadded'] . "\n\n";
$body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
@@ -481,6 +494,9 @@
////////////////////////
if ($type == '6')
{
+ // Generate the nofication message
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " dependency removed";
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $notify_text['depremoved'] . "\n\n";
$body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
@@ -508,6 +524,9 @@
);
$comment = $db->FetchArray($result);
+ // Generate the nofication message
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " comment added";
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $notify_text['commentadded'] . "\n\n";
$body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
@@ -532,6 +551,8 @@
//////////////////////
if ($type == '8')
{
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " attachment added";
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $notify_text['attachmentadded'] . "\n\n";
$body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
@@ -548,6 +569,7 @@
////////////////////////
if ($type == '9')
{
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " related task added";
$related_task = $fs->getTaskDetails($arg1);
$body = $notify_text['donotreply'] . "\n\n";
@@ -569,6 +591,8 @@
/////////////////////
if ($type == '10')
{
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " assigned to " . $task_details['assigned_to_name'];
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $task_details['assigned_to_name'] . ' ' . $notify_text['takenownership'] . "\n\n";
$body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n\n";
@@ -635,6 +659,8 @@
//////////////////
if ($type == '14')
{
+ $subject = $proj->prefs['project_title'] . " FS#" . $task_id . " assigned to " . $current_user['user_name'];
+
$body = $notify_text['donotreply'] . "\n\n";
$body .= $notify_text['assignedtoyou'] . "\n\n";
$body .= 'FS#' . $task_id . ' - ' . $task_details['item_summary'] . "\n";
@@ -706,7 +732,7 @@
// This sends a notification to multiple users, usually from the notifications tab on a task
- function Address($task_id)
+ function Address($type, $task_id)
{
global $db;
global $fs;
@@ -772,7 +798,9 @@
// Now, we add the project contact addresses...
// ...but only if the task is public
$task_details = $fs->getTaskDetails($task_id);
- if ($task_details['mark_private'] != '1')
+ if (($task_details['mark_private'] != '1') &&
+ (($type == 1) || ($type == 3) || ($type == 4) || ($type == 10) ||
+ ($type == 14)))
{
$proj_emails = explode(",", $proj->prefs['notify_email']);
$proj_jids = explode(",", $proj->prefs['notify_jabber']);
Performance tweak for a slow SQL statement.
Index: index.php
===================================================================
--- index.php (revision 502)
+++ index.php (working copy)
@@ -130,10 +130,12 @@
// or, if the user is logged in
$sql = $db->Query(
"SELECT p.project_id, p.project_title
- FROM {projects} p
- LEFT JOIN {groups} g ON p.project_id=g.belongs_to_project AND g.view_tasks=1
- LEFT JOIN {users_in_groups} uig ON uig.group_id = g.group_id AND uig.user_id = ?
- WHERE p.project_is_active='1' AND (p.others_view OR uig.user_id IS NOT NULL)
+ FROM {users_in_groups} uig
+ LEFT JOIN {groups} g ON uig.group_id = g.group_id
+ LEFT JOIN {projects} p ON g.belongs_to_project = p.project_id
+ WHERE uig.user_id = ? AND p.project_is_active='1' AND
+ g.view_tasks='1' AND
+ (p.others_view OR uig.user_id IS NOT NULL)
ORDER BY p.project_title", array($user->id));
}
else {
Fixes for misc. scripts.
* Remove a bogus check.
* Add support for xlogin from boss.
* Fix SQL syntax errors.
* Move notification to the right place.
* Allow the current project to be specified with the project_title arg.
Index: scripts/index.php
===================================================================
--- scripts/index.php (revision 502)
+++ scripts/index.php (working copy)
@@ -10,10 +10,6 @@
$fs->Redirect( $fs->CreateURL('error', null) );
}
-if (Get::val('project') === '0' && !$user->perms['global_view']) {
- $fs->Redirect( $fs->CreateURL('error', null) );
-}
-
// First, the obligatory language packs
$fs->get_language_pack('index');
$fs->get_language_pack('details');
Index: scripts/authenticate.php
===================================================================
--- scripts/authenticate.php (revision 502)
+++ scripts/authenticate.php (working copy)
@@ -58,6 +58,33 @@
$_SESSION['SUCCESS'] = $authenticate_text['loginsuccessful'];
}
+} elseif (Req::has('username') && Req::has('bosscred')) {
+ $username = Req::val('username');
+ $bosscred = Req::val('bosscred');
+
+ if (($user_id = $fs->checkXLogin($username, $bosscred))) {
+ $cookie_time = 0;
+ $user = new User($user_id);
+
+ // Set a couple of cookies
+ $fs->setcookie('flyspray_userid',
+ $user->id, $cookie_time);
+ $fs->setcookie('flyspray_passhash',
+ crypt($user->infos['user_pass'], $conf['general']['cookiesalt']), $cookie_time);
+ Cookie::clr('flyspray_project');
+ $fs->setcookie('flyspray_project', '', time()-60);
+
+ $remove_magic = $db->Query("UPDATE {users} SET cred=NULL ".
+ "WHERE user_id = ?",
+ array($user->id)
+ );
+
+ $_SESSION['SUCCESS'] = $authenticate_text['loginsuccessful'];
+ }
+ else {
+ $_SESSION['ERROR'] = $authenticate_text['loginfailed'];
+ $fs->redirect(Req::val('prev_page'));
+ }
}
else {
// If the user didn't provide both a username and a password, show this error:
Index: scripts/depends.php
===================================================================
--- scripts/depends.php (revision 502)
+++ scripts/depends.php (working copy)
@@ -71,11 +71,11 @@
t2.closure_comment AS com2, u2c.real_name AS clsdby2,
r2.resolution_name as res2
FROM {dependencies} AS d
- JOIN {tasks} AS t1 ON d.task_id=t1.task_id
+ INNER JOIN {tasks} AS t1 ON d.task_id=t1.task_id
LEFT JOIN {users} AS u1a ON t1.assigned_to=u1a.user_id
LEFT JOIN {users} AS u1c ON t1.closed_by=u1c.user_id
LEFT JOIN {list_resolution} AS r1 ON t1.resolution_reason=r1.resolution_id
- JOIN {tasks} AS t2 ON d.dep_task_id=t2.task_id
+ INNER JOIN {tasks} AS t2 ON d.dep_task_id=t2.task_id
LEFT JOIN {users} AS u2a ON t2.assigned_to=u2a.user_id
LEFT JOIN {users} AS u2c ON t2.closed_by=u2c.user_id
LEFT JOIN {list_resolution} AS r2 ON t2.resolution_reason=r2.resolution_id
Index: scripts/modify.php
===================================================================
--- scripts/modify.php (revision 502)
+++ scripts/modify.php (working copy)
@@ -67,7 +67,7 @@
attached_to_project, item_summary,
detailed_desc, opened_by,
percent_complete, $sql_params )
- VALUES ( ?, ?, $sql_placeholder)", $sql_values);
+ VALUES ($sql_placeholder)", $sql_values);
// Now, let's get the task_id back, so that we can send a direct link
// URL in the notification message
@@ -114,11 +114,11 @@
VALUES (?, ?)", array($task_id, $owner));
$fs->logEvent($task_id, 9, $owner);
-
- // Create the Notification
- $notify->Create('1', $task_id);
}
+ // Create the Notification
+ $notify->Create('1', $task_id);
+
// If the reporter wanted to be added to the notification list
if (Post::val('notifyme') == '1' && $user->id != $owner) {
$be->AddToNotifyList($user->id, $task_id);
Index: includes/class.backend.php
===================================================================
--- includes/class.backend.php (revision 502)
+++ includes/class.backend.php (working copy)
@@ -139,7 +139,7 @@
$_FILES['userfile']['type'][$key],
$_FILES['userfile']['size'][$key],
$_FILES['userfile']['name'][$key],
- $user->id), time());
+ $user->id, time()));
// Fetch the attachment id for the history log
$result = $db->Query("SELECT attachment_id
@@ -326,6 +326,12 @@
// End of checking if there's a category owner set, and notifying them.
}
+ if ($user->id != $owner) {
+ $this->AddToNotifyList($user->id, $task_id);
+ }
+
+ $notify->Create('1', $taskid);
+
// give some information back
return $task_details;
Index: includes/class.gpc.php
===================================================================
--- includes/class.gpc.php (revision 502)
+++ includes/class.gpc.php (working copy)
@@ -54,6 +54,11 @@
class Cookie
{
+ function clr($key)
+ {
+ unset($_COOKIE[$key]);
+ }
+
function has($key)
{
return isset($_COOKIE[$key]) && $_COOKIE[$key] !== '';
Index: includes/class.user.php
===================================================================
--- includes/class.user.php (revision 502)
+++ includes/class.user.php (working copy)
@@ -13,7 +13,7 @@
$sql = $db->Query("SELECT *, g.group_id AS global_group,
uig.record_id AS global_record_id
FROM {users} u
- INNER JOIN {users_in_groups} uig
+ JOIN {users_in_groups} uig
INNER JOIN {groups} g ON uig.group_id = g.group_id
WHERE u.user_id = ? AND g.belongs_to_project = '0'",
array($uid));
@@ -68,7 +68,7 @@
// Get the global group permissions for the current user
$sql = $db->Query("SELECT ".join(', ', $max).",
- MAX(IF(g.belongs_to_project, view_tasks, 0)) AS global_view
+ MAX(IF(g.belongs_to_project = 0, g.view_tasks, 0)) AS global_view
FROM {groups} g
LEFT JOIN {users_in_groups} uig ON g.group_id = uig.group_id
WHERE uig.user_id = ? AND
@@ -117,7 +117,7 @@
function can_create_group()
{
return $this->perms['is_admin']
- || ($this->perms['manage_project'] && !Get::val('project'));
+ || ($this->perms['manage_project'] && Get::val('project'));
}
function can_edit_comment($comment)
Index: includes/functions.inc.php
===================================================================
--- includes/functions.inc.php (revision 502)
+++ includes/functions.inc.php (working copy)
@@ -139,7 +139,8 @@
uo.real_name AS opened_by_name,
ue.real_name AS last_edited_by_name,
uc.real_name AS closed_by_name,
- ua.real_name AS assigned_to_name
+ ua.real_name AS assigned_to_name,
+ t.date_closed AS date_closed
FROM {tasks} t
LEFT JOIN {projects} p ON t.attached_to_project = p.project_id
LEFT JOIN {list_category} c ON t.product_category = c.category_id
@@ -475,12 +476,9 @@
case 32:
$password = md5($password);
break;
- case 13:
+ default:
$password = crypt($password, $auth_details['user_pass']); //using the salt from db
break;
- default:
- //unknown encryption!?
- return false;
}
// Compare the crypted password to the one in the database
@@ -494,7 +492,38 @@
return false;
}
+ // This function checks if a user provided the right credentials
+ function checkXLogin($username, $cred)
+ {
+ global $db;
+ global $dbprefix;
+ $result = $db->Query("SELECT uig.*, g.group_open, u.account_enabled,
+ u.cred FROM {users_in_groups} uig
+ LEFT JOIN {groups} g ON uig.group_id = g.group_id
+ LEFT JOIN {users} u ON uig.user_id = u.user_id
+ WHERE u.user_name = ? AND g.belongs_to_project = ?
+ ORDER BY g.group_id ASC",
+ array($username, '0'));
+
+ $auth_details = $db->FetchArray($result);
+
+ // Compare the credential to the one in the database
+ if ($cred == $auth_details['cred']
+ && $auth_details['account_enabled'] == '1'
+ && $auth_details['group_open'] == '1')
+ {
+ return $auth_details['user_id'];
+
+ } else
+ {
+ return false;
+ }
+
+ // End of checkXLogin function
+ }
+
+
function setCookie($name, $val, $time)
{
global $baseurl;
@@ -587,7 +616,7 @@
case 'newtask': return $url . '&project=' . $arg1;
case 'editgroup':
- case 'projgroup': return $conf['general']['baseurl'] . '?do=admin&area=editgroup&id=' . $arg1;
+ case 'projgroup': return $conf['general']['baseurl'] . '?do=pm&area=editgroup&id=' . $arg1;
case 'error':
case 'lostpw':
Index: header.php
===================================================================
--- header.php (revision 502)
+++ header.php (working copy)
@@ -49,6 +49,18 @@
// Determine which project we want to see
if (Req::val('project')) {
$project_id = Req::val('project');
+ } elseif (Req::has('project_title')) {
+ $get_pid = $db->Query("SELECT project_id
+ FROM {projects}
+ WHERE project_title = ?",
+ Req::val('project_title'));
+ if ($db->CountRows($get_pid) != 1)
+ $project_id = 0;
+ else
+ {
+ $row = $db->FetchArray($get_pid);
+ $project_id = $row['project_id'];
+ }
} else {
$project_id = Req::val('project_id', Cookie::val('flyspray_project',
$fs->prefs['default_project']));
Adapt the default "Bluey" theme to make it Emulab friendly.
* Change out the flyspray header with the emulab one.
* Make disabled form fields look disabled.
* Hide the logout button.
Index: themes/Bluey/theme.css
===================================================================
--- themes/Bluey/theme.css (revision 502)
+++ themes/Bluey/theme.css (working copy)
@@ -49,11 +49,10 @@
/* the main title; h1 alone is also used in the popup windows. */
h1#title {
- background:#47617b url("title.png") no-repeat;
- height:45px;
+ background:#ffffff url("http://www.emulab.net/headerbgbb.jpg") repeat;
+ height:100px;
margin:0;
- padding:1ex 0;
- text-indent:-9000px;
+ padding:0 0;
}
h2 {
@@ -86,6 +85,14 @@
margin:2px;
}
+input.disabled, textarea.disabled, select.disabled, button.disabled {
+ background-color : #dde6ee;
+ color : #02007e;
+ border : 1px ridge #000000;
+ margin : 2px;
+ font-size : 100%;
+}
+
textarea {
width:95%;
}
@@ -290,6 +297,13 @@
margin:3px 0 0;
}
+div#search select.disabled,div#search input.disabled {
+ background-color : #dde6ee;
+ color : #02007e;
+ border : 1px ridge #000000;
+ margin : 3px 0 0;
+}
+
div#search input.mainbutton {
color:#FFF;
}
@@ -1030,4 +1044,8 @@
table.requests td {
border:solid 1px black;
padding:0.2em 0.5em;
-}
\ No newline at end of file
+}
+
+#logoutlink {
+ visibility: hidden;
+}
Index: templates/common.profile.tpl
===================================================================
--- templates/common.profile.tpl (revision 502)
+++ templates/common.profile.tpl (working copy)
@@ -4,15 +4,23 @@
<tr>
<td><label for="realname">{$admin_text['realname']}</label></td>
<td>
+ <?php if (0): ?>
<input id="realname" type="text" name="real_name" size="50" maxlength="100"
value="{$theuser->infos['real_name']}" />
+ <?php else: ?>
+ {$theuser->infos['real_name']}
+ <?php endif; ?>
</td>
</tr>
<tr>
<td><label for="emailaddress">{$admin_text['emailaddress']}</label></td>
<td>
+ <?php if (0): ?>
<input id="emailaddress" type="text" name="email_address" size="50" maxlength="100"
value="{$theuser->infos['email_address']}" />
+ <?php else: ?>
+ {$theuser->infos['email_address']}
+ <?php endif; ?>
</td>
</tr>
<tr>
@@ -71,6 +79,7 @@
</td>
</tr>
<?php endif; ?>
+ <?php if (0): ?>
<tr>
<td colspan="2"><hr /></td>
</tr>
@@ -82,6 +91,7 @@
<td><label for="confirmpass">{$admin_text['confirmpass']}</label></td>
<td><input id="confirmpass" type="password" name="confirmpass" size="40" maxlength="100" /></td>
</tr>
+ <?php endif; ?>
<tr>
<td colspan="2" class="buttons">
<input type="hidden" name="do" value="modify" />
@@ -93,4 +103,4 @@
</tr>
</table>
</form>
-</fieldset>
\ No newline at end of file
+</fieldset>
Index: templates/common.groups.tpl
===================================================================
--- templates/common.groups.tpl (revision 502)
+++ templates/common.groups.tpl (working copy)
@@ -45,7 +45,7 @@
</form>
<?php endforeach; ?>
-<?php if ($proj->id): ?>
+<?php if (0 && $proj->id): ?>
<form action="{$baseurl}" method="post">
<div>
<input type="hidden" name="do" value="modify" />
Index: templates/links.tpl
===================================================================
--- templates/links.tpl (revision 502)
+++ templates/links.tpl (working copy)
@@ -5,7 +5,7 @@
<a href="{$fs->CreateURL('myprofile', null)}" title="{$language['editmydetails']}">
<em>{$user->infos['real_name']} ({$user->infos['user_name']})</em>
</a>
- <div id="permissions">
+ <div id="permissions" onmouseout='perms.do_later("hide")'>
{!tpl_draw_perms($user->perms)}
</div>
</li>
Index: templates/header.tpl
===================================================================
--- templates/header.tpl (revision 502)
+++ templates/header.tpl (working copy)
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="{$language['locale']}" xml:lang="{$language['locale']}">
<head>
- <title>Flyspray::&nbsp;&nbsp;{$proj->prefs['project_title']}:&nbsp;&nbsp;</title>
+ <title>Flyspray::{$proj->prefs['project_title']}:</title>
<meta name="description" content="Flyspray, a Bug Tracking System written in PHP." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@@ -32,7 +32,7 @@
</head>
<body onload="perms = new Perms('permissions')">
<!-- Remove this to remove the logo -->
- <h1 id="title">{$proj->prefs['project_title']}</h1>
+ <h1 id="title"><a href="https://www.emulab.net"><img src="https://www.emulab.net/overlay.emulab.net.gif" border=0></a></h1>
<?php
if ($user->isAnon()):
$this->display('loginbox.tpl');
@@ -83,4 +83,8 @@