Indefero

Indefero Commit Details


Date:2011-01-05 10:02:06 (13 years 11 months ago)
Author:William MARTIN
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:c7c39c6fa13285d133fcda302eee71c2434accf0
Parents: 4b75a556399559300239bf14f262602a06bc8beb
Message:Implementation of the watch-list viewer

Fix issue 589
Changes:

File differences

src/IDF/Views/Issue.php
7979
8080
8181
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
82234
83235
84236
......
541693
542694
543695
696
697
698
699
700
701
702
703
704
705
706
544707
545708
546709
......
576739
577740
578741
742
743
}
/**
* View the issues watch list of a given user.
* Limited to a specified project
*/
public $watchList_precond = array('IDF_Precondition::accessIssues',
'Pluf_Precondition::loginRequired');
public function watchList($request, $match)
{
$prj = $request->project;
$otags = $prj->getTagIdsByStatus('open');
$ctags = $prj->getTagIdsByStatus('closed');
if (count($otags) == 0) $otags[] = 0;
if (count($ctags) == 0) $ctags[] = 0;
// Get the id list of issue in the user watch list (for all projects !)
$db =& Pluf::db();
$issues_id = $db->select('SELECT GROUP_CONCAT(idf_issue_id) as id FROM '.Pluf::f('db_table_prefix', '').'idf_issue_pluf_user_assoc WHERE pluf_user_id='.$request->user->id.' GROUP BY pluf_user_id');
if (empty ($issues_id)) $issues_id = "";
else $issues_id = $issues_id[0]['id'];
// Count open and close issues
$sql = new Pluf_SQL('project=%s AND id IN ('.$issues_id.') AND status IN ('.implode(', ', $otags).')', array($prj->id));
$nb_open = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
$sql = new Pluf_SQL('project=%s AND id IN ('.$issues_id.') AND status IN ('.implode(', ', $ctags).')', array($prj->id));
$nb_closed = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
// Generate a filter for the paginator
switch ($match[2]) {
case 'closed':
$title = sprintf(__('Watch List: Closed Issues for %s'), (string) $prj);
$summary = __('This table shows the closed issues in your watch list for %s project.', (string) $prj);
$f_sql = new Pluf_SQL('project=%s AND id IN ('.$issues_id.') AND status IN ('.implode(', ', $ctags).')', array($prj->id));
break;
case 'open':
default:
$title = sprintf(__('Watch List: Open Issues for %s'), (string) $prj);
$summary = __('This table shows the open issues in your watch list for %s project.', (string) $prj);
$f_sql = new Pluf_SQL('project=%s AND id IN ('.$issues_id.') AND status IN ('.implode(', ', $otags).')', array($prj->id));
break;
}
// Paginator to paginate the issues
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues';
$pag->item_extra_props = array('project_m' => $prj,
'shortname' => $prj->shortname,
'current_user' => $request->user);
$pag->summary = $summary;
$pag->forced_where = $f_sql;
$pag->action = array('IDF_Views_Issue::watchList', array($prj->shortname, $match[1]));
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
$pag->sort_reverse_order = array('modif_dtime');
$pag->sort_link_title = true;
$pag->extra_classes = array('a-c', '', 'a-c', '');
$list_display = array(
'id' => __('Id'),
array('summary', 'IDF_Views_Issue_SummaryAndLabels', __('Summary')),
array('status', 'IDF_Views_Issue_ShowStatus', __('Status')),
array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')),
);
$pag->configure($list_display, array(), array('id', 'status', 'modif_dtime'));
$pag->items_per_page = 10;
$pag->no_results_text = __('No issues were found.');
$pag->setFromRequest($request);
return Pluf_Shortcuts_RenderToResponse('idf/issues/project-watchlist.html',
array('project' => $prj,
'page_title' => $title,
'open' => $nb_open,
'closed' => $nb_closed,
'issues' => $pag,
),
$request);
}
/**
* View the issues watch list of a given user.
* For all projects
*/
public $forgeWatchList_precond = array('Pluf_Precondition::loginRequired');
public function forgeWatchList($request, $match)
{
$otags = array();
$ctags = array();
// Note that this approach does not scale, we will need to add
// a table to cache the meaning of the tags for large forges.
foreach (IDF_Views::getProjects($request->user) as $project) {
$otags = array_merge($otags, $project->getTagIdsByStatus('open'));
}
foreach (IDF_Views::getProjects($request->user) as $project) {
$ctags = array_merge($ctags, $project->getTagIdsByStatus('closed'));
}
if (count($otags) == 0) $otags[] = 0;
if (count($ctags) == 0) $ctags[] = 0;
// Get the id list of issue in the user watch list (for all projects !)
$db =& Pluf::db();
$issues_id = $db->select('SELECT GROUP_CONCAT(idf_issue_id) as id FROM '.Pluf::f('db_table_prefix', '').'idf_issue_pluf_user_assoc WHERE pluf_user_id='.$request->user->id.' GROUP BY pluf_user_id');
if (empty ($issues_id)) $issues_id = "";
else $issues_id = $issues_id[0]['id'];
// Count open and close issues
$sql = new Pluf_SQL('id IN ('.$issues_id.') AND status IN ('.implode(', ', $otags).')', array());
$nb_open = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
$sql = new Pluf_SQL('id IN ('.$issues_id.') AND status IN ('.implode(', ', $ctags).')', array());
$nb_closed = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen()));
// Generate a filter for the paginator
switch ($match[1]) {
case 'closed':
$title = sprintf(__('Watch List: Closed Issues'));
$summary = __('This table shows the closed issues in your watch list.');
$f_sql = new Pluf_SQL('id IN ('.$issues_id.') AND status IN ('.implode(', ', $ctags).')', array());
break;
case 'open':
default:
$title = sprintf(__('Watch List: Open Issues'));
$summary = __('This table shows the open issues in your watch list.');
$f_sql = new Pluf_SQL('id IN ('.$issues_id.') AND status IN ('.implode(', ', $otags).')', array());
break;
}
// Paginator to paginate the issues
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues';
$pag->item_extra_props = array('current_user' => $request->user);
$pag->summary = $summary;
$pag->forced_where = $f_sql;
$pag->action = array('IDF_Views_Issue::forgeWatchList', array($match[1]));
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
$pag->sort_reverse_order = array('modif_dtime');
$pag->sort_link_title = true;
$pag->extra_classes = array('a-c', '', 'a-c', '');
$list_display = array(
'id' => __('Id'),
array('summary', 'IDF_Views_Issue_SummaryAndLabelsUnknownProject', __('Summary')),
array('project', 'Pluf_Paginator_FkToString', __('Project')),
array('status', 'IDF_Views_Issue_ShowStatus', __('Status')),
array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')),
);
$pag->configure($list_display, array(), array('id', 'project', 'status', 'modif_dtime'));
$pag->items_per_page = 10;
$pag->no_results_text = __('No issues were found.');
$pag->setFromRequest($request);
return Pluf_Shortcuts_RenderToResponse('idf/issues/forge-watchlist.html',
array('page_title' => $title,
'open' => $nb_open,
'closed' => $nb_closed,
'issues' => $pag,
),
$request);
}
/**
* View the issues of a given user.
*
* Only open issues are shown.
}
/**
* When you access to your forge watch list, issue don't known
* the project shortname.
*/
function IDF_Views_Issue_SummaryAndLabelsUnknownProject($field, $issue, $extra='')
{
$shortname = $issue->get_project()->shortname;
$issue->__set('shortname', $shortname);
return IDF_Views_Issue_SummaryAndLabels ($field, $issue, $extra);
}
/**
* Display the summary of an issue, then on a new line, display the
* list of labels with a link to a view "by label only".
*
{
return Pluf_esc($issue->get_status()->name);
}
src/IDF/conf/urls.php
141141
142142
143143
144
145
146
147
148
149
150
151
152
153
144154
145155
146156
'model' => 'IDF_Views_Issue',
'method' => 'viewAttachment');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/watchlist/(\w+)$#',
'base' => $base,
'model' => 'IDF_Views_Issue',
'method' => 'watchList');
$ctl[] = array('regex' => '#^/watchlist/(\w+)$#',
'base' => $base,
'model' => 'IDF_Views_Issue',
'method' => 'forgeWatchList');
// ---------- SCM ----------------------------------------
$ctl[] = array('regex' => '#^/p/([\-\w]+)/source/help/$#',
src/IDF/templates/idf/issues/base.html
33
44
55
6
6
7
78
89
910
{block subtabs}
<div id="sub-tabs">
<a {if $inOpenIssues}class="active" {/if}href="{url 'IDF_Views_Issue::index', array($project.shortname)}">{trans 'Open Issues'}</a>
{if !$user.isAnonymous()} | <a {if $inCreate}class="active" {/if}href="{url 'IDF_Views_Issue::create', array($project.shortname)}">{trans 'New Issue'}</a> | <a {if $inMyIssues}class="active" {/if}href="{url 'IDF_Views_Issue::myIssues', array($project.shortname, 'submit')}">{trans 'My Issues'}</a>{/if} |
{if !$user.isAnonymous()} | <a {if $inCreate}class="active" {/if}href="{url 'IDF_Views_Issue::create', array($project.shortname)}">{trans 'New Issue'}</a> | <a {if $inMyIssues}class="active" {/if}href="{url 'IDF_Views_Issue::myIssues', array($project.shortname, 'submit')}">{trans 'My Issues'}</a>
| <a {if $inWatchList}class="active" {/if}href="{url 'IDF_Views_Issue::watchList', array($project.shortname, 'open')}">{trans 'My watch list'}</a>{/if} |
<form class="star" action="{url 'IDF_Views_Issue::search', array($project.shortname)}" method="get">
<input accesskey="4" type="text" value="{$q}" name="q" size="20" />
<input type="submit" name="s" value="{trans 'Search'}" />
src/IDF/templates/idf/issues/forge-watchlist.html
1
2
3
4
5
6
7
8
9
10
11
12
{extends "idf/base-simple.html"}
{block body}
{$issues.render}
{/block}
{block context}
{aurl 'open_url', 'IDF_Views_Issue::forgeWatchList', array('open')}
{aurl 'closed_url', 'IDF_Views_Issue::forgeWatchList', array('closed')}
{blocktrans}<p><strong>Open issues:</strong> <a href="{$open_url}">{$open}</a></p>
<p><strong>Closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>{/blocktrans}
{/block}
src/IDF/templates/idf/issues/project-watchlist.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{extends "idf/issues/base.html"}
{block docclass}yui-t2{assign $inWatchList = true}{/block}
{block body}
{$issues.render}
{if !$user.isAnonymous()}
{aurl 'url', 'IDF_Views_Issue::create', array($project.shortname)}
<p><a href="{$url}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/add.png'}" alt="+" align="bottom" /></a> <a href="{$url}">{trans 'New Issue'}</a></p>{/if}
{/block}
{block context}
{aurl 'open_url', 'IDF_Views_Issue::watchList', array($project.shortname, 'open')}
{aurl 'closed_url', 'IDF_Views_Issue::watchList', array($project.shortname, 'closed')}
{blocktrans}<p><strong>Open issues:</strong> <a href="{$open_url}">{$open}</a></p>
<p><strong>Closed issues:</strong> <a href="{$closed_url}">{$closed}</a></p>{/blocktrans}
{/block}
src/IDF/templates/idf/user/dashboard.html
1111
1212
1313
14
15
1416
1517
<p>{blocktrans}<a href="{$url}">Update your account</a>.{/blocktrans}</p>
{aurl 'url', 'IDF_Views_User::view', array($user.login)}
<p>{blocktrans}<a href="{$url}">See your public profile</a>.{/blocktrans}</p>
{aurl 'url', 'IDF_Views_Issue::forgeWatchList', array('open')}
<p>{blocktrans}<a href="{$url}">See your forge issue watch list</a>.{/blocktrans}</p>
{/block}

Archive Download the corresponding diff file

Page rendered in 0.09644s using 14 queries.