Merge branch 'feature.issue-links' into develop
This commit is contained in:
@@ -90,37 +90,37 @@ class IDF_Views_Issue
|
||||
$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();
|
||||
$sql_results = $db->select('SELECT idf_issue_id as id FROM '.Pluf::f('db_table_prefix', '').'idf_issue_pluf_user_assoc WHERE pluf_user_id='.$request->user->id);
|
||||
$issue_ids = array(0);
|
||||
foreach ($sql_results as $id) {
|
||||
$issue_ids[] = $id['id'];
|
||||
}
|
||||
}
|
||||
$issue_ids = implode (',', $issue_ids);
|
||||
|
||||
|
||||
// Count open and close issues
|
||||
$sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') 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 ('.$issue_ids.') 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 ('.$issue_ids.') AND status IN ('.implode(', ', $ctags).')', array($prj->id));
|
||||
break;
|
||||
$f_sql = new Pluf_SQL('project=%s AND id IN ('.$issue_ids.') 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 ('.$issue_ids.') AND status IN ('.implode(', ', $otags).')', array($prj->id));
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Paginator to paginate the issues
|
||||
$pag = new Pluf_Paginator(new IDF_Issue());
|
||||
$pag->class = 'recent-issues';
|
||||
@@ -170,17 +170,17 @@ class IDF_Views_Issue
|
||||
}
|
||||
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();
|
||||
$sql_results = $db->select('SELECT idf_issue_id as id FROM '.Pluf::f('db_table_prefix', '').'idf_issue_pluf_user_assoc WHERE pluf_user_id='.$request->user->id);
|
||||
$issue_ids = array(0);
|
||||
foreach ($sql_results as $id) {
|
||||
$issue_ids[] = $id['id'];
|
||||
}
|
||||
}
|
||||
$issue_ids = implode (',', $issue_ids);
|
||||
|
||||
// Count open and close issues
|
||||
@@ -194,16 +194,16 @@ class IDF_Views_Issue
|
||||
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 ('.$issue_ids.') AND status IN ('.implode(', ', $ctags).')', array());
|
||||
break;
|
||||
$f_sql = new Pluf_SQL('id IN ('.$issue_ids.') 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 ('.$issue_ids.') AND status IN ('.implode(', ', $otags).')', array());
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Paginator to paginate the issues
|
||||
$pag = new Pluf_Paginator(new IDF_Issue());
|
||||
$pag->class = 'recent-issues';
|
||||
@@ -345,6 +345,7 @@ class IDF_Views_Issue
|
||||
'form' => $form,
|
||||
'page_title' => $title,
|
||||
'preview' => $preview,
|
||||
'issue' => new IDF_Issue(),
|
||||
),
|
||||
self::autoCompleteArrays($prj)
|
||||
);
|
||||
@@ -403,6 +404,8 @@ class IDF_Views_Issue
|
||||
$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' => 'other_issue ASC'));
|
||||
|
||||
$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));
|
||||
@@ -453,7 +456,7 @@ class IDF_Views_Issue
|
||||
$next_issue = Pluf::factory('IDF_Issue')->getList(array('filter' => $sql_next->gen(),
|
||||
'order' => 'id ASC',
|
||||
'nb' => 1
|
||||
));
|
||||
));
|
||||
$previous_issue_id = (isset($previous_issue[0])) ? $previous_issue[0]->id : 0;
|
||||
$next_issue_id = (isset($next_issue[0])) ? $next_issue[0]->id : 0;
|
||||
|
||||
@@ -470,7 +473,8 @@ class IDF_Views_Issue
|
||||
'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);
|
||||
@@ -643,6 +647,73 @@ class IDF_Views_Issue
|
||||
$request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a JSON string containing completed issue information
|
||||
* based on the queried / partial string
|
||||
*/
|
||||
public $autoCompleteIssueList_precond = array('IDF_Precondition::accessIssues');
|
||||
public function autoCompleteIssueList($request, $match)
|
||||
{
|
||||
$prj = $request->project;
|
||||
$issue_id = !empty($match[2]) ? intval($match[2]) : 0;
|
||||
$query = trim($request->REQUEST['q']);
|
||||
$limit = !empty($request->REQUEST['limit']) ? intval($request->REQUEST['limit']) : 0;
|
||||
$limit = max(10, $limit);
|
||||
|
||||
$issues = array();
|
||||
|
||||
// empty search, return the most recently updated issues
|
||||
if (empty($query)) {
|
||||
$sql = new Pluf_SQL('project=%s', array($prj->id));
|
||||
$tmp = Pluf::factory('IDF_Issue')->getList(array(
|
||||
'filter' => $sql->gen(),
|
||||
'order' => 'modif_dtime DESC'
|
||||
));
|
||||
$issues += $tmp->getArrayCopy();
|
||||
}
|
||||
else {
|
||||
// ID-based search
|
||||
if (is_numeric($query)) {
|
||||
$sql = new Pluf_SQL('project=%s AND id LIKE %s', array($prj->id, $query.'%'));
|
||||
$tmp = Pluf::factory('IDF_Issue')->getList(array(
|
||||
'filter' => $sql->gen(),
|
||||
'order' => 'id ASC'
|
||||
));
|
||||
$issues += $tmp->getArrayCopy();
|
||||
}
|
||||
|
||||
// text-based search
|
||||
$res = new Pluf_Search_ResultSet(
|
||||
IDF_Search::mySearch($query, $prj, 'IDF_Issue')
|
||||
);
|
||||
foreach ($res as $issue)
|
||||
$issues[] = $issue;
|
||||
}
|
||||
|
||||
// Autocomplete from jQuery UI works with JSON, this old one still
|
||||
// expects a parsable string; since we'd need to bump jQuery beyond
|
||||
// 1.2.6 for this to use as well, we're trying to cope with the old format.
|
||||
// see http://www.learningjquery.com/2010/06/autocomplete-migration-guide
|
||||
$out = '';
|
||||
$ids = array();
|
||||
foreach ($issues as $issue)
|
||||
{
|
||||
if ($issue->id == $issue_id)
|
||||
continue;
|
||||
|
||||
if (in_array($issue->id, $ids))
|
||||
continue;
|
||||
|
||||
if (--$limit < 0)
|
||||
break;
|
||||
|
||||
$out .= str_replace('|', '|', $issue->summary) .'|'.$issue->id."\n";
|
||||
$ids[] = $issue->id;
|
||||
}
|
||||
|
||||
return new Pluf_HTTP_Response($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Star/Unstar an issue.
|
||||
*/
|
||||
@@ -715,6 +786,15 @@ class IDF_Views_Issue
|
||||
}
|
||||
$auto['auto_owner'] = substr($auto['auto_owner'], 0, -2);
|
||||
unset($auto['_auto_owner']);
|
||||
// Get issue relations
|
||||
$r = $project->getRelationsFromConfig();
|
||||
$auto['auto_relation_types'] = '';
|
||||
foreach ($r as $rt) {
|
||||
$esc = Pluf_esc($rt);
|
||||
$auto['auto_relation_types'] .= sprintf('{ name: "%s", to: "%s" }, ',
|
||||
$esc, $esc);
|
||||
}
|
||||
$auto['auto_relation_types'] = substr($auto['auto_relation_types'], 0, -2);
|
||||
return $auto;
|
||||
}
|
||||
}
|
||||
|
@@ -38,18 +38,18 @@ class IDF_Views_Project
|
||||
public function logo($request, $match)
|
||||
{
|
||||
$prj = $request->project;
|
||||
|
||||
|
||||
$logo = $prj->getConf()->getVal('logo');
|
||||
if (empty($logo)) {
|
||||
$url = Pluf::f('url_media') . '/idf/img/no_logo.png';
|
||||
return new Pluf_HTTP_Response_Redirect($url);
|
||||
}
|
||||
|
||||
|
||||
$info = IDF_FileUtil::getMimeType($logo);
|
||||
return new Pluf_HTTP_Response_File(Pluf::f('upload_path') . '/' . $prj->shortname . $logo,
|
||||
$info[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Home page of a project.
|
||||
*/
|
||||
@@ -291,12 +291,12 @@ class IDF_Views_Project
|
||||
public function admin($request, $match)
|
||||
{
|
||||
$prj = $request->project;
|
||||
$title = sprintf(__('%s Project Summary'), (string) $prj);
|
||||
$extra = array('project' => $prj);
|
||||
$title = sprintf(__('%s Project Summary'), (string) $prj);
|
||||
$extra = array('project' => $prj);
|
||||
if ($request->method == 'POST') {
|
||||
$form = new IDF_Form_ProjectConf(array_merge($request->POST,
|
||||
$request->FILES),
|
||||
$extra);
|
||||
$extra);
|
||||
if ($form->isValid()) {
|
||||
$form->save();
|
||||
$request->user->setMessage(__('The project has been updated.'));
|
||||
@@ -305,9 +305,9 @@ class IDF_Views_Project
|
||||
return new Pluf_HTTP_Response_Redirect($url);
|
||||
}
|
||||
} else {
|
||||
$form = new IDF_Form_ProjectConf($prj->getData(), $extra);
|
||||
$form = new IDF_Form_ProjectConf($prj->getData(), $extra);
|
||||
}
|
||||
|
||||
|
||||
$logo = $prj->getConf()->getVal('logo');
|
||||
return Pluf_Shortcuts_RenderToResponse('idf/admin/summary.html',
|
||||
array(
|
||||
@@ -316,7 +316,7 @@ class IDF_Views_Project
|
||||
'project' => $prj,
|
||||
'logo' => $logo,
|
||||
),
|
||||
$request);
|
||||
$request);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,7 +344,8 @@ class IDF_Views_Project
|
||||
$params = array();
|
||||
$keys = array('labels_issue_template',
|
||||
'labels_issue_open', 'labels_issue_closed',
|
||||
'labels_issue_predefined', 'labels_issue_one_max');
|
||||
'labels_issue_predefined', 'labels_issue_one_max',
|
||||
'issue_relations');
|
||||
foreach ($keys as $key) {
|
||||
$_val = $conf->getVal($key, false);
|
||||
if ($_val !== false) {
|
||||
|
Reference in New Issue
Block a user