Skip to content

Commit

Permalink
Merge pull request #5735 from BOINC/dpa_forum6
Browse files Browse the repository at this point in the history
web: when create or post to a thread, add option for subscribing (default on)
  • Loading branch information
AenBleidd authored Aug 7, 2024
2 parents 190fa61 + a9a2a58 commit d238eae
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 189 deletions.
83 changes: 40 additions & 43 deletions html/inc/bbcode_html.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,44 @@ require_once("../inc/util.inc");
$bbcode_js = "<script type=\"text/javascript\" src=\"bbcode_toolbar.js\"></script>";

$bbcode_html = '
<tr>
<td>
<input type="button" class="btn btn-default btn-sm" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; " onClick="bbstyle(0)" title="'.tra("Bold text: [b]text[/b] (alt+b)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; " onClick="bbstyle(2)" title="'.tra("Italic text: [i]text[/i] (alt+i)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; " onClick="bbstyle(4)" title="'.tra("Underline text: [u]text[/u] (alt+u)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="k" name="addbbcode20" value=" k " style="text-decoration: line-through; " onClick="bbstyle(20)" title="'.tra("Strikethrough text: [s]text[/s] (alt+k)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="q" name="addbbcode6" value="Quote" onClick="bbstyle(6)" title="'.tra("Quote text: [quote]text[/quote] (alt+q)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="c" name="addbbcode8" value="Code" style="" onClick="bbstyle(8)" title="'.tra("Code display: [code]code[/code] (alt+c)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="l" name="addbbcode10" value="List" style="" onClick="bbstyle(10)" title="'.tra("List: [list]text[/list] (alt+l)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="o" name="addbbcode12" value="List=1" style="" onClick="bbstyle(12)" title="'.tra("Ordered list: [list=1]text[/list] (alt+o)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="p" name="addbbcode14" value="Img" style="" onClick="bbstyle(14)" title="'.tra("Insert image: [img]http://image_url[/img] (alt+p)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; " onClick="bbstyle(16)" title="'.tra("Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url] (alt+w)").'" />
</td>
</tr>
<tr>
<td>
&nbsp;'.tra("Font color").':
<select style="color:#000;" name="addbbcode22" onChange="bbfontstyle(\'[color=\' + this.form.addbbcode22.options[this.form.addbbcode22.selectedIndex].value + \']\', \'[/color]\');this.selectedIndex=0;" title="'.tra("Font color: [color=red]text[/color] Tip: you can also use color=#FF0000").'" >
<option style="color:black" value="#000000" class="genmed">'.tra("Default").'</option>
<option style="color:darkred" value="darkred" class="genmed">'.tra("Dark Red").'</option>
<option style="color:red" value="red" class="genmed">'.tra("Red").'</option>
<option style="color:orange" value="orange" class="genmed">'.tra("Orange").'</option>
<option style="color:brown" value="brown" class="genmed">'.tra("Brown").'</option>
<option style="color:yellow" value="yellow" class="genmed">'.tra("Yellow").'</option>
<option style="color:green" value="green" class="genmed">'.tra("Green").'</option>
<option style="color:olive" value="olive" class="genmed">'.tra("Olive").'</option>
<option style="color:cyan" value="cyan" class="genmed">'.tra("Cyan").'</option>
<option style="color:blue" value="blue" class="genmed">'.tra("Blue").'</option>
<option style="color:darkblue" value="darkblue" class="genmed">'.tra("Dark Blue").'</option>
<option style="color:indigo" value="indigo" class="genmed">'.tra("Indigo").'</option>
<option style="color:violet" value="violet" class="genmed">'.tra("Violet").'</option>
</select>
&nbsp;'.tra("Font size").':
<select style="color:#000;" name="addbbcode24" onChange="bbfontstyle(\'[size=\' + this.form.addbbcode24.options[this.form.addbbcode24.selectedIndex].value + \']\', \'[/size]\');this.selectedIndex=0;" title="'.tra("Font size: [size=x-small]small text[/size]").'" >
<option value="12" selected class="genmed">'.tra("Default").'</option>
<option value="9" class="genmed">'.tra("Small").'</option>
<option value="12" class="genmed">'.tra("Normal").'</option>
<option value="18" class="genmed">'.tra("Large").'</option>
</select>
&nbsp;
<a href="javascript:bbstyle(-1)" title='.tra("Close all open bbCode tags").'>'.tra("Close Tags").'</a>
</td>
</tr>
<p>
<input type="button" class="btn btn-default btn-sm" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; " onClick="bbstyle(0)" title="'.tra("Bold text: [b]text[/b] (alt+b)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; " onClick="bbstyle(2)" title="'.tra("Italic text: [i]text[/i] (alt+i)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; " onClick="bbstyle(4)" title="'.tra("Underline text: [u]text[/u] (alt+u)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="k" name="addbbcode20" value=" k " style="text-decoration: line-through; " onClick="bbstyle(20)" title="'.tra("Strikethrough text: [s]text[/s] (alt+k)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="q" name="addbbcode6" value="Quote" onClick="bbstyle(6)" title="'.tra("Quote text: [quote]text[/quote] (alt+q)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="c" name="addbbcode8" value="Code" style="" onClick="bbstyle(8)" title="'.tra("Code display: [code]code[/code] (alt+c)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="l" name="addbbcode10" value="List" style="" onClick="bbstyle(10)" title="'.tra("List: [list]text[/list] (alt+l)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="o" name="addbbcode12" value="List=1" style="" onClick="bbstyle(12)" title="'.tra("Ordered list: [list=1]text[/list] (alt+o)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="p" name="addbbcode14" value="Img" style="" onClick="bbstyle(14)" title="'.tra("Insert image: [img]http://image_url[/img] (alt+p)").'" />
<input type="button" class="btn btn-default btn-sm" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; " onClick="bbstyle(16)" title="'.tra("Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url] (alt+w)").'" />
<p>
&nbsp;'.tra("Font color").':
<select style="color:#000;" name="addbbcode22" onChange="bbfontstyle(\'[color=\' + this.form.addbbcode22.options[this.form.addbbcode22.selectedIndex].value + \']\', \'[/color]\');this.selectedIndex=0;" title="'.tra("Font color: [color=red]text[/color] Tip: you can also use color=#FF0000").'" >
<option style="color:black" value="#000000" class="genmed">'.tra("Default").'</option>
<option style="color:darkred" value="darkred" class="genmed">'.tra("Dark Red").'</option>
<option style="color:red" value="red" class="genmed">'.tra("Red").'</option>
<option style="color:orange" value="orange" class="genmed">'.tra("Orange").'</option>
<option style="color:brown" value="brown" class="genmed">'.tra("Brown").'</option>
<option style="color:yellow" value="yellow" class="genmed">'.tra("Yellow").'</option>
<option style="color:green" value="green" class="genmed">'.tra("Green").'</option>
<option style="color:olive" value="olive" class="genmed">'.tra("Olive").'</option>
<option style="color:cyan" value="cyan" class="genmed">'.tra("Cyan").'</option>
<option style="color:blue" value="blue" class="genmed">'.tra("Blue").'</option>
<option style="color:darkblue" value="darkblue" class="genmed">'.tra("Dark Blue").'</option>
<option style="color:indigo" value="indigo" class="genmed">'.tra("Indigo").'</option>
<option style="color:violet" value="violet" class="genmed">'.tra("Violet").'</option>
</select>
&nbsp;'.tra("Font size").':
<select style="color:#000;" name="addbbcode24" onChange="bbfontstyle(\'[size=\' + this.form.addbbcode24.options[this.form.addbbcode24.selectedIndex].value + \']\', \'[/size]\');this.selectedIndex=0;" title="'.tra("Font size: [size=x-small]small text[/size]").'" >
<option value="12" selected class="genmed">'.tra("Default").'</option>
<option value="9" class="genmed">'.tra("Small").'</option>
<option value="12" class="genmed">'.tra("Normal").'</option>
<option value="18" class="genmed">'.tra("Large").'</option>
</select>
&nbsp;
<a href="javascript:bbstyle(-1)" title='.tra("Close all open bbCode tags").'>'.tra("Close Tags").'</a>
<p>
';

?>
49 changes: 24 additions & 25 deletions html/inc/forum.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require_once("../inc/news.inc");
require_once("../inc/text_transform.inc");

define('THREADS_PER_PAGE', 50);
define('FORUM_LH_PCT', '25%'); // width of LH column

$forum_error = "";
// for functions that return null on error,
Expand Down Expand Up @@ -59,8 +60,10 @@ define('AVATAR_HEIGHT',100);
define('ST_NEW_TIME', 1209600); //3600*24*14 - 14 days
define('ST_NEW', 'New member');

define('MAXIMUM_EDIT_TIME',3600);
// allow edits of forums posts up till one hour after posting.
if (!defined('MAXIMUM_EDIT_TIME')) {
define('MAXIMUM_EDIT_TIME', 3600);
// allow edits of forums posts up till one hour after posting.
}

define('MAX_FORUM_LOGGING_TIME', 2419200); //3600*24*28 - 28 days
define('NO_CONTROLS', 0);
Expand Down Expand Up @@ -192,11 +195,11 @@ function forum_title($category, $forum, $thread, $link_thread=false) {
$forum->title
);
} else if ($forum && $thread) {
$x .= sprintf('<a href="%s">%s</a> :',
$x .= sprintf('<a href="%s">%s</a> : ',
$top_url,
$where
);
$x .= sprintf('<a href="forum_forum.php?id=%d">%s</a> :',
$x .= sprintf('<a href="forum_forum.php?id=%d">%s</a> : ',
$forum->id,
$forum->title
);
Expand Down Expand Up @@ -781,30 +784,29 @@ function show_post_and_context($post, $thread, $forum, $options, $n) {
} else {
$deleted = "";
}
echo "
<tr>
<td>
$n)
";
switch ($forum->parent_type) {
case 0:
$category = BoincCategory::lookup_id($forum->category);
echo forum_title($category, $forum, $thread, true);
$title= forum_title($category, $forum, $thread, true);
break;
case 1:
echo team_forum_title($forum);
$title= team_forum_title($forum);
break;
}
echo "
(<a href=\"forum_thread.php?id=".$thread->id."&amp;postid=".$post->id."\">".tra("Message %1", $post->id)."</a>)
<br>
".tra("Posted %1 by %2", $when, user_links($user))." $deleted
<br>
Post:
<hr>
row_array([
sprintf(
'%d) %s
<br><a href="forum_thread.php?id=%d&amp;postid=%d">%s</a>
<br>%s%s
',
$n, $title,
$thread->id, $post->id,
tra("Message %1", $post->id),
tra("Posted %1 by %2", $when, user_links($user)),
$deleted
),
$content
</td></tr>
";
]);
}

function is_banished($user) {
Expand Down Expand Up @@ -858,9 +860,7 @@ function post_rules() {
}

function post_warning($forum=null) {
$x = "<br><br>
<table><tr><td align=left>
";
$x = '<p><div style="text-align:left">';

// let projects add extra instructions in specific forums,
// e.g. Questions and Problems
Expand All @@ -873,7 +873,7 @@ function post_warning($forum=null) {
<small>
".post_rules()."
</small>
</td></tr></table>
</div>
";
return $x;
}
Expand Down Expand Up @@ -1005,7 +1005,6 @@ function create_thread($title, $content, $user, $forum, $signature, $export) {
create_post($content, 0, $user, $forum, $thread, $signature);
$forum->update("threads=threads+1");
notify_forum_subscribers($forum, $user);
exit;
return $thread;
}

Expand Down
75 changes: 43 additions & 32 deletions html/inc/pm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ require_once("boinc_db.inc");
require_once("sanitize_html.inc");
require_once("bbcode_html.inc");

define('PM_LH_PCT', '30%');

function pm_header() {
echo "<div>\n";
echo " <a href=\"pm.php?action=inbox\">".tra("Inbox")."</a>\n";
Expand All @@ -29,7 +31,7 @@ function pm_header() {

function pm_rules() {
if (defined('PM_RULES')) return PM_RULES;
$x = "<table><tr><td align=left><small>";
$x = '<span style="text-align: left"><p>';
$x .= tra("
<ul>
<li> Messages may not contain content that is obscene, hate-related,
Expand All @@ -45,7 +47,7 @@ function pm_rules() {
<li> If your account is suspended, don't create a new one.
</ul>
");
$x .= "</small></td></tr></table>\n";
$x .= "</span>";
return $x;
}

Expand Down Expand Up @@ -82,25 +84,25 @@ function pm_team_form($user, $teamid, $error=null) {
row2(
tra("Subject"),
"<input type=\"text\" class=\"form-control\" name=\"subject\" value=\"$subject\">",
null, '20%'
null, PM_LH_PCT
);
row2_init(tra("Message")."<small>".bbcode_info()."</small>", '20%');
start_table();
echo $bbcode_html;
echo "<tr><td>\n";
echo "<textarea name=\"content\" class=\"form-control\" rows=\"18\">$content</textarea>";
echo "</td></tr>\n";
end_table();
echo sprintf(
'<tr><td></td><td>
<input class="btn" %s type="submit" name="preview" value="%s">
<input class="btn" %s type="submit" value="%s">
</td></tr>
',
button_style('blue'),
tra("Preview"),
button_style(),
tra("Send message")
row2(
tra("Message")."<small>".bbcode_info()."</small>",
$bbcode_html."<textarea name=\"content\" class=\"form-control\" rows=\"18\">$content</textarea>",
null, PM_LH_PCT
);
row2(
'',
sprintf(
'<input class="btn" %s type="submit" name="preview" value="%s">
<input class="btn" %s type="submit" value="%s">
',
button_style('blue'),
tra("Preview"),
button_style(),
tra("Send message")
),
null, PM_LH_PCT
);
end_table();
page_tail();
Expand Down Expand Up @@ -174,24 +176,33 @@ function pm_form_page($replyto, $userid, $error = null) {
'<textarea rows=2 class="form-control" name="to">%s</textarea>',
$writeto
),
null, '20%'
null, PM_LH_PCT
);
row2(
tra("Subject"),
"<input type=\"text\" class=\"form-control\" name=\"subject\" value=\"$subject\">",
null, '20%'
"<input type=\"text\" class=\"form-control\" name=\"subject\" value=\"$subject\">",
null, PM_LH_PCT
);
row2_init(
row2(
tra("Message")."<small>".bbcode_info().pm_rules()."</small>",
'20%'
sprintf(
'%s <textarea name="content" class="form-control" rows="18">%s</textarea>',
$bbcode_html,
$content
),
null, PM_LH_PCT
);
row2(
'',
sprintf(
'<input class="btn btn-primary" type="submit" name="preview" value="%s">
<input class="btn btn-success" type="submit" value="%s">
',
tra("Preview"),
tra("Send message")
),
null, PM_LH_PCT
);
start_table();
echo $bbcode_html;
echo "<tr><td>\n";
echo "<textarea name=\"content\" class=\"form-control\" rows=\"18\">$content</textarea>";
echo "</td></tr>\n";
end_table();
echo "<tr><td></td><td><input class=\"btn btn-primary\" type=\"submit\" name=\"preview\" value=\"".tra("Preview")."\"> <input class=\"btn btn-success\" type=\"submit\" value=\"".tra("Send message")."\"></td></tr>\n";
end_table();

page_tail();
Expand Down
17 changes: 7 additions & 10 deletions html/inc/text_transform.inc
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ function externalize_links($text) {
$linkpos=true;
$out = "";
while (true){
//Find a link
// Find a link
//
$linkpos=strpos($text, "<a ", $i);
if ($linkpos===false) break;

//Replace with target='_new'
// Replace with target='_new'
//
$out .= substr($text, $i, $linkpos-$i)."<a target=\"_new\" ";
$i = $linkpos+3;
Expand All @@ -311,18 +311,15 @@ function externalize_links($text) {
}

// Converts image tags to links to the images.

//
function image_as_link($text){
/* This function depends on sanitized HTML */
// Build some regex (should be a *lot* faster)
$pattern = '@<img([\S\s]+?)src=([^>]+?)>@si';
$replacement = '<a href=${2}>[Image link]</a>'; // Turns that URL into a hyperlink
$text = preg_replace($pattern, $replacement, $text);
return $text;
$replacement = '<a href=${2}>[Image link]</a>';
return preg_replace($pattern, $replacement, $text);
}

// Highlight terms in text (most likely used with searches)

// Highlight terms in text (used in search results)
//
function highlight_terms($text, $terms) {
$search = $terms;
$replace = array();
Expand Down
Loading

0 comments on commit d238eae

Please sign in to comment.