2008-07-25 08:26:05 +00:00
|
|
|
<?php
|
|
|
|
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# This file is part of InDefero, an open source project management application.
|
|
|
|
# Copyright (C) 2008 Céondo Ltd and contributors.
|
|
|
|
#
|
|
|
|
# InDefero is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# InDefero is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
#
|
|
|
|
# ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
|
|
|
|
Pluf::loadFunction('Pluf_Shortcuts_RenderToResponse');
|
|
|
|
Pluf::loadFunction('Pluf_Shortcuts_GetObjectOr404');
|
|
|
|
Pluf::loadFunction('Pluf_Shortcuts_GetFormForModel');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Project's views.
|
|
|
|
*/
|
|
|
|
class IDF_Views_Project
|
|
|
|
{
|
2008-07-29 19:18:02 +00:00
|
|
|
/**
|
|
|
|
* Home page of a project.
|
|
|
|
*/
|
2008-11-21 12:19:02 +00:00
|
|
|
public $home_precond = array('IDF_Precondition::baseAccess');
|
2008-07-29 19:18:02 +00:00
|
|
|
public function home($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
|
|
|
$team = $prj->getMembershipData();
|
|
|
|
$title = (string) $prj;
|
2008-08-07 13:35:03 +00:00
|
|
|
$downloads = array();
|
|
|
|
if ($request->rights['hasDownloadsAccess']) {
|
|
|
|
$tags = IDF_Views_Download::getDownloadTags($prj);
|
|
|
|
// the first tag is the featured, the last is the deprecated.
|
2010-04-26 22:02:47 +00:00
|
|
|
$downloads = $tags[0]->get_idf_upload_list();
|
2008-08-07 13:35:03 +00:00
|
|
|
}
|
2008-11-23 13:51:47 +00:00
|
|
|
$pages = array();
|
|
|
|
if ($request->rights['hasWikiAccess']) {
|
|
|
|
$tags = IDF_Views_Wiki::getWikiTags($prj);
|
2010-04-26 22:02:47 +00:00
|
|
|
$pages = $tags[0]->get_idf_wikipage_list();
|
2008-11-23 13:51:47 +00:00
|
|
|
}
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/project/home.html',
|
2008-07-29 19:18:02 +00:00
|
|
|
array(
|
|
|
|
'page_title' => $title,
|
|
|
|
'team' => $team,
|
2008-08-05 18:33:43 +00:00
|
|
|
'downloads' => $downloads,
|
2008-11-23 13:51:47 +00:00
|
|
|
'pages' => $pages,
|
2008-07-29 19:18:02 +00:00
|
|
|
),
|
|
|
|
$request);
|
|
|
|
}
|
|
|
|
|
2010-10-09 11:53:01 +00:00
|
|
|
/**
|
|
|
|
* Returns an associative array with available model filters
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private static function getAvailableModelFilters()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'all' => __('All Updates'),
|
|
|
|
'commits' => __('Commits'),
|
|
|
|
'issues' => __('Issues and Comments'),
|
|
|
|
'downloads' => __('Downloads'),
|
|
|
|
'documents' => __('Documents'),
|
|
|
|
'reviews' => __('Reviews and Patches'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of model classes for which the current user
|
|
|
|
* has rights and which should be used according to his filter
|
|
|
|
*
|
|
|
|
* @param object $request
|
|
|
|
* @param string $model_filter
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private static function determineModelClasses($request, $model_filter = 'all')
|
|
|
|
{
|
|
|
|
$classes = array();
|
|
|
|
if (true === IDF_Precondition::accessSource($request) &&
|
|
|
|
($model_filter == 'all' || $model_filter == 'commits')) {
|
|
|
|
$classes[] = '\'IDF_Commit\'';
|
|
|
|
// FIXME: this looks like a hack...
|
|
|
|
IDF_Scm::syncTimeline($request->project);
|
|
|
|
}
|
|
|
|
if (true === IDF_Precondition::accessIssues($request) &&
|
|
|
|
($model_filter == 'all' || $model_filter == 'issues')) {
|
|
|
|
$classes[] = '\'IDF_Issue\'';
|
|
|
|
$classes[] = '\'IDF_IssueComment\'';
|
|
|
|
}
|
|
|
|
if (true === IDF_Precondition::accessDownloads($request) &&
|
|
|
|
($model_filter == 'all' || $model_filter == 'downloads')) {
|
|
|
|
$classes[] = '\'IDF_Upload\'';
|
|
|
|
}
|
|
|
|
if (true === IDF_Precondition::accessWiki($request) &&
|
|
|
|
($model_filter == 'all' || $model_filter == 'documents')) {
|
|
|
|
$classes[] = '\'IDF_WikiPage\'';
|
|
|
|
$classes[] = '\'IDF_WikiRevision\'';
|
|
|
|
}
|
|
|
|
if (true === IDF_Precondition::accessReview($request) &&
|
|
|
|
($model_filter == 'all' || $model_filter == 'reviews')) {
|
|
|
|
$classes[] = '\'IDF_Review_Comment\'';
|
|
|
|
$classes[] = '\'IDF_Review_Patch\'';
|
|
|
|
}
|
|
|
|
if (count($classes) == 0) {
|
|
|
|
$classes[] = '\'IDF_Dummy\'';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $classes;
|
|
|
|
}
|
|
|
|
|
2008-11-14 14:41:51 +00:00
|
|
|
/**
|
|
|
|
* Timeline of the project.
|
|
|
|
*/
|
2008-11-21 12:19:02 +00:00
|
|
|
public $timeline_precond = array('IDF_Precondition::baseAccess');
|
2008-11-14 14:41:51 +00:00
|
|
|
public function timeline($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
2010-10-09 11:53:01 +00:00
|
|
|
|
|
|
|
$model_filter = @$match[2];
|
|
|
|
$all_model_filters = self::getAvailableModelFilters();
|
|
|
|
if (!array_key_exists($model_filter, $all_model_filters)) {
|
|
|
|
$model_filter = 'all';
|
|
|
|
}
|
|
|
|
$title = (string)$prj . ' ' . $all_model_filters[$model_filter];
|
2008-11-15 10:31:43 +00:00
|
|
|
|
|
|
|
$pag = new IDF_Timeline_Paginator(new IDF_Timeline());
|
|
|
|
$pag->class = 'recent-issues';
|
|
|
|
$pag->item_extra_props = array('request' => $request);
|
2008-11-15 10:47:09 +00:00
|
|
|
$pag->summary = __('This table shows the project updates.');
|
2010-10-09 11:53:01 +00:00
|
|
|
|
|
|
|
$classes = self::determineModelClasses($request, $model_filter);
|
|
|
|
$sql = sprintf('model_class IN (%s)', implode(', ', $classes));
|
2010-04-26 22:02:47 +00:00
|
|
|
$pag->forced_where = new Pluf_SQL('project=%s AND '.$sql,
|
2008-11-15 10:47:09 +00:00
|
|
|
array($prj->id));
|
2008-11-15 10:31:43 +00:00
|
|
|
$pag->sort_order = array('creation_dtime', 'ASC');
|
|
|
|
$pag->sort_reverse_order = array('creation_dtime');
|
|
|
|
$pag->action = array('IDF_Views_Project::timeline', array($prj->shortname));
|
|
|
|
$list_display = array(
|
|
|
|
'creation_dtime' => __('Age'),
|
|
|
|
'id' => __('Change'),
|
|
|
|
);
|
|
|
|
$pag->configure($list_display, array(), array('creation_dtime'));
|
|
|
|
$pag->items_per_page = 20;
|
|
|
|
$pag->no_results_text = __('No changes were found.');
|
|
|
|
$pag->setFromRequest($request);
|
2010-10-09 11:53:01 +00:00
|
|
|
|
2009-10-08 11:27:15 +00:00
|
|
|
if (!$request->user->isAnonymous() and $prj->isRestricted()) {
|
2008-12-03 14:00:47 +00:00
|
|
|
$feedurl = Pluf_HTTP_URL_urlForView('idf_project_timeline_feed_auth',
|
2010-04-26 22:02:47 +00:00
|
|
|
array($prj->shortname,
|
2010-10-09 11:53:01 +00:00
|
|
|
$model_filter,
|
2008-12-03 14:00:47 +00:00
|
|
|
IDF_Precondition::genFeedToken($prj, $request->user)));
|
|
|
|
} else {
|
|
|
|
$feedurl = Pluf_HTTP_URL_urlForView('idf_project_timeline_feed',
|
2010-10-09 11:53:01 +00:00
|
|
|
array($prj->shortname, $model_filter));
|
2008-12-03 14:00:47 +00:00
|
|
|
}
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/project/timeline.html',
|
2008-11-14 14:41:51 +00:00
|
|
|
array(
|
|
|
|
'page_title' => $title,
|
2008-12-03 14:00:47 +00:00
|
|
|
'feedurl' => $feedurl,
|
2008-11-15 10:31:43 +00:00
|
|
|
'timeline' => $pag,
|
2010-10-09 11:53:01 +00:00
|
|
|
'model_filter' => $model_filter,
|
|
|
|
'all_model_filters' => $all_model_filters,
|
2008-11-14 14:41:51 +00:00
|
|
|
),
|
|
|
|
$request);
|
2008-12-03 14:00:47 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Timeline feed.
|
|
|
|
*
|
|
|
|
* A custom view to have a bit more control on the way to handle
|
|
|
|
* it and optimize the output.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public $timelineFeed_precond = array('IDF_Precondition::feedSetUser',
|
|
|
|
'IDF_Precondition::baseAccess');
|
|
|
|
public function timelineFeed($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
2010-10-09 11:53:01 +00:00
|
|
|
$model_filter = @$match[2];
|
|
|
|
|
|
|
|
$model_filter = @$match[2];
|
|
|
|
$all_model_filters = self::getAvailableModelFilters();
|
|
|
|
if (!array_key_exists($model_filter, $all_model_filters)) {
|
|
|
|
$model_filter = 'all';
|
|
|
|
}
|
|
|
|
$title = $all_model_filters[$model_filter];
|
|
|
|
|
|
|
|
$classes = self::determineModelClasses($request, $model_filter);
|
|
|
|
$sqls = sprintf('model_class IN (%s)', implode(', ', $classes));
|
2008-12-03 14:00:47 +00:00
|
|
|
$sql = new Pluf_SQL('project=%s AND '.$sqls, array($prj->id));
|
|
|
|
$params = array(
|
|
|
|
'filter' => $sql->gen(),
|
|
|
|
'order' => 'creation_dtime DESC',
|
2009-10-09 07:22:36 +00:00
|
|
|
'nb' => 20,
|
2008-12-03 14:00:47 +00:00
|
|
|
);
|
|
|
|
$items = Pluf::factory('IDF_Timeline')->getList($params);
|
2010-04-26 22:02:47 +00:00
|
|
|
$set = new Pluf_Model_Set($items,
|
2008-12-03 14:00:47 +00:00
|
|
|
array('public_dtime' => 'public_dtime'));
|
|
|
|
$out = array();
|
|
|
|
foreach ($set as $item) {
|
2009-10-09 07:22:36 +00:00
|
|
|
if ($item->id) {
|
|
|
|
$out[] = $item->feedFragment($request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($items->count() > 0) {
|
|
|
|
$date = Pluf_Date::gmDateToGmString($items[0]->creation_dtime);
|
|
|
|
} else {
|
|
|
|
$date = gmdate('c');
|
2008-12-03 14:00:47 +00:00
|
|
|
}
|
|
|
|
$out = Pluf_Template::markSafe(implode("\n", $out));
|
|
|
|
$tmpl = new Pluf_Template('idf/index.atom');
|
|
|
|
$feedurl = Pluf::f('url_base').Pluf::f('idf_base').$request->query;
|
|
|
|
$viewurl = Pluf_HTTP_URL_urlForView('IDF_Views_Project::timeline',
|
|
|
|
array($prj->shortname));
|
2010-04-26 22:02:47 +00:00
|
|
|
$context = new Pluf_Template_Context_Request($request,
|
2008-12-03 14:00:47 +00:00
|
|
|
array('body' => $out,
|
2009-10-09 07:22:36 +00:00
|
|
|
'date' => $date,
|
2008-12-03 14:00:47 +00:00
|
|
|
'title' => $title,
|
|
|
|
'feedurl' => $feedurl,
|
|
|
|
'viewurl' => $viewurl));
|
|
|
|
return new Pluf_HTTP_Response('<?xml version="1.0" encoding="utf-8"?>'
|
|
|
|
."\n".$tmpl->render($context),
|
|
|
|
'application/atom+xml; charset=utf-8');
|
2008-11-14 14:41:51 +00:00
|
|
|
}
|
|
|
|
|
2008-07-29 19:18:02 +00:00
|
|
|
|
2008-07-25 08:26:05 +00:00
|
|
|
/**
|
|
|
|
* Administrate the summary of a project.
|
|
|
|
*/
|
|
|
|
public $admin_precond = array('IDF_Precondition::projectOwner');
|
|
|
|
public function admin($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
|
|
|
$title = sprintf(__('%s Project Summary'), (string) $prj);
|
2008-12-02 12:22:01 +00:00
|
|
|
$form_fields = array('fields'=> array('name', 'shortdesc',
|
|
|
|
'description'));
|
2008-07-25 08:26:05 +00:00
|
|
|
if ($request->method == 'POST') {
|
|
|
|
$form = Pluf_Shortcuts_GetFormForModel($prj, $request->POST,
|
|
|
|
$form_fields);
|
|
|
|
if ($form->isValid()) {
|
|
|
|
$prj = $form->save();
|
|
|
|
$request->user->setMessage(__('The project has been updated.'));
|
2010-04-26 22:02:47 +00:00
|
|
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::admin',
|
2008-07-25 08:26:05 +00:00
|
|
|
array($prj->shortname));
|
|
|
|
return new Pluf_HTTP_Response_Redirect($url);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$form = Pluf_Shortcuts_GetFormForModel($prj, $prj->getData(),
|
|
|
|
$form_fields);
|
|
|
|
}
|
2008-12-02 12:22:01 +00:00
|
|
|
$form->fields['description']->widget->attrs['cols'] = 68;
|
|
|
|
$form->fields['description']->widget->attrs['rows'] = 26;
|
|
|
|
$form->fields['shortdesc']->widget->attrs['size'] = 67;
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/admin/summary.html',
|
2008-07-25 08:26:05 +00:00
|
|
|
array(
|
|
|
|
'page_title' => $title,
|
|
|
|
'form' => $form,
|
|
|
|
),
|
|
|
|
$request);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Administrate the issue tracking of a project.
|
|
|
|
*/
|
2008-08-03 22:42:05 +00:00
|
|
|
public $adminIssues_precond = array('IDF_Precondition::projectOwner');
|
2008-07-25 08:26:05 +00:00
|
|
|
public function adminIssues($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
|
|
|
$title = sprintf(__('%s Issue Tracking Configuration'), (string) $prj);
|
|
|
|
$conf = new IDF_Conf();
|
|
|
|
$conf->setProject($prj);
|
|
|
|
if ($request->method == 'POST') {
|
|
|
|
$form = new IDF_Form_IssueTrackingConf($request->POST);
|
|
|
|
if ($form->isValid()) {
|
|
|
|
foreach ($form->cleaned_data as $key=>$val) {
|
|
|
|
$conf->setVal($key, $val);
|
|
|
|
}
|
|
|
|
$request->user->setMessage(__('The issue tracking configuration has been saved.'));
|
|
|
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminIssues',
|
|
|
|
array($prj->shortname));
|
|
|
|
return new Pluf_HTTP_Response_Redirect($url);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$params = array();
|
2010-10-09 10:40:30 +00:00
|
|
|
$keys = array('labels_issue_template',
|
|
|
|
'labels_issue_open', 'labels_issue_closed',
|
2008-07-25 08:26:05 +00:00
|
|
|
'labels_issue_predefined', 'labels_issue_one_max');
|
|
|
|
foreach ($keys as $key) {
|
|
|
|
$_val = $conf->getVal($key, false);
|
|
|
|
if ($_val !== false) {
|
|
|
|
$params[$key] = $_val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count($params) == 0) {
|
|
|
|
$params = null; //Nothing in the db, so new form.
|
|
|
|
}
|
|
|
|
$form = new IDF_Form_IssueTrackingConf($params);
|
|
|
|
}
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/admin/issue-tracking.html',
|
2008-07-25 08:26:05 +00:00
|
|
|
array(
|
|
|
|
'page_title' => $title,
|
|
|
|
'form' => $form,
|
|
|
|
),
|
|
|
|
$request);
|
|
|
|
}
|
|
|
|
|
2008-08-03 22:42:05 +00:00
|
|
|
/**
|
|
|
|
* Administrate the downloads of a project.
|
|
|
|
*/
|
|
|
|
public $adminDownloads_precond = array('IDF_Precondition::projectOwner');
|
|
|
|
public function adminDownloads($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
|
|
|
$title = sprintf(__('%s Downloads Configuration'), (string) $prj);
|
|
|
|
$conf = new IDF_Conf();
|
|
|
|
$conf->setProject($prj);
|
|
|
|
if ($request->method == 'POST') {
|
|
|
|
$form = new IDF_Form_UploadConf($request->POST);
|
|
|
|
if ($form->isValid()) {
|
|
|
|
foreach ($form->cleaned_data as $key=>$val) {
|
|
|
|
$conf->setVal($key, $val);
|
|
|
|
}
|
|
|
|
$request->user->setMessage(__('The downloads configuration has been saved.'));
|
|
|
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminDownloads',
|
|
|
|
array($prj->shortname));
|
|
|
|
return new Pluf_HTTP_Response_Redirect($url);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$params = array();
|
|
|
|
$keys = array('labels_download_predefined', 'labels_download_one_max');
|
|
|
|
foreach ($keys as $key) {
|
|
|
|
$_val = $conf->getVal($key, false);
|
|
|
|
if ($_val !== false) {
|
|
|
|
$params[$key] = $_val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count($params) == 0) {
|
|
|
|
$params = null; //Nothing in the db, so new form.
|
|
|
|
}
|
|
|
|
$form = new IDF_Form_UploadConf($params);
|
|
|
|
}
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/admin/downloads.html',
|
2008-08-03 22:42:05 +00:00
|
|
|
array(
|
|
|
|
'page_title' => $title,
|
|
|
|
'form' => $form,
|
|
|
|
),
|
|
|
|
$request);
|
|
|
|
}
|
|
|
|
|
2008-11-22 22:51:23 +00:00
|
|
|
/**
|
|
|
|
* Administrate the information pages of a project.
|
|
|
|
*/
|
|
|
|
public $adminWiki_precond = array('IDF_Precondition::projectOwner');
|
|
|
|
public function adminWiki($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
|
|
|
$title = sprintf(__('%s Documentation Configuration'), (string) $prj);
|
|
|
|
$conf = new IDF_Conf();
|
|
|
|
$conf->setProject($prj);
|
|
|
|
if ($request->method == 'POST') {
|
|
|
|
$form = new IDF_Form_WikiConf($request->POST);
|
|
|
|
if ($form->isValid()) {
|
|
|
|
foreach ($form->cleaned_data as $key=>$val) {
|
|
|
|
$conf->setVal($key, $val);
|
|
|
|
}
|
|
|
|
$request->user->setMessage(__('The documentation configuration has been saved.'));
|
2009-05-07 12:54:42 +00:00
|
|
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminWiki',
|
2008-11-22 22:51:23 +00:00
|
|
|
array($prj->shortname));
|
|
|
|
return new Pluf_HTTP_Response_Redirect($url);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$params = array();
|
|
|
|
$keys = array('labels_wiki_predefined', 'labels_wiki_one_max');
|
|
|
|
foreach ($keys as $key) {
|
|
|
|
$_val = $conf->getVal($key, false);
|
|
|
|
if ($_val !== false) {
|
|
|
|
$params[$key] = $_val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count($params) == 0) {
|
|
|
|
$params = null; //Nothing in the db, so new form.
|
|
|
|
}
|
|
|
|
$form = new IDF_Form_WikiConf($params);
|
|
|
|
}
|
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/admin/wiki.html',
|
|
|
|
array(
|
|
|
|
'page_title' => $title,
|
|
|
|
'form' => $form,
|
|
|
|
),
|
|
|
|
$request);
|
|
|
|
}
|
|
|
|
|
2008-07-25 08:26:05 +00:00
|
|
|
/**
|
|
|
|
* Administrate the members of a project.
|
|
|
|
*/
|
|
|
|
public $adminMembers_precond = array('IDF_Precondition::projectOwner');
|
|
|
|
public function adminMembers($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
|
|
|
$title = sprintf(__('%s Project Members'), (string) $prj);
|
|
|
|
$params = array(
|
|
|
|
'project' => $prj,
|
|
|
|
'user' => $request->user,
|
|
|
|
);
|
|
|
|
if ($request->method == 'POST') {
|
|
|
|
$form = new IDF_Form_MembersConf($request->POST, $params);
|
|
|
|
if ($form->isValid()) {
|
|
|
|
$form->save();
|
|
|
|
$request->user->setMessage(__('The project membership has been saved.'));
|
|
|
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminMembers',
|
|
|
|
array($prj->shortname));
|
|
|
|
return new Pluf_HTTP_Response_Redirect($url);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$form = new IDF_Form_MembersConf($prj->getMembershipData('string'), $params);
|
|
|
|
}
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/admin/members.html',
|
2008-07-25 08:26:05 +00:00
|
|
|
array(
|
|
|
|
'page_title' => $title,
|
|
|
|
'form' => $form,
|
|
|
|
),
|
|
|
|
$request);
|
|
|
|
}
|
2008-08-07 13:35:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Administrate the access rights to the tabs.
|
|
|
|
*/
|
|
|
|
public $adminTabs_precond = array('IDF_Precondition::projectOwner');
|
|
|
|
public function adminTabs($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
|
|
|
$title = sprintf(__('%s Tabs Access Rights'), (string) $prj);
|
|
|
|
$extra = array(
|
2008-11-21 12:19:02 +00:00
|
|
|
'project' => $prj,
|
2008-08-07 13:35:03 +00:00
|
|
|
'conf' => $request->conf,
|
|
|
|
);
|
|
|
|
if ($request->method == 'POST') {
|
|
|
|
$form = new IDF_Form_TabsConf($request->POST, $extra);
|
|
|
|
if ($form->isValid()) {
|
|
|
|
foreach ($form->cleaned_data as $key=>$val) {
|
2009-01-06 21:04:48 +00:00
|
|
|
if (!in_array($key, array('private_project', 'authorized_users'))) {
|
|
|
|
$request->conf->setVal($key, $val);
|
|
|
|
}
|
2008-08-07 13:35:03 +00:00
|
|
|
}
|
2008-11-21 12:19:02 +00:00
|
|
|
$form->save(); // Save the authorized users.
|
2008-08-07 13:35:03 +00:00
|
|
|
$request->user->setMessage(__('The project tabs access rights have been saved.'));
|
|
|
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminTabs',
|
|
|
|
array($prj->shortname));
|
|
|
|
return new Pluf_HTTP_Response_Redirect($url);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$params = array();
|
|
|
|
$keys = array('downloads_access_rights', 'source_access_rights',
|
2010-04-26 22:02:47 +00:00
|
|
|
'issues_access_rights', 'review_access_rights',
|
2009-01-25 09:32:34 +00:00
|
|
|
'wiki_access_rights',
|
|
|
|
'downloads_notification_email',
|
|
|
|
'review_notification_email',
|
|
|
|
'wiki_notification_email',
|
|
|
|
'source_notification_email',
|
|
|
|
'issues_notification_email');
|
2008-08-07 13:35:03 +00:00
|
|
|
foreach ($keys as $key) {
|
|
|
|
$_val = $request->conf->getVal($key, false);
|
|
|
|
if ($_val !== false) {
|
|
|
|
$params[$key] = $_val;
|
|
|
|
}
|
|
|
|
}
|
2008-11-21 12:19:02 +00:00
|
|
|
// Add the authorized users.
|
|
|
|
$md = $prj->getMembershipData('string');
|
|
|
|
$params['authorized_users'] = $md['authorized'];
|
2009-01-06 21:04:48 +00:00
|
|
|
$params['private_project'] = $prj->private;
|
2008-08-07 13:35:03 +00:00
|
|
|
$form = new IDF_Form_TabsConf($params, $extra);
|
|
|
|
}
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/admin/tabs.html',
|
2008-08-07 13:35:03 +00:00
|
|
|
array(
|
|
|
|
'page_title' => $title,
|
|
|
|
'form' => $form,
|
2009-01-25 09:58:24 +00:00
|
|
|
'from_email' => Pluf::f('from_email'),
|
2008-08-07 13:35:03 +00:00
|
|
|
),
|
|
|
|
$request);
|
|
|
|
}
|
2008-09-02 14:45:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Administrate the source control.
|
2010-05-10 08:11:27 +00:00
|
|
|
*
|
|
|
|
* There, the login/password of the subversion remote repo can be
|
|
|
|
* change together with the webhook url.
|
2008-09-02 14:45:49 +00:00
|
|
|
*/
|
|
|
|
public $adminSource_precond = array('IDF_Precondition::projectOwner');
|
|
|
|
public function adminSource($request, $match)
|
|
|
|
{
|
|
|
|
$prj = $request->project;
|
|
|
|
$title = sprintf(__('%s Source'), (string) $prj);
|
2010-05-10 08:11:27 +00:00
|
|
|
|
|
|
|
$remote_svn = ($request->conf->getVal('scm') == 'svn' and
|
|
|
|
strlen($request->conf->getVal('svn_remote_url')) > 0);
|
|
|
|
$extra = array(
|
|
|
|
'conf' => $request->conf,
|
|
|
|
'remote_svn' => $remote_svn,
|
|
|
|
);
|
|
|
|
if ($request->method == 'POST') {
|
|
|
|
$form = new IDF_Form_SourceConf($request->POST, $extra);
|
|
|
|
if ($form->isValid()) {
|
|
|
|
foreach ($form->cleaned_data as $key=>$val) {
|
|
|
|
$request->conf->setVal($key, $val);
|
2008-09-02 14:45:49 +00:00
|
|
|
}
|
2010-05-10 08:11:27 +00:00
|
|
|
$request->user->setMessage(__('The project source configuration has been saved.'));
|
|
|
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminSource',
|
|
|
|
array($prj->shortname));
|
|
|
|
return new Pluf_HTTP_Response_Redirect($url);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$params = array();
|
|
|
|
foreach (array('svn_username', 'svn_password', 'webhook_url') as $key) {
|
|
|
|
$_val = $request->conf->getVal($key, false);
|
|
|
|
if ($_val !== false) {
|
|
|
|
$params[$key] = $_val;
|
2008-11-30 23:36:27 +00:00
|
|
|
}
|
2008-09-02 14:45:49 +00:00
|
|
|
}
|
2010-05-10 08:11:27 +00:00
|
|
|
if (count($params) == 0) {
|
|
|
|
$params = null; //Nothing in the db, so new form.
|
|
|
|
}
|
|
|
|
$form = new IDF_Form_SourceConf($params, $extra);
|
2008-09-02 14:45:49 +00:00
|
|
|
}
|
2008-11-30 23:36:27 +00:00
|
|
|
$scm = $request->conf->getVal('scm', 'git');
|
|
|
|
$options = array(
|
|
|
|
'git' => __('git'),
|
|
|
|
'svn' => __('Subversion'),
|
|
|
|
'mercurial' => __('mercurial'),
|
2010-04-26 22:02:47 +00:00
|
|
|
'mtn' => __('monotone'),
|
2008-11-30 23:36:27 +00:00
|
|
|
);
|
|
|
|
$repository_type = $options[$scm];
|
2008-11-18 08:15:02 +00:00
|
|
|
return Pluf_Shortcuts_RenderToResponse('idf/admin/source.html',
|
2008-09-02 14:45:49 +00:00
|
|
|
array(
|
2008-11-30 23:36:27 +00:00
|
|
|
'remote_svn' => $remote_svn,
|
|
|
|
'repository_access' => $prj->getRemoteAccessUrl(),
|
|
|
|
'repository_type' => $repository_type,
|
2009-06-19 15:31:45 +00:00
|
|
|
'repository_size' => $prj->getRepositorySize(),
|
2008-09-02 14:45:49 +00:00
|
|
|
'page_title' => $title,
|
|
|
|
'form' => $form,
|
2010-05-10 08:11:27 +00:00
|
|
|
'hookkey' => $prj->getPostCommitHookKey(),
|
2008-09-02 14:45:49 +00:00
|
|
|
),
|
|
|
|
$request);
|
|
|
|
}
|
2010-10-09 10:40:30 +00:00
|
|
|
}
|