",$issue['resolution']);
$bodyhtml = str_ireplace("%%resolution%%",xs_format($frmt_res),$bodyhtml);
$bodyhtml = str_ireplace("%%timestamp%%",date($conf['plugin']['issuetracker']['d_format']),$bodyhtml);
$bodyhtml = str_ireplace("%%resolver%%",$usr,$bodyhtml);
$bodyhtml = str_ireplace("%%mod_by%%",$usr,$bodyhtml);
$bodyhtml = str_ireplace("%%issuedescrmod_subject%%",sprintf($lang['issuedescrmod_subject'],$issue['id'], $project),$bodyhtml);
$bodyhtml = str_ireplace("%%th_description%%",$lang['th_description'],$bodyhtml);
$frmt_descr = str_ireplace(chr(10),"
",$issue['description']);
$bodyhtml = str_ireplace("%%description%%",xs_format($frmt_descr),$bodyhtml);
// if($comment) {
$bodyhtml = str_ireplace("%%lbl_cmts_wlog%%",$lang['lbl_cmts_wlog'],$bodyhtml);
$bodyhtml = str_ireplace("%%cmnt_id%%",$comment['id'],$bodyhtml);
$bodyhtml = str_ireplace("%%edit_author%%",$comment['author'],$bodyhtml);
$bodyhtml = str_ireplace("%%cmnt_timestamp%%",date($conf['plugin']['issuetracker']['d_format'],strtotime($comment['timestamp'])),$bodyhtml);
$frmt_cmnt = str_ireplace(chr(10),"
",$comment['comment']);
$bodyhtml = str_ireplace("%%comment%%",xs_format($frmt_cmnt),$bodyhtml);
$bodyhtml = str_ireplace("%%field%%",str_ireplace(chr(10),"
",$comment["field"]),$bodyhtml);
$bodyhtml = str_ireplace("%%old_value%%",xs_format(str_ireplace(chr(10),"
",$comment["old_value"])),$bodyhtml);
$bodyhtml = str_ireplace("%%new_value%%",xs_format(str_ireplace(chr(10),"
",$comment["new_value"])),$bodyhtml);
// }
$bodyhtml = str_ireplace("%%issuemod_br%%",$lang['issuemod_br'],$bodyhtml);
$bodyhtml = str_ireplace("%%issuemod_end%%",$lang['issuemod_end'],$bodyhtml);
return $bodyhtml;
}
/******************************************************************************/
/* replace simple formats used by editor buttons
*/
function xs_format($x_comment)
{ // bold , italic, underline, etc.
$x_comment = preg_replace('/\[([bius])\]/i', '<\\1>', $x_comment);
$x_comment = preg_replace('/\[\/([bius])\]/i', '\\1>', $x_comment);
$x_comment = preg_replace('/\[ol\]/i', '
', $x_comment); $x_comment = preg_replace('/\[\/blockquote\]/i', '', $x_comment); $x_comment = preg_replace('/\[code\]/i', '
', $x_comment);
$x_comment = preg_replace('/\[\/code\]/i', '
', $x_comment);
$x_comment = preg_replace('/\[red\]/i', '', $x_comment);
$x_comment = preg_replace('/\[\/red\]/i', '', $x_comment);
$x_comment = preg_replace('/\[grn\]/i', '', $x_comment);
$x_comment = preg_replace('/\[\/grn\]/i', '', $x_comment);
$x_comment = preg_replace('/\[bgy\]/i', '', $x_comment);
$x_comment = preg_replace('/\[\/bgy\]/i', '', $x_comment);
$x_comment = preg_replace('/\[blu\]/i', '', $x_comment);
$x_comment = preg_replace('/\[\/blu\]/i', '', $x_comment);
$urlsuch[]="/([^]_a-z0-9-=\"'\/])((https?|ftp):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si";
$urlsuch[]="/^((https?|ftp):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si";
$urlreplace[]="\\1[link]\\2\\4[/link]";
$urlreplace[]="[link]\\1\\3[/link]";
$x_comment = preg_replace($urlsuch, $urlreplace, $x_comment);
$x_comment = preg_replace("/\[link\]www.(.*?)\[\/link\]/si", "www.\\1", $x_comment);
$x_comment = preg_replace("/\[link=www.(.*?)\](.*?)\[\/link\]/si", "\\2", $x_comment);
$x_comment = preg_replace("/\[link\](\:.*?)\[\/link\]/si", "\\1", $x_comment);
$x_comment = preg_replace("/\[link=(\:.*?)\]\[\/link\]/si", "\\1", $x_comment);
$x_comment = preg_replace("/\[link=(\:.*?)\](.*?)\[\/link\]/si", "\\2", $x_comment);
$x_comment = preg_replace("/\[link\](.*?)\[\/link\]/si", "\\1", $x_comment);
$x_comment = preg_replace("/\[link=(.*?)\](.*?)\[\/link\]/si", "\\2", $x_comment);
$x_comment = preg_replace("/\[img\](http.*?)\[\/img\]/si", "", $x_comment);
$x_comment = preg_replace("/\[img=(http.*?)\](.*?)\[\/img\]/si", "", $x_comment);
$x_comment = preg_replace("/\[img\](file.*?)\[\/img\]/si", "", $x_comment);
$x_comment = preg_replace("/\[img=(file.*?)\](.*?)\[\/img\]/si", "", $x_comment);
$x_comment = preg_replace("/\[img\](\:.*?)\[\/img\]/si", "", $x_comment);
$x_comment = preg_replace("/\[img=(\:.*?)\](.*?)\[\/img\]/si", "", $x_comment);
$x_comment = preg_replace("/\[img\](.*?)\[\/img\]/si", "", $x_comment);
$x_comment = preg_replace("/\[img=(.*?)\](.*?)\[\/img\]/si", "", $x_comment);
/*---------------------------------------------------------------------------------
* think about parsing content by dokuwiki renderer for dokuwiki syntax recognition
* $x_comment = p_render('xhtml',p_get_instructions($x_comment),$info);
* take care to strip IssueTracker syntax to prevent endless loop
---------------------------------------------------------------------------------*/
return $x_comment;
}
/******************************************************************************/
/* log issue modificaions
* who changed what and when per issue
*/
function _log_mods($project, $issue, $usr, $column, $old_value, $new_value)
{ global $conf;
// get mod-log file contents
if($conf['plugin']['issuetracker']['it_data']==false) $modfile = DOKU_CONF."../data/meta/".$project.'_'.$issue['id'].'.mod-log';
else $modfile = DOKU_CONF."../". $conf['plugin']['issuetracker']['it_data'].$project.'_'.$issue['id'].'.mod-log';
if (@file_exists($modfile))
{$mods = unserialize(@file_get_contents($modfile));}
else
{$mods = array();}
$cur_date = date('Y-m-d G:i:s');
$mod_id = count($mods);
if($new_value=='') $new_value = '[deleted]';
$mods[$mod_id]['timestamp'] = $cur_date;
$mods[$mod_id]['user'] = $usr;
$mods[$mod_id]['field'] = $column;
$mods[$mod_id]['old_value'] = $old_value;
$mods[$mod_id]['new_value'] = $new_value;
// Save issues file contents
$fh = fopen($modfile, 'w');
fwrite($fh, serialize($mods));
fclose($fh);
}
/******************************************************************************/
global $ID;
global $lang;
global $conf;
// Include the language file
if ($conf['lang']=='') $conf['lang']=='en';
if ($conf['lang']!=='') {
$path = DOKU_PLUGIN.'issuetracker/lang/';
// don't include once, in case several plugin components require the same language file
@include($path.'en/lang.php');
if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php');
}
$exploded = explode(' ',htmlspecialchars(stripslashes($_POST['id'])));
$project = $exploded[0];
$id_issue = intval($exploded[1]);
$usr = $_POST['usr'];
$currentID = $_POST['currentID'];
$cur_date = date('Y-m-d G:i:s');
// get issues file contents
if($conf['plugin']['issuetracker']['it_data']==false) $pfile = DOKU_CONF."../data/meta/".$project.'.issues';
else $pfile = DOKU_CONF."../". $conf['plugin']['issuetracker']['it_data'].$project.'.issues';
if (@file_exists($pfile))
{$issues = unserialize(@file_get_contents($pfile));}
else
{$issues = array();}
$field = strtolower(htmlspecialchars(stripslashes($_POST['field'])));
$value = htmlspecialchars(stripslashes($_POST['value']));
if(($field == 'resolution') && ($value !== false)) {
$issues[$id_issue]['status'] = $lang['issue_resolved_status'];
}
$old_value = $issues[$id_issue][$field];
$issues[$id_issue][$field] = $value;
$issues[$id_issue]['modified'] = $cur_date;
_log_mods($project, $issues[$id_issue], $usr, $field, $old_value, $value);
// notification mails as long as status is not deleted
if($conf['status_special']=='') $conf['status_special']='Deleted';
if (stripos($conf['status_special'],$value) === false) {
_emailForIssueMod($currentID, $project, $issues[$id_issue], $old_value, $field, $value, $usr);
}
// inform assigned workforce for new issue
if ($field == 'assigned') {
$issues[$id_issue]['assigned'] = $value;
$status = explode(',', $conf['plugin']['issuetracker']['status']);
// No custom configuration in the event $conf does not contain issuetracker status field
// not the best idea to fall back to hard coded defaults but fast implemented
if($status[0]=='') $status[0]='New';
if($status[1]=='') $status[1]='Assigned';
if($issues[$id_issue]['assigned']=='')
{ // assignment deleted => set status to first config value
$issues[$id_issue]['status'] = $status[0];
}
else $issues[$id_issue]['status'] = $status[1];
_emailToAssigneeMod($currentID, $project, $issues[$id_issue], $value, $usr);
}
// Save issues file contents
$fh = fopen($pfile, 'w');
fwrite($fh, serialize($issues));
fclose($fh);
echo $value;
?>