From 33882d4fa788e44462709718050238202a89a6ea Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Mon, 3 Oct 2011 10:00:35 +0200 Subject: [PATCH 1/3] Update how the myIssue view works. It's allow to display this view for other members. In the issue summary, we can now follow make links for each user display in the part "Unresolved: By Assignee". --- src/IDF/Views/Issue.php | 46 ++++++++++++++------- src/IDF/conf/urls.php | 2 +- src/IDF/templates/idf/issues/base.html | 2 +- src/IDF/templates/idf/issues/my-issues.html | 10 ++--- src/IDF/templates/idf/issues/summary.html | 2 +- src/IDF/templates/idf/js-hotkeys.html | 4 +- src/IDF/templates/idf/review/base-full.html | 2 +- 7 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/IDF/Views/Issue.php b/src/IDF/Views/Issue.php index 9c749af..3ef8e96 100644 --- a/src/IDF/Views/Issue.php +++ b/src/IDF/Views/Issue.php @@ -113,7 +113,7 @@ class IDF_Views_Issue $obj = Pluf::factory('Pluf_User')->getOne(array('filter'=>'id='.$user)); $key = $obj->first_name . ' ' . $obj->last_name; } - $ownerStatistics[$key] = array($nb, (int)(100 * $nb / $opened)); + $ownerStatistics[$key] = array($nb, (int)(100 * $nb / $opened), $obj->login); } // Issue class tag statistics @@ -313,42 +313,55 @@ class IDF_Views_Issue * * Only open issues are shown. */ - public $myIssues_precond = array('IDF_Precondition::accessIssues', - 'Pluf_Precondition::loginRequired'); + public $myIssues_precond = array('IDF_Precondition::accessIssues'); public function myIssues($request, $match) { $prj = $request->project; + + $sql = new Pluf_SQL('login=%s', array($match[2])); + $user = Pluf::factory('Pluf_User')->getOne(array('filter' => $sql->gen())); + if ($user === null) { + $url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::index', + array($prj->shortname)); + return new Pluf_HTTP_Response_Redirect($url); + } + $otags = $prj->getTagIdsByStatus('open'); $ctags = $prj->getTagIdsByStatus('closed'); if (count($otags) == 0) $otags[] = 0; if (count($ctags) == 0) $ctags[] = 0; - switch ($match[2]) { + switch ($match[3]) { case 'submit': - $title = sprintf(__('My Submitted %s Issues'), (string) $prj); - $f_sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $request->user->id)); + $titleFormat = + $f_sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $user->id)); break; case 'submitclosed': - $title = sprintf(__('My Closed Submitted %s Issues'), (string) $prj); - $f_sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $request->user->id)); + $title = __('%s %s Closed Submitted %s Issues'); + $f_sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $user->id)); break; case 'ownerclosed': - $title = sprintf(__('My Closed Working %s Issues'), (string) $prj); - $f_sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $request->user->id)); + $title = __('%s %s Closed Working %s Issues'); + $f_sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $user->id)); break; default: - $title = sprintf(__('My Working %s Issues'), (string) $prj); - $f_sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $request->user->id)); + $title = __('%s %s Working %s Issues'); + $f_sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $user->id)); break; } + $title = sprintf(__('%s %s Submitted %s Issues'), + $user->first_name, + $user->last_name, + (string) $prj); + // Get stats about the issues - $sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $request->user->id)); + $sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $user->id)); $nb_submit = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen())); - $sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $request->user->id)); + $sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $user->id)); $nb_owner = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen())); // Closed issues - $sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $request->user->id)); + $sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $user->id)); $nb_submit_closed = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen())); - $sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $request->user->id)); + $sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $user->id)); $nb_owner_closed = Pluf::factory('IDF_Issue')->getCount(array('filter'=>$sql->gen())); // Paginator to paginate the issues @@ -377,6 +390,7 @@ class IDF_Views_Issue return Pluf_Shortcuts_RenderToResponse('idf/issues/my-issues.html', array('project' => $prj, 'page_title' => $title, + 'login' => $user->login, 'nb_submit' => $nb_submit, 'nb_owner' => $nb_owner, 'nb_submit_closed' => $nb_submit_closed, diff --git a/src/IDF/conf/urls.php b/src/IDF/conf/urls.php index 03779c0..a011f37 100644 --- a/src/IDF/conf/urls.php +++ b/src/IDF/conf/urls.php @@ -153,7 +153,7 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/create/$#', 'model' => 'IDF_Views_Issue', 'method' => 'create'); -$ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/my/(\w+)/$#', +$ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/(.*)/(\w+)/$#', 'base' => $base, 'model' => 'IDF_Views_Issue', 'method' => 'myIssues'); diff --git a/src/IDF/templates/idf/issues/base.html b/src/IDF/templates/idf/issues/base.html index 636d5da..0856f8f 100644 --- a/src/IDF/templates/idf/issues/base.html +++ b/src/IDF/templates/idf/issues/base.html @@ -4,7 +4,7 @@
{trans 'Summary'} | {trans 'Open Issues'} -{if !$user.isAnonymous()} | {trans 'New Issue'} | {trans 'My Issues'} +{if !$user.isAnonymous()} | {trans 'New Issue'} | {trans 'My Issues'} | {trans 'My watch list'}{/if} |
diff --git a/src/IDF/templates/idf/issues/my-issues.html b/src/IDF/templates/idf/issues/my-issues.html index f3d1d27..9823cd2 100644 --- a/src/IDF/templates/idf/issues/my-issues.html +++ b/src/IDF/templates/idf/issues/my-issues.html @@ -1,5 +1,5 @@ {extends "idf/issues/base.html"} -{block docclass}yui-t2{assign $inMyIssues = true}{/block} +{block docclass}yui-t2{if $user.login == $login}{assign $inMyIssues = true}{/if}{/block} {block body} {$issues.render} {if !$user.isAnonymous()} @@ -8,10 +8,10 @@ {/block} {block context} -{aurl 'owner_url', 'IDF_Views_Issue::myIssues', array($project.shortname, 'owner')} -{aurl 'submit_url', 'IDF_Views_Issue::myIssues', array($project.shortname, 'submit')} -{aurl 'owner_closed_url', 'IDF_Views_Issue::myIssues', array($project.shortname, 'ownerclosed')} -{aurl 'submit_closed_url', 'IDF_Views_Issue::myIssues', array($project.shortname, 'submitclosed')} +{aurl 'owner_url', 'IDF_Views_Issue::myIssues', array($project.shortname, $login, 'owner')} +{aurl 'submit_url', 'IDF_Views_Issue::myIssues', array($project.shortname, $login, 'submit')} +{aurl 'owner_closed_url', 'IDF_Views_Issue::myIssues', array($project.shortname, $login, 'ownerclosed')} +{aurl 'submit_closed_url', 'IDF_Views_Issue::myIssues', array($project.shortname, $login, 'submitclosed')}

