1<?php
2
3  require_once(realpath(dirname(__FILE__)).'/../../../inc/init.php');
4  if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
5  if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
6  require_once(DOKU_PLUGIN.'syntax.php');
7
8// POST Sent by the edited array
9//    * &row=n: The row index of the edited cell
10//    * &cell=n: The cell index of the edited cell
11//    * &id=id: The id attribute of the row, it may be useful to set this to the record ID you are editing
12//    * &field=field: The id attribute of the header cell of the column of the edited cell, it may be useful to set this to the field name you are editing
13//    * &value=xxxxxx: The rest of the POST body is the serialised form. The default name of the field is 'value'.
14
15
16/******************************************************************************/
17/* send an e-mail to user due to issue modificaion
18*/
19    function _emailForIssueMod($currentID, $project, $issue, $old_value, $column, $new_value, $usr)
20    {
21//        if ($conf['plugin']['issuetracker']['userinfo_email']==1)
22        {   global $ID;
23            global $lang;
24            global $conf;
25            if($new_value == '') $new_value = $lang['it__none'];
26            if($old_value == '') $old_value = $lang['it__none'];
27
28            if ($conf['plugin']['issuetracker']['mail_templates']==1) {
29                // load user html mail template
30                $sFilename = DOKU_PLUGIN.'issuetracker/mailtemplate/edit_issuemod_mail.html';
31                $bodyhtml = file_get_contents($sFilename);
32                $comment = array();
33                $comment["field"] = $column;
34                $comment["old_value"] = $old_value;
35                $comment["new_value"] = $new_value;
36                $comment["timestamp"] = date('Y-m-d G:i:s');
37                $comment["author"] = $user_mail['userinfo']['mail'];
38            }
39            //issuemod_subject = 'Issue #%s on %s: %s';
40            $subject = sprintf($lang['issuemod_subject'], $issue['id'], $project, $lang['th_'.$column]);
41            $subject = mb_encode_mimeheader($subject, "UTF-8", "Q" );
42            $pstring = sprintf("showid=%s&project=%s", urlencode($issue['id']), urlencode($project));
43            //issuemod_changes = The issue changed on %s from %s to %s.
44            $changes = sprintf($lang['issuemod_changes'],$lang['th_'.$column], $old_value, $new_value);
45
46            $body = chr(10).$lang['issuemod_head'].chr(10).chr(10).
47                    $lang['issuemod_intro'].chr(10).
48                    $changes.chr(10).chr(10).
49                    $lang['issuemod_title'].$issue['title'].chr(10).
50                    $lang['issuemod_issueid'].$issue['id'].chr(10).
51                    $lang['issuemod_product'].$issue['product'].chr(10).
52                    $lang['issuemod_version'].$issue['version'].chr(10).
53                    $lang['issuemod_severity'].$issue['severity'].chr(10).
54                    $lang['issuemod_status'].$issue['status'].chr(10).
55                    $lang['issuemod_creator'].$issue['user_name'].chr(10).
56                    $lang['th_assigned'].': '.$issue['assigned'].chr(10).
57                    $lang['issuenew_descr'].$issue['description'].chr(10).
58                    $lang['issuemod_see'].DOKU_URL.'doku.php?id='.$currentID.'&do=showcaselink&'.$pstring.chr(10).chr(10).
59                    $lang['issuemod_br'].chr(10).$lang['issuemod_end'];
60
61
62                $body = html_entity_decode($body);
63                $from = $conf['plugin']['issuetracker']['email_address'];
64                $to   = $issue['user_mail'];
65                $cc   = $issue['add_user_mail'];
66
67            if ($conf['plugin']['issuetracker']['mail_templates']==1) {
68                $bodyhtml = replace_bodyhtml($currentID, $bodyhtml, $pstring, $project, $issue, $comment, $usr);
69              $headers .= "Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable";
70              mail_send_html($to, $subject, $body, $bodyhtml, $from, $cc, $bcc='', $headers, $params=null);
71            }
72            else {
73              mail_send($to, $subject, $body, $from, $cc, $bcc='', $headers=null, $params=null);
74            }
75        }
76    }
77/******************************************************************************/
78/* send an e-mail to assignee about routed service request
79*/
80    function _emailToAssigneeMod($currentID, $project, $issue, $value, $usr)
81    {       global $lang;
82            global $conf;
83            if ($conf['plugin']['issuetracker']['mail_templates']==1) {
84                // load user html mail template
85                $sFilename = DOKU_PLUGIN.'issuetracker/mailtemplate/assignee_mail.html';
86                $bodyhtml = file_get_contents($sFilename);
87                $comment = array();
88                $comment["timestamp"] = date('Y-m-d G:i:s');
89                $comment["author"] = $user_mail['userinfo']['mail'];
90            }
91            $subject = sprintf($lang['issueassigned_subject'], $issue['id'], $project);
92            $subject = mb_encode_mimeheader($subject, "UTF-8", "Q" );
93            $pstring = sprintf("showid=%s&project=%s", urlencode($issue['id']), urlencode($project));
94
95            $body = chr(10).$lang['issueassigned_head'].chr(10).chr(10).
96                    $lang['issueassigned_intro'].chr(10).
97                    $lang['issuemod_title'].$issue['title'].chr(10).
98                    $lang['issuemod_issueid'].$issue['id'].chr(10).
99                    $lang['issuemod_product'].$issue['product'].chr(10).
100                    $lang['issuemod_version'].$issue['version'].chr(10).
101                    $lang['issuemod_severity'].$issue['severity'].chr(10).
102                    $lang['issuemod_status'].$issue['status'].chr(10).
103                    $lang['issuemod_creator'].$issue['user_name'].chr(10).
104                    $lang['th_assigned'].$issue['assigned'].chr(10).
105                    $lang['issuenew_descr'].$issue['description'].chr(10).
106                    $lang['issuemod_see'].DOKU_URL.'doku.php?id='.$currentID.'&do=showcaselink&'.$pstring.chr(10).chr(10).
107                    $lang['issuemod_br'].chr(10).$lang['issuemod_end'];
108
109            $body = html_entity_decode($body);
110            if ($conf['plugin']['issuetracker']['mail_templates']==1) $bodyhtml = replace_bodyhtml($currentID, $bodyhtml, $pstring, $project, $issue, $comment, $usr);
111
112            $from = $conf['plugin']['issuetracker']['email_address'];
113            $to   = $value;
114
115            if ($conf['plugin']['issuetracker']['mail_templates']==1) {
116              $bodyhtml = replace_bodyhtml($currentID, $bodyhtml, $pstring, $project, $issue, $comment, $usr);
117              $headers .= "Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable";
118              mail_send_html($to, $subject, $body, $bodyhtml, $from, $cc, $bcc='', $headers, $params=null);
119            }
120            else {
121              mail_send($to, $subject, $body, $from, $cc='', $bcc='', $headers=null, $params=null);
122            }
123    }
124/******************************************************************************
125     * HTML Mail functions
126     *
127     * Sends HTML-formatted mail
128     * By Lin Junjie (mail [dot] junjie [at] gmail [dot] com)
129     *
130******************************************************************************/
131    function mail_send_html($to, $subject, $body, $bodyhtml, $from='', $cc='', $bcc='', $header='', $params=null){
132      if(defined('MAILHEADER_ASCIIONLY')){
133        $subject = utf8_deaccent($subject);
134        $subject = utf8_strip($subject);
135      }
136      if(!defined('MAILHEADER_EOL')) define('MAILHEADER_EOL',"\n");
137      if(!utf8_isASCII($subject)) {
138        $subject = '=?UTF-8?Q?'.mail_quotedprintable_encode($subject,0).'?=';
139        // Spaces must be encoded according to rfc2047. Use the "_" shorthand
140        $subject = preg_replace('/ /', '_', $subject);
141      }
142
143      $header  = '';
144
145      $usenames = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? false : true;
146
147      $random_hash = md5(date('r', time())); // added
148
149      $to = mail_encode_address($to,'',$usenames);
150      $header .= mail_encode_address($from,'From');
151      $header .= mail_encode_address($cc,'Cc');
152      $header .= mail_encode_address($bcc,'Bcc');
153      $header .= 'MIME-Version: 1.0'.MAILHEADER_EOL;
154      $header .= "Content-Type: multipart/alternative; boundary=PHP-alt-".$random_hash.MAILHEADER_EOL;
155      $header  = trim($header);
156
157
158      $body = mail_quotedprintable_encode($body,0);
159      $bodyhtml = mail_quotedprintable_encode($bodyhtml,0);
160
161      $message =	"--PHP-alt-".$random_hash."\r\n".
162    				"Content-Type: text/plain; charset=UTF-8"."\n".
163    				"Content-Transfer-Encoding: quoted-printable"."\n\n".
164    				$body."\n\n".
165    				"--PHP-alt-".$random_hash."\r\n".
166    				"Content-Type: text/html; charset=UTF-8"."\n".
167    				"Content-Transfer-Encoding: quoted-printable"."\n\n".
168    				$bodyhtml."\n".
169    				"--PHP-alt-".$random_hash."--";
170
171      if($params == null){
172        return @mail($to,$subject,$message,$header);
173      }else{
174        return @mail($to,$subject,$message,$header,$params);
175      }
176    }
177
178/******************************************************************************/
179    function replace_bodyhtml($currentID, $bodyhtml, $pstring, $project, $issue, $comment, $usr) {
180        global $ID;
181        global $lang;
182
183        $bodyhtml = str_ireplace("%%_see%%",DOKU_URL.'doku.php?id='.$currentID.'&do=showcaselink&'.$pstring,$bodyhtml);
184        $bodyhtml = str_ireplace("%%issuemod_head%%",$lang['issuemod_head'],$bodyhtml);
185        $bodyhtml = str_ireplace("%%issuemod_intro%%",$lang['issuemod_intro'],$bodyhtml);
186
187        $bodyhtml = str_ireplace("%%issuemod_issueid%%",$lang['issuemod_issueid'],$bodyhtml);
188        $bodyhtml = str_ireplace("%%ID%%",$issue['id'],$bodyhtml);
189        $bodyhtml = str_ireplace("%%issuemod_title%%",$lang['issuemod_title'],$bodyhtml);
190        $bodyhtml = str_ireplace("%%TITEL%%",$issue['title'],$bodyhtml);
191        $bodyhtml = str_ireplace("%%issuemod_status%%",$lang['issuemod_status'],$bodyhtml);
192        $bodyhtml = str_ireplace("%%status%%",$issue['status'],$bodyhtml);
193        $bodyhtml = str_ireplace("%%th_project%%",$lang['th_project'],$bodyhtml);
194        $bodyhtml = str_ireplace("%%project%%",$project,$bodyhtml);
195        $bodyhtml = str_ireplace("%%issuemod_product%%",$lang['issuemod_product'],$bodyhtml);
196        $bodyhtml = str_ireplace("%%product%%",$issue['product'],$bodyhtml);
197        $bodyhtml = str_ireplace("%%issuemod_version%%",$lang['issuemod_version'],$bodyhtml);
198        $bodyhtml = str_ireplace("%%version%%",$issue['version'],$bodyhtml);
199        $bodyhtml = str_ireplace("%%issuemod_severity%%",$lang['issuemod_severity'],$bodyhtml);
200        $bodyhtml = str_ireplace("%%severity%%",$issue['severity'],$bodyhtml);
201        $bodyhtml = str_ireplace("%%issuemod_creator%%",$lang['issuemod_creator'],$bodyhtml);
202        $bodyhtml = str_ireplace("%%creator%%",$issue['user_name'],$bodyhtml);
203        $bodyhtml = str_ireplace("%%CREATOR_MAIL%%",$issue['user_mail'],$bodyhtml);
204        $bodyhtml = str_ireplace("%%th_assigned%%",$lang['th_assigned'],$bodyhtml);
205        $bodyhtml = str_ireplace("%%assigned%%",$issue['assigned'],$bodyhtml);
206        $bodyhtml = str_ireplace("%%th_created%%",$lang['th_created'],$bodyhtml);
207        $bodyhtml = str_ireplace("%%created%%",$issue['created'],$bodyhtml);
208        $bodyhtml = str_ireplace("%%issueassigned_head%%",$lang['issueassigned_head'],$bodyhtml);
209        $bodyhtml = str_ireplace("%%issueassigned_intro%%",$lang['issueassigned_intro'],$bodyhtml);
210
211        $bodyhtml = str_ireplace("%%issue_resolved_intro%%",$lang['issue_resolved_intro'],$bodyhtml);
212        $bodyhtml = str_ireplace("%%issue_resolved_text%%",$lang['issue_resolved_text'],$bodyhtml);
213        $frmt_res = str_ireplace(chr(10),"<br />",$issue['resolution']);
214        $bodyhtml = str_ireplace("%%resolution%%",xs_format($frmt_res),$bodyhtml);
215        $bodyhtml = str_ireplace("%%timestamp%%",date($conf['plugin']['issuetracker']['d_format']),$bodyhtml);
216
217        $bodyhtml = str_ireplace("%%resolver%%",$usr,$bodyhtml);
218        $bodyhtml = str_ireplace("%%mod_by%%",$usr,$bodyhtml);
219        $bodyhtml = str_ireplace("%%issuedescrmod_subject%%",sprintf($lang['issuedescrmod_subject'],$issue['id'], $project),$bodyhtml);
220        $bodyhtml = str_ireplace("%%th_description%%",$lang['th_description'],$bodyhtml);
221        $frmt_descr = str_ireplace(chr(10),"<br />",$issue['description']);
222        $bodyhtml = str_ireplace("%%description%%",xs_format($frmt_descr),$bodyhtml);
223
224
225//        if($comment) {
226            $bodyhtml = str_ireplace("%%lbl_cmts_wlog%%",$lang['lbl_cmts_wlog'],$bodyhtml);
227            $bodyhtml = str_ireplace("%%cmnt_id%%",$comment['id'],$bodyhtml);
228            $bodyhtml = str_ireplace("%%edit_author%%",$comment['author'],$bodyhtml);
229            $bodyhtml = str_ireplace("%%cmnt_timestamp%%",date($conf['plugin']['issuetracker']['d_format'],strtotime($comment['timestamp'])),$bodyhtml);
230            $frmt_cmnt = str_ireplace(chr(10),"<br />",$comment['comment']);
231            $bodyhtml = str_ireplace("%%comment%%",xs_format($frmt_cmnt),$bodyhtml);
232            $bodyhtml = str_ireplace("%%field%%",str_ireplace(chr(10),"<br />",$comment["field"]),$bodyhtml);
233            $bodyhtml = str_ireplace("%%old_value%%",xs_format(str_ireplace(chr(10),"<br />",$comment["old_value"])),$bodyhtml);
234            $bodyhtml = str_ireplace("%%new_value%%",xs_format(str_ireplace(chr(10),"<br />",$comment["new_value"])),$bodyhtml);
235//        }
236        $bodyhtml = str_ireplace("%%issuemod_br%%",$lang['issuemod_br'],$bodyhtml);
237        $bodyhtml = str_ireplace("%%issuemod_end%%",$lang['issuemod_end'],$bodyhtml);
238
239        return $bodyhtml;
240    }
241/******************************************************************************/
242/* replace simple formats used by editor buttons
243*/
244    function xs_format($x_comment)
245    { // bold , italic, underline, etc.
246        $x_comment = preg_replace('/\[([bius])\]/i', '<\\1>', $x_comment);
247        $x_comment = preg_replace('/\[\/([bius])\]/i', '</\\1>', $x_comment);
248
249        $x_comment = preg_replace('/\[ol\]/i', '<ol>', $x_comment);
250        $x_comment = preg_replace('/\[\/ol\]/i', '</ol>', $x_comment);
251
252        $x_comment = preg_replace('/\[ul\]/i', '<ul>', $x_comment);
253        $x_comment = preg_replace('/\[\/ul\]/i', '</ul>', $x_comment);
254
255        $x_comment = preg_replace('/\[li\]/i', '<li>', $x_comment);
256        $x_comment = preg_replace('/\[\/li\]/i', '</li>', $x_comment);
257
258        $x_comment = preg_replace('/\[sup\]/i', '<sup>', $x_comment);
259        $x_comment = preg_replace('/\[\/sup\]/i', '</sup>', $x_comment);
260
261        $x_comment = preg_replace('/\[sub\]/i', '<sub>', $x_comment);
262        $x_comment = preg_replace('/\[\/sub\]/i', '</sub>', $x_comment);
263
264        $x_comment = preg_replace('/\[hr\]/i', '<hr>', $x_comment);
265
266        $x_comment = preg_replace('/\[blockquote\]/i', '<blockquote>', $x_comment);
267        $x_comment = preg_replace('/\[\/blockquote\]/i', '</blockquote>', $x_comment);
268
269        $x_comment = preg_replace('/\[code\]/i', '<code>', $x_comment);
270        $x_comment = preg_replace('/\[\/code\]/i', '</code>', $x_comment);
271
272        $x_comment = preg_replace('/\[red\]/i', '<span style="color:red;">', $x_comment);
273        $x_comment = preg_replace('/\[\/red\]/i', '</span>', $x_comment);
274
275        $x_comment = preg_replace('/\[grn\]/i', '<span style="color:green;">', $x_comment);
276        $x_comment = preg_replace('/\[\/grn\]/i', '</span>', $x_comment);
277
278        $x_comment = preg_replace('/\[bgy\]/i', '<span style="background:yellow;">', $x_comment);
279        $x_comment = preg_replace('/\[\/bgy\]/i', '</span>', $x_comment);
280
281        $x_comment = preg_replace('/\[blu\]/i', '<span style="color:blue;">', $x_comment);
282        $x_comment = preg_replace('/\[\/blu\]/i', '</span>', $x_comment);
283
284        $urlsuch[]="/([^]_a-z0-9-=\"'\/])((https?|ftp):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si";
285        $urlsuch[]="/^((https?|ftp):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si";
286        $urlreplace[]="\\1[link]\\2\\4[/link]";
287        $urlreplace[]="[link]\\1\\3[/link]";
288        $x_comment = preg_replace($urlsuch, $urlreplace, $x_comment);
289        $x_comment = preg_replace("/\[link\]www.(.*?)\[\/link\]/si", "<a target=\"_blank\" href=\"http://www.\\1\">www.\\1</a>", $x_comment);
290        $x_comment = preg_replace("/\[link=www.(.*?)\](.*?)\[\/link\]/si", "<a target=\"_blank\" href=\"http://www.\\1\">\\2</a>", $x_comment);
291        $x_comment = preg_replace("/\[link\](\:.*?)\[\/link\]/si", "<a target=\"_blank\" href=\"doku.php?id=\\1\">\\1</a>", $x_comment);
292        $x_comment = preg_replace("/\[link=(\:.*?)\]\[\/link\]/si", "<a target=\"_blank\" href=\"doku.php?id=\\1\">\\1</a>", $x_comment);
293        $x_comment = preg_replace("/\[link=(\:.*?)\](.*?)\[\/link\]/si", "<a target=\"_blank\" href=\"doku.php?id=\\1\">\\2</a>", $x_comment);
294        $x_comment = preg_replace("/\[link\](.*?)\[\/link\]/si", "<a target=\"_blank\" href=\"\\1\">\\1</a>", $x_comment);
295        $x_comment = preg_replace("/\[link=(.*?)\](.*?)\[\/link\]/si", "<a target=\"_blank\" href=\"\\1\">\\2</a>", $x_comment);
296
297        $x_comment = preg_replace("/\[img\](http.*?)\[\/img\]/si", "<img src=\"\\1\"title=\"\\1\" alt=\"\\1\" style=\"max-width:850px;\" \/>", $x_comment);
298        $x_comment = preg_replace("/\[img=(http.*?)\](.*?)\[\/img\]/si", "<img src=\"\\1\" title=\"\\2\" alt=\"\\1\" style=\"max-width:850px;\" \/>", $x_comment);
299        $x_comment = preg_replace("/\[img\](file.*?)\[\/img\]/si", "<img src=\"\\1\" title=\"\\1\" alt=\"\\1\" style=\"max-width:850px;\" \/>", $x_comment);
300        $x_comment = preg_replace("/\[img=(file.*?)\](.*?)\[\/img\]/si", "<img src=\"\\1\" title=\"\\2\" alt=\"\\1\" style=\"max-width:850px;\" \/>", $x_comment);
301        $x_comment = preg_replace("/\[img\](\:.*?)\[\/img\]/si", "<img src=\"". DOKU_URL . "lib/exe/fetch.php?media=\\1\" title=\"\\1\" alt=\"\\1\" style=\"max-width:850px;\" \/>", $x_comment);
302        $x_comment = preg_replace("/\[img=(\:.*?)\](.*?)\[\/img\]/si", "<img src=\"". DOKU_URL . "lib/exe/fetch.php?media=\\1\" title=\"\\2\" alt=\"\\1\" style=\"max-width:850px;\" \/>", $x_comment);
303        $x_comment = preg_replace("/\[img\](.*?)\[\/img\]/si", "<img src=\"\\1\" title=\"\\1\" style=\"max-width:850px;\" \/>", $x_comment);
304        $x_comment = preg_replace("/\[img=(.*?)\](.*?)\[\/img\]/si", "<img src=\"\\1\" title=\"\\2\" style=\"max-width:850px;\" \/>", $x_comment);
305
306
307/*---------------------------------------------------------------------------------
308*  think about parsing content by dokuwiki renderer for dokuwiki syntax recognition
309*        $x_comment = p_render('xhtml',p_get_instructions($x_comment),$info);
310*        take care to strip IssueTracker syntax to prevent endless loop
311---------------------------------------------------------------------------------*/
312
313      return $x_comment;
314    }
315/******************************************************************************/
316/* log issue modificaions
317 * who changed what and when per issue
318*/
319    function _log_mods($project, $issue, $usr, $column, $old_value, $new_value)
320    {     global $conf;
321          // get mod-log file contents
322          if($conf['plugin']['issuetracker']['it_data']==false) $modfile = DOKU_CONF."../data/meta/".$project.'_'.$issue['id'].'.mod-log';
323          else $modfile = DOKU_CONF."../". $conf['plugin']['issuetracker']['it_data'].$project.'_'.$issue['id'].'.mod-log';
324          if (@file_exists($modfile))
325              {$mods  = unserialize(@file_get_contents($modfile));}
326          else
327              {$mods = array();}
328
329          $cur_date = date('Y-m-d G:i:s');
330          $mod_id = count($mods);
331          if($new_value=='') $new_value = '[deleted]';
332          $mods[$mod_id]['timestamp']   = $cur_date;
333          $mods[$mod_id]['user']        = $usr;
334          $mods[$mod_id]['field']       = $column;
335          $mods[$mod_id]['old_value']   = $old_value;
336          $mods[$mod_id]['new_value']   = $new_value;
337
338          // Save issues file contents
339          $fh = fopen($modfile, 'w');
340          fwrite($fh, serialize($mods));
341          fclose($fh);
342    }
343/******************************************************************************/
344    global $ID;
345    global $lang;
346    global $conf;
347
348    // Include the language file
349    if ($conf['lang']=='') $conf['lang']=='en';
350    if ($conf['lang']!=='') {
351        $path = DOKU_PLUGIN.'issuetracker/lang/';
352        // don't include once, in case several plugin components require the same language file
353        @include($path.'en/lang.php');
354        if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php');
355    }
356
357    $exploded  = explode(' ',htmlspecialchars(stripslashes($_POST['id'])));
358    $project   = $exploded[0];
359    $id_issue  = intval($exploded[1]);
360    $usr       = $_POST['usr'];
361    $currentID = $_POST['currentID'];
362    $cur_date  = date('Y-m-d G:i:s');
363
364    // get issues file contents
365    if($conf['plugin']['issuetracker']['it_data']==false) $pfile = DOKU_CONF."../data/meta/".$project.'.issues';
366    else $pfile = DOKU_CONF."../". $conf['plugin']['issuetracker']['it_data'].$project.'.issues';
367    if (@file_exists($pfile))
368        {$issues  = unserialize(@file_get_contents($pfile));}
369    else
370        {$issues = array();}
371
372    $field = strtolower(htmlspecialchars(stripslashes($_POST['field'])));
373    $value = htmlspecialchars(stripslashes($_POST['value']));
374
375    if(($field == 'resolution') && ($value !== false)) {
376      $issues[$id_issue]['status'] = $lang['issue_resolved_status'];
377    }
378
379      $old_value = $issues[$id_issue][$field];
380      $issues[$id_issue][$field] = $value;
381      $issues[$id_issue]['modified'] = $cur_date;
382      _log_mods($project, $issues[$id_issue], $usr, $field, $old_value, $value);
383   // notification mails as long as status is not deleted
384    if($conf['status_special']=='') $conf['status_special']='Deleted';
385    if (stripos($conf['status_special'],$value) === false) {
386      _emailForIssueMod($currentID, $project, $issues[$id_issue], $old_value, $field, $value, $usr);
387    }
388        // inform assigned workforce for new issue
389    if ($field == 'assigned') {
390        $issues[$id_issue]['assigned'] = $value;
391        $status = explode(',', $conf['plugin']['issuetracker']['status']);
392        // No custom configuration in the event $conf does not contain issuetracker status field
393        // not the best idea to fall back to hard coded defaults but fast implemented
394        if($status[0]=='') $status[0]='New';
395        if($status[1]=='') $status[1]='Assigned';
396
397        if($issues[$id_issue]['assigned']=='')
398        { // assignment deleted => set status to first config value
399          $issues[$id_issue]['status'] = $status[0];
400        }
401        else $issues[$id_issue]['status'] = $status[1];
402
403        _emailToAssigneeMod($currentID, $project, $issues[$id_issue], $value, $usr);
404    }
405    // Save issues file contents
406    $fh = fopen($pfile, 'w');
407    fwrite($fh, serialize($issues));
408    fclose($fh);
409    echo $value;
410?>
411
412