Indefero

Indefero Commit Details


Date:2011-05-28 16:48:00 (13 years 6 months ago)
Author:Thomas Keller
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:16dda0743c805fa01bc2d0a313c89436f5b3080c
Parents: bcba64b2a10b29e06472f2dc6bb021e9eacb4645
Message:Basic storage of relations for new issues has been done; the relations are also properly displayed at the left side in the issue's detail view.

Changes:

File differences

src/IDF/Form/IssueCreate.php
3636
3737
3838
39
3940
4041
4142
......
4546
4647
4748
49
50
4851
4952
5053
54
5155
5256
5357
......
109113
110114
111115
112
113116
114117
115118
116
119
117120
118121
119122
......
250253
251254
252255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
253299
254300
255301
......
313359
314360
315361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
316383
317384
318385
public $user = null;
public $project = null;
public $show_full = false;
public $relation_types = null;
public function initFields($extra=array())
{
or $this->user->hasPerm('IDF.project-member', $this->project)) {
$this->show_full = true;
}
$this->relation_types = $this->project->getRelationsFromConfig();
$contentTemplate = $this->project->getConf()->getVal(
'labels_issue_template', IDF_Form_IssueTrackingConf::init_template
);
$this->fields['summary'] = new Pluf_Form_Field_Varchar(
array('required' => true,
'label' => __('Summary'),
),
));
$relation_types = $extra['project']->getRelationsFromConfig();
$this->fields['relation_type'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('This issue'),
'initial' => $relation_types[0],
'initial' => current($this->relation_types),
'widget_attrs' => array('size' => 15),
));
return $this->cleaned_data['status'];
}
function clean_relation_type()
{
$relation_type = trim($this->cleaned_data['relation_type']);
if (empty($relation_type))
return '';
$found = false;
foreach ($this->relation_types as $type) {
if ($type == $relation_type) {
$found = true;
break;
}
}
if (!$found) {
throw new Pluf_Form_Invalid(__('You provided an invalid relation type.'));
}
return $relation_type;
}
function clean_relation_issue()
{
$issues = trim($this->cleaned_data['relation_issue']);
if (empty($issues))
return '';
$issue_ids = preg_split('/\s*,\s*/', $issues, -1, PREG_SPLIT_NO_EMPTY);
foreach ($issue_ids as $issue_id) {
if (!ctype_digit($issue_id) || (int)$issue_id < 1) {
throw new Pluf_Form_Invalid(sprintf(
__('The value "%s" is not a valid issue id.'), $issue_id
));
}
$issue = new IDF_Issue($issue_id);
if ($issue->id != $issue_id || $issue->project != $this->project->id) {
throw new Pluf_Form_Invalid(sprintf(
__('The issue "%s" does not exist.'), $issue_id
));
}
}
return implode(', ', $issue_ids);
}
/**
* Clean the attachments post failure.
*/
foreach ($tags as $tag) {
$issue->setAssoc($tag);
}
// add relations
$verb = $this->cleaned_data['relation_type'];
$other_verb = $this->relation_types[$verb];
$related_issues = preg_split('/\s*,\s*/', $this->cleaned_data['relation_issue'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($related_issues as $related_issue_id) {
$related_issue = new IDF_Issue($related_issue_id);
$rel = new IDF_IssueRelation();
$rel->issue = $issue;
$rel->verb = $verb;
$rel->other_issue = $related_issue;
$rel->submitter = $this->user;
$rel->create();
$other_rel = new IDF_IssueRelation();
$other_rel->issue = $related_issue;
$other_rel->verb = $other_verb;
$other_rel->other_issue = $issue;
$other_rel->submitter = $this->user;
$other_rel->create();
}
// add the first comment
$comment = new IDF_IssueComment();
$comment->issue = $issue;
src/IDF/Form/IssueTrackingConf.php
7272
7373
7474
75
7576
7677
7778
7879
80
81
82
83
84
85
86
87
88
89
90
91
92
7993
8094
8195
Usability = Affects program usability
Maintainability = Hinders future changes';
const init_one_max = 'Type, Priority, Milestone';
// ATTENTION: if you change something here, change the values below as well!
const init_relations = 'is related to
blocks, is blocked by
duplicates, is duplicated by';
// These are actually all noop's, but we have no other chance to
// tell IDF's translation mechanism to mark the strings as translatable
// FIXME: IDF should get a internal translation system for strings like
// that, that can also be easily expanded by users
private function noop()
{
__('is related to');
__('blocks');
__('is blocked by');
__('duplicates');
__('is duplicated by');
}
public function initFields($extra=array())
{
$this->fields['labels_issue_template'] = new Pluf_Form_Field_Varchar(
src/IDF/Form/IssueUpdate.php
3939
4040
4141
42
4243
4344
4445
......
103104
104105
105106
106
107107
108108
109109
110
110
111111
112112
113113
or $this->user->hasPerm('IDF.project-member', $this->project)) {
$this->show_full = true;
}
$this->relation_types = $this->project->getRelationsFromConfig();
if ($this->show_full) {
$this->fields['summary'] = new Pluf_Form_Field_Varchar(
array('required' => true,
),
));
$relation_types = $extra['project']->getRelationsFromConfig();
$this->fields['relation_type'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('This issue'),
'initial' => $relation_types[0],
'initial' => current($this->relation_types),
'widget_attrs' => array('size' => 15),
));
src/IDF/Issue.php
169169
170170
171171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
172190
173191
174192
}
}
function getGroupedRelatedIssues($opts = array())
{
$rels = $this->get_related_issues_list(array_merge($opts, array(
'view' => 'with_other_issue',
)));
$res = array();
foreach ($rels as $rel) {
$verb = $rel->verb;
if (!array_key_exists($verb, $res)) {
$res[$verb] = array();
}
$res[$verb][] = $rel;
}
return $res;
}
/**
* Returns an HTML fragment used to display this issue in the
* timeline.
src/IDF/IssueRelation.php
4545
4646
4747
48
48
4949
5050
5151
......
5959
6060
6161
62
62
6363
6464
6565
......
8282
8383
8484
85
86
87
88
89
90
91
8592
8693
8794
'model' => 'IDF_Issue',
'blank' => false,
'verbose' => __('issue'),
'relate_name' => 'issues',
'relate_name' => 'related_issues',
),
'verb' =>
array(
'model' => 'IDF_Issue',
'blank' => false,
'verbose' => __('other issue'),
'relate_name' => 'other_issues',
'relate_name' => 'related_other_issues',
),
'submitter' =>
array(
'type' => 'normal',
),
);
$issuetbl = $this->_con->pfx.'idf_issues';
$this->_a['views'] = array(
'with_other_issue' => array(
'join' => 'INNER JOIN '.$issuetbl.' ON other_issue='.$issuetbl.'.id',
'select' => $this->getSelect().', summary',
'props' => array('summary' => 'other_summary'),
));
}
function preSave($create=false)
src/IDF/Project.php
234234
235235
236236
237
237
238
239
240
238241
239242
240243
......
244247
245248
246249
247
250
251
252
253
254
248255
249256
250257
}
/**
* Returns a list of relations which are available in this project
* Returns a list of relations which are available in this project as
* associative array. Each key-value pair marks a set of orthogonal
* relations. To ease processing, each of these pairs is included twice
* in the array, once as key1 => key2 and once as key2 => key1.
*
* @return array List of relation names
*/
$rel = $conf->getVal('issue_relations', IDF_Form_IssueTrackingConf::init_relations);
$relations = array();
foreach (preg_split("/\015\012|\015|\012/", $rel, -1, PREG_SPLIT_NO_EMPTY) as $s) {
$relations = array_merge($relations, preg_split("/\s*,\s*/", $s, 2));
$verbs = preg_split("/\s*,\s*/", $s, 2);
if (count($verbs) == 1)
$relations += array($verbs[0] => $verbs[0]);
else
$relations += array($verbs[0] => $verbs[1], $verbs[1] => $verbs[0]);
}
return $relations;
}
src/IDF/Views/Issue.php
404404
405405
406406
407
408
407409
408410
409411
......
471473
472474
473475
474
476
477
475478
476479
477480
$issue = Pluf_Shortcuts_GetObjectOr404('IDF_Issue', $match[2]);
$prj->inOr404($issue);
$comments = $issue->get_comments_list(array('order' => 'id ASC'));
$related_issues = $issue->getGroupedRelatedIssues(array('order' => 'creation_dtime DESC'));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($prj->shortname, $issue->id));
$title = Pluf_Template::markSafe(sprintf(__('Issue <a href="%s">%d</a>: %s'), $url, $issue->id, $issue->summary));
'preview' => $preview,
'interested' => $interested->count(),
'previous_issue_id' => $previous_issue_id,
'next_issue_id' => $next_issue_id
'next_issue_id' => $next_issue_id,
'related_issues' => $related_issues,
),
$arrays),
$request);
src/IDF/templates/idf/issues/view.html
170170
171171
172172
173
174
175
176
177
178
179
180
181
182
183
184
185
173186
174187
175188
<span class="label"><a href="{$url}" class="label"><strong>{$tag.class}:</strong>{$tag.name}</a></span><br />
{/foreach}
</p>{/if}
{if count($related_issues) > 0}
{foreach $related_issues as $verb => $rel_issues}
<strong>{blocktrans}This issue {$verb}{/blocktrans}</strong><br />
{foreach $rel_issues as $rel_issue}
<span class="label">
<a href="{url 'IDF_Views_Issue::view', array($project.shortname, $rel_issue.other_issue)}"
title="{$rel_issue.other_summary}">
<strong>{$rel_issue.other_issue}</strong> - {$rel_issue.other_summary|shorten:30}
</a>
</span><br />
{/foreach}
{/foreach}
{/if}
</div>
{/block}
{block javascript}{if $form}{include 'idf/issues/js-autocomplete.html'}

Archive Download the corresponding diff file

Page rendered in 0.10407s using 13 queries.