{trans 'Submitted issues:'} {$nb_submit} {if $nb_submit_closed}
{blocktrans $nb_submit_closed}See the {$nb_submit_closed} closed.{plural}See the {$nb_submit_closed} closed.{/blocktrans}{/if}

{if $nb_owner > 0} diff --git a/src/IDF/templates/idf/issues/summary.html b/src/IDF/templates/idf/issues/summary.html index bfff813..61e117a 100644 --- a/src/IDF/templates/idf/issues/summary.html +++ b/src/IDF/templates/idf/issues/summary.html @@ -71,7 +71,7 @@ {foreach $ownerStatistics as $key => $value} - {$key} + {$key} {$value[0]} diff --git a/src/IDF/templates/idf/js-hotkeys.html b/src/IDF/templates/idf/js-hotkeys.html index 66793fb..78ecb37 100644 --- a/src/IDF/templates/idf/js-hotkeys.html +++ b/src/IDF/templates/idf/js-hotkeys.html @@ -10,8 +10,8 @@ {if $hasWikiAccess}{hotkey 'Shift+o', 'IDF_Views_Wiki::index', array($project.shortname)}{/if} {if $hasSourceAccess}{hotkey 'Shift+s', 'IDF_Views_Source::treeBase', array($project.shortname, $project.getScmRoot())}{/if} {if $hasIssuesAccess and !$user.isAnonymous()} -{hotkey 'Shift+m', 'IDF_Views_Issue::myIssues', array($project.shortname, 'submit')} -{hotkey 'Shift+w', 'IDF_Views_Issue::myIssues', array($project.shortname, 'owner')} +{hotkey 'Shift+m', 'IDF_Views_Issue::myIssues', array($project.shortname, $user.login, 'submit')} +{hotkey 'Shift+w', 'IDF_Views_Issue::myIssues', array($project.shortname, $user.login, 'owner')} {/if}{/if} //--> diff --git a/src/IDF/templates/idf/review/base-full.html b/src/IDF/templates/idf/review/base-full.html index 4d2b360..370e056 100644 --- a/src/IDF/templates/idf/review/base-full.html +++ b/src/IDF/templates/idf/review/base-full.html @@ -4,7 +4,7 @@
{trans 'Open Reviews'} {* -{if !$user.isAnonymous()} | {trans 'New Issue'} | {trans 'My Issues'}{/if} | +{if !$user.isAnonymous()} | {trans 'New Issue'} | {trans 'My Issues'}{/if} | From d860f299fdec7dfbcf7c602f8d7841c944ecb097 Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Mon, 3 Oct 2011 10:17:10 +0200 Subject: [PATCH 2/3] The last part of the previous patch. --- src/IDF/Views/Issue.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/IDF/Views/Issue.php b/src/IDF/Views/Issue.php index 3ef8e96..aa37634 100644 --- a/src/IDF/Views/Issue.php +++ b/src/IDF/Views/Issue.php @@ -332,23 +332,23 @@ class IDF_Views_Issue if (count($ctags) == 0) $ctags[] = 0; switch ($match[3]) { case 'submit': - $titleFormat = + $titleFormat = __('%s %s Submitted %s Issues'); $f_sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $user->id)); break; case 'submitclosed': - $title = __('%s %s Closed Submitted %s Issues'); + $titleFormat = __('%s %s Closed Submitted %s Issues'); $f_sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $user->id)); break; case 'ownerclosed': - $title = __('%s %s Closed Working %s Issues'); + $titleFormat = __('%s %s Closed Working %s Issues'); $f_sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $ctags).')', array($prj->id, $user->id)); break; default: - $title = __('%s %s Working %s Issues'); + $titleFormat = __('%s %s Working %s Issues'); $f_sql = new Pluf_SQL('project=%s AND owner=%s AND status IN ('.implode(', ', $otags).')', array($prj->id, $user->id)); break; } - $title = sprintf(__('%s %s Submitted %s Issues'), + $title = sprintf($titleFormat, $user->first_name, $user->last_name, (string) $prj); From 813184f06cf4589e019b68e74dec2180853e87c0 Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Tue, 4 Oct 2011 10:05:42 +0200 Subject: [PATCH 3/3] Fix an issue with "unasigned issues" Rename the view to userIssues --- src/IDF/Views/Issue.php | 12 +++++++----- src/IDF/conf/urls.php | 2 +- src/IDF/templates/idf/issues/base.html | 2 +- src/IDF/templates/idf/issues/summary.html | 7 ++++++- .../idf/issues/{my-issues.html => userIssues.html} | 8 ++++---- src/IDF/templates/idf/js-hotkeys.html | 4 ++-- src/IDF/templates/idf/review/base-full.html | 2 +- 7 files changed, 22 insertions(+), 15 deletions(-) rename src/IDF/templates/idf/issues/{my-issues.html => userIssues.html} (74%) diff --git a/src/IDF/Views/Issue.php b/src/IDF/Views/Issue.php index aa37634..2a234fb 100644 --- a/src/IDF/Views/Issue.php +++ b/src/IDF/Views/Issue.php @@ -109,11 +109,13 @@ class IDF_Views_Issue foreach ($owners as $user => $nb) { if ($user === '') { $key = __('Not assigned'); + $login = null; } else { $obj = Pluf::factory('Pluf_User')->getOne(array('filter'=>'id='.$user)); $key = $obj->first_name . ' ' . $obj->last_name; + $login = $obj->login; } - $ownerStatistics[$key] = array($nb, (int)(100 * $nb / $opened), $obj->login); + $ownerStatistics[$key] = array($nb, (int)(100 * $nb / $opened), $login); } // Issue class tag statistics @@ -313,8 +315,8 @@ class IDF_Views_Issue * * Only open issues are shown. */ - public $myIssues_precond = array('IDF_Precondition::accessIssues'); - public function myIssues($request, $match) + public $userIssues_precond = array('IDF_Precondition::accessIssues'); + public function userIssues($request, $match) { $prj = $request->project; @@ -372,7 +374,7 @@ class IDF_Views_Issue 'current_user' => $request->user); $pag->summary = __('This table shows the open issues.'); $pag->forced_where = $f_sql; - $pag->action = array('IDF_Views_Issue::myIssues', array($prj->shortname, $match[2])); + $pag->action = array('IDF_Views_Issue::userIssues', array($prj->shortname, $match[2])); $pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted $pag->sort_reverse_order = array('modif_dtime'); $pag->sort_link_title = true; @@ -387,7 +389,7 @@ class IDF_Views_Issue $pag->items_per_page = 10; $pag->no_results_text = __('No issues were found.'); $pag->setFromRequest($request); - return Pluf_Shortcuts_RenderToResponse('idf/issues/my-issues.html', + return Pluf_Shortcuts_RenderToResponse('idf/issues/userIssues.html', array('project' => $prj, 'page_title' => $title, 'login' => $user->login, diff --git a/src/IDF/conf/urls.php b/src/IDF/conf/urls.php index a011f37..1aa395c 100644 --- a/src/IDF/conf/urls.php +++ b/src/IDF/conf/urls.php @@ -156,7 +156,7 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/create/$#', $ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/(.*)/(\w+)/$#', 'base' => $base, 'model' => 'IDF_Views_Issue', - 'method' => 'myIssues'); + 'method' => 'userIssues'); $ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/attachment/(\d+)/(.*)$#', 'base' => $base, diff --git a/src/IDF/templates/idf/issues/base.html b/src/IDF/templates/idf/issues/base.html index 0856f8f..1d40c02 100644 --- a/src/IDF/templates/idf/issues/base.html +++ b/src/IDF/templates/idf/issues/base.html @@ -4,7 +4,7 @@
{trans 'Summary'} | {trans 'Open Issues'} -{if !$user.isAnonymous()} | {trans 'New Issue'} | {trans 'My Issues'} +{if !$user.isAnonymous()} | {trans 'New Issue'} | {trans 'My Issues'} | {trans 'My watch list'}{/if} | diff --git a/src/IDF/templates/idf/issues/summary.html b/src/IDF/templates/idf/issues/summary.html index 61e117a..7a7ccb0 100644 --- a/src/IDF/templates/idf/issues/summary.html +++ b/src/IDF/templates/idf/issues/summary.html @@ -71,7 +71,12 @@
{foreach $ownerStatistics as $key => $value} - +
{$key} + {if !empty($value[2])} + {aurl 'url', 'IDF_Views_Issue::userIssues', array($project.shortname, $value[2], 'owner')} + {$key} + {else}{$key}{/if} + {$value[0]} diff --git a/src/IDF/templates/idf/issues/my-issues.html b/src/IDF/templates/idf/issues/userIssues.html similarity index 74% rename from src/IDF/templates/idf/issues/my-issues.html rename to src/IDF/templates/idf/issues/userIssues.html index 9823cd2..018a642 100644 --- a/src/IDF/templates/idf/issues/my-issues.html +++ b/src/IDF/templates/idf/issues/userIssues.html @@ -8,10 +8,10 @@ {/block} {block context} -{aurl 'owner_url', 'IDF_Views_Issue::myIssues', array($project.shortname, $login, 'owner')} -{aurl 'submit_url', 'IDF_Views_Issue::myIssues', array($project.shortname, $login, 'submit')} -{aurl 'owner_closed_url', 'IDF_Views_Issue::myIssues', array($project.shortname, $login, 'ownerclosed')} -{aurl 'submit_closed_url', 'IDF_Views_Issue::myIssues', array($project.shortname, $login, 'submitclosed')} +{aurl 'owner_url', 'IDF_Views_Issue::userIssues', array($project.shortname, $login, 'owner')} +{aurl 'submit_url', 'IDF_Views_Issue::userIssues', array($project.shortname, $login, 'submit')} +{aurl 'owner_closed_url', 'IDF_Views_Issue::userIssues', array($project.shortname, $login, 'ownerclosed')} +{aurl 'submit_closed_url', 'IDF_Views_Issue::userIssues', array($project.shortname, $login, 'submitclosed')}

{trans 'Submitted issues:'} {$nb_submit} {if $nb_submit_closed}
{blocktrans $nb_submit_closed}See the {$nb_submit_closed} closed.{plural}See the {$nb_submit_closed} closed.{/blocktrans}{/if}

{if $nb_owner > 0} diff --git a/src/IDF/templates/idf/js-hotkeys.html b/src/IDF/templates/idf/js-hotkeys.html index 78ecb37..dc5e2c6 100644 --- a/src/IDF/templates/idf/js-hotkeys.html +++ b/src/IDF/templates/idf/js-hotkeys.html @@ -10,8 +10,8 @@ {if $hasWikiAccess}{hotkey 'Shift+o', 'IDF_Views_Wiki::index', array($project.shortname)}{/if} {if $hasSourceAccess}{hotkey 'Shift+s', 'IDF_Views_Source::treeBase', array($project.shortname, $project.getScmRoot())}{/if} {if $hasIssuesAccess and !$user.isAnonymous()} -{hotkey 'Shift+m', 'IDF_Views_Issue::myIssues', array($project.shortname, $user.login, 'submit')} -{hotkey 'Shift+w', 'IDF_Views_Issue::myIssues', array($project.shortname, $user.login, 'owner')} +{hotkey 'Shift+m', 'IDF_Views_Issue::userIssues', array($project.shortname, $user.login, 'submit')} +{hotkey 'Shift+w', 'IDF_Views_Issue::userIssues', array($project.shortname, $user.login, 'owner')} {/if}{/if} //--> diff --git a/src/IDF/templates/idf/review/base-full.html b/src/IDF/templates/idf/review/base-full.html index 370e056..e013932 100644 --- a/src/IDF/templates/idf/review/base-full.html +++ b/src/IDF/templates/idf/review/base-full.html @@ -4,7 +4,7 @@
{trans 'Open Reviews'} {* -{if !$user.isAnonymous()} | {trans 'New Issue'} | {trans 'My Issues'}{/if} | +{if !$user.isAnonymous()} | {trans 'New Issue'} | {trans 'My Issues'}{/if} |