5
* Returns the new issue id.
7
* @param string $title Title of the new issue.
8
* @param string $description The description of the issue.
9
* @param string $reporter Asset id of the reporter.
10
* @param integer $projectid Id of the project that the issue belongs to.
11
* @param array $tags Array of tags.
12
* @param string $status The status of the issue.
13
* @param string $assignedTo The asset id of the user that the issue is
15
* @param string $reportedDate If set then this date will be used instead of the
16
* current date and time.
17
* @param integer $reportedMilestone Reported milestone.
20
* @throws ChannelException If there is an error.
23
* @api-permission public
25
public static function addIssue(
34
$reportedMilestone=NULL
36
// Get current projectid if not specified.
37
if ($projectid === NULL) {
38
Channels::includeSystem('Project');
39
$projectid = Project::getCurrentProjectId();
40
Channels::modifyBasket('project', $projectid);
43
Channels::includeSystem('SquizRoadmap');
44
Channels::includeSystem('Permission');
45
if (Permission::hasPermission($projectid, 'ideas.contribute') === FALSE) {
46
throw new ChannelException(_('You do not have permission to contribute idea'));
49
if ($assignedTo !== NULL) {
50
if (Permission::hasPermission($projectid, 'ideas.edit.details') === FALSE) {
51
throw new ChannelException(_('You do not have permission to assign user to idea'));
54
if (SquizRoadmap::isVisibleProject($projectid, $assignedTo) === FALSE) {
55
throw new ChannelException(_('Assigned to user does not have access to issue project.'));
59
// Get current user id if not specified.
60
if ($reporter === NULL) {
61
Channels::includeSystem('User');
62
$reporter = User::getCurrentUserid();
63
Channels::modifyBasket('reporter', $reporter);
66
if (SquizRoadmap::isVisibleProject($projectid, $reporter) === FALSE) {
67
throw new ChannelException(_('Contributed by user does not have access to issue project.'));
70
// Make sure status is valid.
71
Channels::includeSystem('SquizRoadmap');
72
Channels::includeSystem('SquizRoadmapStatus');
73
if ($status === NULL) {
74
$statuses = SquizRoadmapStatus::getStatus($projectid);
75
if (empty($statuses) === TRUE) {
76
throw new ChannelException(_('No defined statuses in project'));
79
$status = $statuses[0]['status'];
80
Channels::modifyBasket('status', $status);
81
} else if (SquizRoadmapStatus::isValidStatus($projectid, $status) === FALSE) {
82
throw new ChannelException(sprintf(_('Invalid status: %s'), $status));
85
$issueid = DAL::seqNextVal('sq_rdm_issue_seq');
86
Channels::addToBasket('issueid', $issueid);
88
if ($reportedDate === NULL) {
89
include_once 'Libs/String/String.inc';
90
$reportedDate = String::tsIso8601(time());
91
Channels::modifyBasket('reportedDate', $reportedDate);
94
$title = trim($title);
95
Channels::modifyBasket('title', $title);
96
if (empty($title) === TRUE) {
97
throw new ChannelException(_('Title cannot be empty'));
100
$description = SquizRoadmap::stripTags(trim($description));
101
Channels::modifyBasket('description', $description);
102
if (empty($description) === TRUE) {
103
throw new ChannelException(_('Description cannot be empty'));
107
DAL::beginTransaction();
109
$query = DAL::getDALQuery('SquizRoadmapIssue', 'addIssue');
110
DAL::executeQuery($query);
112
// Add tags for the new issue.
113
SquizRoadmapIssue::addIssueTags($issueid, $tags);
115
// Add reporter and assignee to watch list.
116
SquizRoadmapIssue::addIssueWatch($issueid, $reporter);
118
if ($assignedTo !== NULL) {
119
SquizRoadmapIssue::addIssueWatch($issueid, $assignedTo);
122
SquizRoadmapIssue::clearIssueCache($issueid);
125
} catch (Exception $e) {
127
throw new ChannelException($e->getMessage());
130
if ($something === NULL) {
142
* Returns the new issue id.
144
* @param string $title Title of the new issue.
145
* @param string $description The description of the issue.
146
* @param string $reporter Asset id of the reporter.
147
* @param integer $projectid Id of the project that the issue belongs to.
148
* @param array $tags Array of tags.
149
* @param string $status The status of the issue.
150
* @param string $assignedTo The asset id of the user that the issue is
152
* @param string $reportedDate If set then this date will be used instead of the
153
* current date and time.
154
* @param integer $reportedMilestone Reported milestone.
157
* @throws ChannelException If there is an error.
160
public static function addIssue(
169
$reportedMilestone=NULL
171
// Get current projectid if not specified.
172
if ($projectid === NULL) {
173
Channels::includeSystem('Project');
174
$projectid = Project::getCurrentProjectId();
175
Channels::modifyBasket('project', $projectid);