~ubuntu-branches/ubuntu/trusty/php-codesniffer/trusty

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.5.0RC2/CodeSniffer/Standards/MySource/Tests/PHP/AjaxNullComparisonUnitTest.inc

  • Committer: Package Import Robot
  • Author(s): Thomas Goirand
  • Date: 2013-07-12 15:16:25 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130712151625-4autdc0twzbueha9
Tags: 1.5.0~rc2-1
* New upstream release.
* Refreshed patch.
* Standards-Version is now 3.9.4.
* Canonical VCS URLs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Adds a new issue.
 
4
 *
 
5
 * Returns the new issue id.
 
6
 *
 
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
 
14
 *                                   assigned to.
 
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.
 
18
 *
 
19
 * @return integer
 
20
 * @throws ChannelException If there is an error.
 
21
 *
 
22
 * @api            write
 
23
 * @api-permission public
 
24
 */
 
25
public static function addIssue(
 
26
    $title,
 
27
    $description,
 
28
    $reporter=NULL,
 
29
    $projectid=NULL,
 
30
    array $tags=array(),
 
31
    $status=NULL,
 
32
    $assignedTo=NULL,
 
33
    $reportedDate=NULL,
 
34
    $reportedMilestone=NULL
 
35
) {
 
36
    // Get current projectid if not specified.
 
37
    if ($projectid === NULL) {
 
38
        Channels::includeSystem('Project');
 
39
        $projectid = Project::getCurrentProjectId();
 
40
        Channels::modifyBasket('project', $projectid);
 
41
    }
 
42
 
 
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'));
 
47
    }
 
48
 
 
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'));
 
52
        }
 
53
 
 
54
        if (SquizRoadmap::isVisibleProject($projectid, $assignedTo) === FALSE) {
 
55
            throw new ChannelException(_('Assigned to user does not have access to issue project.'));
 
56
        }
 
57
    }
 
58
 
 
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);
 
64
    }
 
65
 
 
66
    if (SquizRoadmap::isVisibleProject($projectid, $reporter) === FALSE) {
 
67
        throw new ChannelException(_('Contributed by user does not have access to issue project.'));
 
68
    }
 
69
 
 
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'));
 
77
        }
 
78
 
 
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));
 
83
    }
 
84
 
 
85
    $issueid = DAL::seqNextVal('sq_rdm_issue_seq');
 
86
    Channels::addToBasket('issueid', $issueid);
 
87
 
 
88
    if ($reportedDate === NULL) {
 
89
        include_once 'Libs/String/String.inc';
 
90
        $reportedDate = String::tsIso8601(time());
 
91
        Channels::modifyBasket('reportedDate', $reportedDate);
 
92
    }
 
93
 
 
94
    $title = trim($title);
 
95
    Channels::modifyBasket('title', $title);
 
96
    if (empty($title) === TRUE) {
 
97
        throw new ChannelException(_('Title cannot be empty'));
 
98
    }
 
99
 
 
100
    $description = SquizRoadmap::stripTags(trim($description));
 
101
    Channels::modifyBasket('description', $description);
 
102
    if (empty($description) === TRUE) {
 
103
        throw new ChannelException(_('Description cannot be empty'));
 
104
    }
 
105
 
 
106
    try {
 
107
        DAL::beginTransaction();
 
108
 
 
109
        $query = DAL::getDALQuery('SquizRoadmapIssue', 'addIssue');
 
110
        DAL::executeQuery($query);
 
111
 
 
112
        // Add tags for the new issue.
 
113
        SquizRoadmapIssue::addIssueTags($issueid, $tags);
 
114
 
 
115
        // Add reporter and assignee to watch list.
 
116
        SquizRoadmapIssue::addIssueWatch($issueid, $reporter);
 
117
 
 
118
        if ($assignedTo !== NULL) {
 
119
            SquizRoadmapIssue::addIssueWatch($issueid, $assignedTo);
 
120
        }
 
121
 
 
122
        SquizRoadmapIssue::clearIssueCache($issueid);
 
123
 
 
124
        DAL::commit();
 
125
    } catch (Exception $e) {
 
126
        DAL::rollBack();
 
127
        throw new ChannelException($e->getMessage());
 
128
    }//end try
 
129
 
 
130
    if ($something === NULL) {
 
131
        if ($bar !== NULL) {
 
132
        }
 
133
    }
 
134
 
 
135
    return $issueid;
 
136
 
 
137
}//end addIssue()
 
138
 
 
139
/**
 
140
 * Adds a new issue.
 
141
 *
 
142
 * Returns the new issue id.
 
143
 *
 
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
 
151
 *                                   assigned to.
 
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.
 
155
 *
 
156
 * @return integer
 
157
 * @throws ChannelException If there is an error.
 
158
 *
 
159
 */
 
160
public static function addIssue(
 
161
    $title,
 
162
    $description,
 
163
    $reporter=NULL,
 
164
    $projectid=NULL,
 
165
    array $tags=array(),
 
166
    $status=NULL,
 
167
    $assignedTo=NULL,
 
168
    $reportedDate=NULL,
 
169
    $reportedMilestone=NULL
 
170
) {
 
171
    // Get current projectid if not specified.
 
172
    if ($projectid === NULL) {
 
173
        Channels::includeSystem('Project');
 
174
        $projectid = Project::getCurrentProjectId();
 
175
        Channels::modifyBasket('project', $projectid);
 
176
    }
 
177
 
 
178
}//end addIssue()
 
179
?>