4 Allows users to submit a bug report, automatically creates a new bug
5 page and adds a link to the current page (BugReports). It is used in
6 conjuntion with BugReportState on the ErfurtWiki: demo site.
10 $ewiki_plugins["mpi"]["bugreport"] = "ewiki_mpi_bugreport";
15 function ewiki_mpi_bugreport($action, $args, &$iii, &$s)
18 $MAIN = $ewiki_id; //"BugReports";
19 ($ELSE = $args[0]) or ($ELSE = rtrim($MAIN,"s"));
22 if ($_REQUEST["br_save"]) {
25 $content = $_REQUEST["content"];
26 $title = $_REQUEST["title"];
27 $author = $_REQUEST["author"];
28 if (strlen($content) < 50) {
29 return("<p><b>Insufficient information for a useful BugReport.</b></p>");
31 if (strstr($title,"???")) {
32 $title = substr($content, 0, 50);
35 #-- make page name for bug report
36 $new_id = ewiki_title_to_pagename($title, $ELSE);
39 #-- generate bug page text
40 $new = "This page is part of the $MAIN series. Please go there to submit a new bug or to see the list of all existing reports.\n";
41 if ($m=$_REQUEST["br_notify"]) {
42 $new .= "\n[notify:$m]\n";
46 foreach ($_REQUEST["i"] as $i=>$v) {
47 if ($v != "unknown") {
48 $new .= "| $i | $v |\n";
51 $new .= "| status | __open__ |\n <?plugin BugReportState ?"."> \n";
52 $new .= "\n$author: $content\n\n";
54 #-- create new bug report page
55 $data = ewiki_db::CREATE($new_id);
56 $data["content"] = $new;
57 ewiki_db::UPDATE($data);
59 $ok = ewiki_db::WRITE($data);
61 return("<b>Error</b> while creating new bug report page. Please go back and change the title (at least two words required), so we can try again.");
64 #-- store bugreport entry on main page
65 $data = ewiki_db::GET($MAIN);
66 $list_e = "| __open__ | $new_id | $title |\n";
67 $data["content"] = preg_replace("/(\n\|.+\|.+\|\s*\n)/", "$1$list_e", $data["content"], 1);
68 ewiki_db::UPDATE($data);
70 ewiki_db::WRITE($data);
71 if ($notify=function_exists($pf="ewiki_notify_edit_hook")) {
72 $pf($MAIN, $data, $uu);
75 #-- append to page output
77 "\n\n| new bug report [#added \"added\"] as $new_id |\n\n",
85 $url = ewiki_script("", $ewiki_id);
87 $current_vers = "<option>$ver";
88 for ($i=$ver[strlen($ver)-1]-1; $i>0; $i--) {
89 $current_vers .= "<option>" . substr($ver, 0, strlen($ver)-1) . $i;
92 <form style="border:2px #444455 solid; background:#9999aa; padding:5px;"class="BugReport" action="$url#added" method="POST" enctype="multipart/form-data">
93 bug title: <input type="text" name="title" value="???" size="50">
96 YourName: <input type="text" name="author" value="anonymous" size="30">
99 your ewiki version: <select name="i[ewiki version]"><option>unknown<option>other{$current_vers}<option>CVS today<option>CVS yesterday<option>CVS last week<option>two weeks old<option>latest -dev<option>R1.02a<option>R1.01f<option>R1.01e<option>R1.01d<option>R1.01c<option>R1.01b<option>R1.01a</select>
100 plattform: <select name="i[operating system]"><option>unknown<option>other<option>Win4<option>NT (2K,XP)<option>Unix<option>Linux<option>OS X</select>
102 database: <select name="i[database backend]"><option>unknown<option>mysql<option>db_flat_files<option>db_fast_files<option>anydb: other<option>anydb: pgsql<option>dzf2<option>dba/dbm<option>phpwiki13<option>zip<option>other<option>own</select>
103 php version: <select name="i[php version]"><option>unknown<option>4.0.x<option>4.1.x<option>4.2.x<option>4.3.x<option>4.4/4.5 (CVS)<option>5.0-beta/rc<option>5.0.x<option>CGI/suPHP<option>PHP/FastCGI<option>SafeMode 4.x</select>
105 problem category (vague): <select name="i[bug category]"><option>unknown<option>general<option>feature request<option>get running<option>markup<option>links<option>error message<option>plugin<option>page plugin<option>action plugin<option>auth plugin<option>aview plugin<option>edit plugin<option>feature extension<option>link tweak plugin<option>mpi plugin<option>spages<option>lib extension<option>module plugin<option>db plugin<option>configuration<option>documentation</select>
108 long error description:<br />
109 <textarea name="content" cols="75" rows="8">
112 <input type="submit" name="br_save" value="create bug page">
115 email notification <input type="text" name="br_notify" value="" size="16">
116 <br/><small>(opt., only enter if you want get notified on any responses)</small>
127 function ewiki_title_to_pagename($title, $else="BugReport") {
129 global $ewiki_config;
131 #-- try to make a wikilink out of the title
132 // $title = strtolower($title);
133 $title = preg_replace("/\b((?!not)[-_\w\d]{1,3})\b/", " ", $title);
134 $title = ucwords($title);
135 $link = preg_replace("/\s+/", "", $title);
137 #-- if we don't get a WikiWord
138 if (!$link || ewiki_db::GET($link)
139 || !preg_match("/^([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}/", $link)) {
142 $link = "$else" . ($n++);
144 while (ewiki_db::GET($link));