Call Us:
For basic information on plugins, please refer: Infocapture plugins
In this section we would see how to change the reporter name to user defined name within the form
You can find the xml file of the test project here:
Lets suppose we have got this test project with ID = 16
For this purpose, we require plugin_16_add_issue.php
<?php function hd_plugin_16_add_issue($params) { global $db; $project = new HDProject(); $fbform = new FBForm(); $pid = 16; $project_info = $params["project"]; $issue_info = $params["issue"]; $issue_fields = $params["issue"]["fields_values"]; if (!$project->Load($pid)) { $errno = "Cannot load current project"; vard2($errno); exit; } //$user_id is the id of the reporter, which is "0" (ie. default reporter) if no other user is selected $user_id = $issue_fields["reporter_name"]; if ($user_id == 0) { //Here reporter name is set to id 1, which is the id of "myself"; $result = array(); $result["issue"] = array(); $result["issue"]["reporter"] = 1; $result["issue"]["fields_values"]["reporter_name"] = 1; return $result; } else { $result = array(); $result["issue"] = array(); $result["issue"]["reporter"] = $user_id; return $result; } } ?>
Place the above file in folder: /httpdocs/intranet/helpdesk/plugins/
Here, I have logged in as “Claromentis Administrator” and I have selected reporter’s name as “User 1 TEST”. When I report issue, the “Reported by” field is changed to “User 1 TEST” instead of the default reporter “Claromentis Administrator”
Discussion