| src/IDF/Form/Admin/ProjectCreate.php |
| 1 | <?php |
| 2 | /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 3 | /* |
| 4 | # ***** BEGIN LICENSE BLOCK ***** |
| 5 | # This file is part of InDefero, an open source project management application. |
| 6 | # Copyright (C) 2008 Céondo Ltd and contributors. |
| 7 | # |
| 8 | # InDefero is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | # InDefero is distributed in the hope that it will be useful, |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | # GNU General Public License for more details. |
| 17 | # |
| 18 | # You should have received a copy of the GNU General Public License |
| 19 | # along with this program; if not, write to the Free Software |
| 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | # |
| 22 | # ***** END LICENSE BLOCK ***** */ |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * Create a project. |
| 27 | * |
| 28 | * A kind of merge of the member configuration, overview and the |
| 29 | * former source tab. |
| 30 | * |
| 31 | */ |
| 32 | class IDF_Form_Admin_ProjectCreate extends Pluf_Form |
| 33 | { |
| 34 | public function initFields($extra=array()) |
| 35 | { |
| 36 | $choices = array(); |
| 37 | $options = array( |
| 38 | 'git' => __('git'), |
| 39 | 'svn' => __('Subversion'), |
| 40 | 'mercurial' => __('mercurial'), |
| 41 | ); |
| 42 | foreach (Pluf::f('allowed_scm', array()) as $key => $class) { |
| 43 | $choices[$options[$key]] = $key; |
| 44 | } |
| 45 | |
| 46 | $this->fields['name'] = new Pluf_Form_Field_Varchar( |
| 47 | array('required' => true, |
| 48 | 'label' => __('Name'), |
| 49 | 'initial' => '', |
| 50 | )); |
| 51 | |
| 52 | $this->fields['shortname'] = new Pluf_Form_Field_Varchar( |
| 53 | array('required' => true, |
| 54 | 'label' => __('Shortname'), |
| 55 | 'initial' => 'myproject', |
| 56 | 'help_text' => __('It must be unique for each project and composed only of letters and digits.'), |
| 57 | )); |
| 58 | |
| 59 | $this->fields['scm'] = new Pluf_Form_Field_Varchar( |
| 60 | array('required' => true, |
| 61 | 'label' => __('Repository type'), |
| 62 | 'initial' => 'git', |
| 63 | 'widget_attrs' => array('choices' => $choices), |
| 64 | 'widget' => 'Pluf_Form_Widget_SelectInput', |
| 65 | )); |
| 66 | |
| 67 | $this->fields['svn_remote_url'] = new Pluf_Form_Field_Varchar( |
| 68 | array('required' => false, |
| 69 | 'label' => __('Remote Subversion repository'), |
| 70 | 'initial' => '', |
| 71 | 'widget_attrs' => array('size' => '30'), |
| 72 | )); |
| 73 | |
| 74 | $this->fields['svn_username'] = new Pluf_Form_Field_Varchar( |
| 75 | array('required' => false, |
| 76 | 'label' => __('Repository username'), |
| 77 | 'initial' => '', |
| 78 | 'widget_attrs' => array('size' => '15'), |
| 79 | )); |
| 80 | |
| 81 | $this->fields['svn_password'] = new Pluf_Form_Field_Varchar( |
| 82 | array('required' => false, |
| 83 | 'label' => __('Repository password'), |
| 84 | 'initial' => '', |
| 85 | 'widget' => 'Pluf_Form_Widget_PasswordInput', |
| 86 | )); |
| 87 | |
| 88 | $this->fields['owners'] = new Pluf_Form_Field_Varchar( |
| 89 | array('required' => false, |
| 90 | 'label' => __('Project owners'), |
| 91 | 'initial' => $extra['user']->login, |
| 92 | 'widget' => 'Pluf_Form_Widget_TextareaInput', |
| 93 | 'widget_attrs' => array('rows' => 5, |
| 94 | 'cols' => 40), |
| 95 | )); |
| 96 | |
| 97 | $this->fields['members'] = new Pluf_Form_Field_Varchar( |
| 98 | array('required' => false, |
| 99 | 'label' => __('Project members'), |
| 100 | 'initial' => '', |
| 101 | 'widget_attrs' => array('rows' => 7, |
| 102 | 'cols' => 40), |
| 103 | 'widget' => 'Pluf_Form_Widget_TextareaInput', |
| 104 | )); |
| 105 | } |
| 106 | |
| 107 | public function clean_svn_remote_url() |
| 108 | { |
| 109 | $url = trim($this->cleaned_data['svn_remote_url']); |
| 110 | if (strlen($url) == 0) return $url; |
| 111 | // we accept only starting with http(s):// to avoid people |
| 112 | // trying to access the local filesystem. |
| 113 | if (!preg_match('#^(http|https)://#', $url)) { |
| 114 | throw new Pluf_Form_Invalid(__('Only a remote repository available throught http or https are allowed. For example "http://somewhere.com/svn/trunk".')); |
| 115 | } |
| 116 | return $url; |
| 117 | } |
| 118 | |
| 119 | public function clean_shortname() |
| 120 | { |
| 121 | $shortname = $this->cleaned_data['shortname']; |
| 122 | if (preg_match('/[^A-Za-z0-9]/', $shortname)) { |
| 123 | throw new Pluf_Form_Invalid(__('This shortname contains illegal characters, please use only letters and digits.')); |
| 124 | } |
| 125 | $sql = new Pluf_SQL('shortname=%s', array($shortname)); |
| 126 | $l = Pluf::factory('IDF_Project')->getList(array('filter'=>$sql->gen())); |
| 127 | if ($l->count() > 0) { |
| 128 | throw new Pluf_Form_Invalid(__('This shortname is already used. Please select another one.')); |
| 129 | } |
| 130 | return $shortname; |
| 131 | } |
| 132 | |
| 133 | public function clean() |
| 134 | { |
| 135 | if ($this->cleaned_data['scm'] != 'svn') { |
| 136 | foreach (array('svn_remote_url', 'svn_username', 'svn_password') |
| 137 | as $key) { |
| 138 | $this->cleaned_data[$key] = ''; |
| 139 | } |
| 140 | } |
| 141 | return $this->cleaned_data; |
| 142 | } |
| 143 | |
| 144 | public function save($commit=true) |
| 145 | { |
| 146 | if (!$this->isValid()) { |
| 147 | throw new Exception(__('Cannot save the model from an invalid form.')); |
| 148 | } |
| 149 | $project = new IDF_Project(); |
| 150 | $project->name = $this->cleaned_data['name']; |
| 151 | $project->shortname = $this->cleaned_data['shortname']; |
| 152 | $project->description = __('Write your project description here.'); |
| 153 | $project->create(); |
| 154 | $conf = new IDF_Conf(); |
| 155 | $conf->setProject($project); |
| 156 | $keys = array('scm', 'svn_remote_url', |
| 157 | 'svn_username', 'svn_password'); |
| 158 | foreach ($keys as $key) { |
| 159 | $conf->setVal($key, $this->cleaned_data[$key]); |
| 160 | } |
| 161 | $project->created(); |
| 162 | IDF_Form_MembersConf::updateMemberships($project, |
| 163 | $this->cleaned_data); |
| 164 | $project->membershipsUpdated(); |
| 165 | return $project; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | |
| src/IDF/Form/Admin/ProjectUpdate.php |
| 1 | <?php |
| 2 | /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 3 | /* |
| 4 | # ***** BEGIN LICENSE BLOCK ***** |
| 5 | # This file is part of InDefero, an open source project management application. |
| 6 | # Copyright (C) 2008 Céondo Ltd and contributors. |
| 7 | # |
| 8 | # InDefero is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | # InDefero is distributed in the hope that it will be useful, |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | # GNU General Public License for more details. |
| 17 | # |
| 18 | # You should have received a copy of the GNU General Public License |
| 19 | # along with this program; if not, write to the Free Software |
| 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | # |
| 22 | # ***** END LICENSE BLOCK ***** */ |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * Update a project. |
| 27 | * |
| 28 | * A kind of merge of the member configuration and overview in the |
| 29 | * project administration area. |
| 30 | * |
| 31 | */ |
| 32 | class IDF_Form_Admin_ProjectUpdate extends Pluf_Form |
| 33 | { |
| 34 | public $project = null; |
| 35 | |
| 36 | public function initFields($extra=array()) |
| 37 | { |
| 38 | $this->project = $extra['project']; |
| 39 | $members = $this->project->getMembershipData('string'); |
| 40 | $this->fields['name'] = new Pluf_Form_Field_Varchar( |
| 41 | array('required' => true, |
| 42 | 'label' => __('Name'), |
| 43 | 'initial' => $this->project->name, |
| 44 | )); |
| 45 | |
| 46 | $this->fields['owners'] = new Pluf_Form_Field_Varchar( |
| 47 | array('required' => false, |
| 48 | 'label' => __('Project owners'), |
| 49 | 'initial' => $members['owners'], |
| 50 | 'widget' => 'Pluf_Form_Widget_TextareaInput', |
| 51 | 'widget_attrs' => array('rows' => 5, |
| 52 | 'cols' => 40), |
| 53 | )); |
| 54 | $this->fields['members'] = new Pluf_Form_Field_Varchar( |
| 55 | array('required' => false, |
| 56 | 'label' => __('Project members'), |
| 57 | 'initial' => $members['members'], |
| 58 | 'widget_attrs' => array('rows' => 7, |
| 59 | 'cols' => 40), |
| 60 | 'widget' => 'Pluf_Form_Widget_TextareaInput', |
| 61 | )); |
| 62 | } |
| 63 | |
| 64 | public function save($commit=true) |
| 65 | { |
| 66 | if (!$this->isValid()) { |
| 67 | throw new Exception(__('Cannot save the model from an invalid form.')); |
| 68 | } |
| 69 | IDF_Form_MembersConf::updateMemberships($this->project, |
| 70 | $this->cleaned_data); |
| 71 | $this->project->membershipsUpdated(); |
| 72 | $this->project->name = $this->cleaned_data['name']; |
| 73 | $this->project->update(); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | |
| src/IDF/Form/MembersConf.php |
| 63 | 63 | if (!$this->isValid()) { |
| 64 | 64 | throw new Exception(__('Cannot save the model from an invalid form.')); |
| 65 | 65 | } |
| 66 | self::updateMemberships($this->project, $this->cleaned_data); |
| 67 | $this->project->membershipsUpdated(); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * The update of the memberships is done in different places. This |
| 72 | * avoids duplicating code. |
| 73 | * |
| 74 | * @param IDF_Project The project |
| 75 | * @param array The new memberships data in 'owners' and 'members' keys |
| 76 | */ |
| 77 | public static function updateMemberships($project, $cleaned_data) |
| 78 | { |
| 66 | 79 | // remove all the permissions |
| 67 | | $cm = $this->project->getMembershipData(); |
| 80 | $cm = $project->getMembershipData(); |
| 68 | 81 | $def = array('owners' => Pluf_Permission::getFromString('IDF.project-owner'), |
| 69 | 82 | 'members' => Pluf_Permission::getFromString('IDF.project-member')); |
| 70 | 83 | $guser = new Pluf_User(); |
| 71 | 84 | foreach ($def as $key=>$perm) { |
| 72 | 85 | foreach ($cm[$key] as $user) { |
| 73 | | Pluf_RowPermission::remove($user, $this->project, $perm); |
| 86 | Pluf_RowPermission::remove($user, $project, $perm); |
| 74 | 87 | } |
| 75 | | foreach (preg_split("/\015\012|\015|\012|\,/", $this->cleaned_data[$key], -1, PREG_SPLIT_NO_EMPTY) as $login) { |
| 88 | foreach (preg_split("/\015\012|\015|\012|\,/", $cleaned_data[$key], -1, PREG_SPLIT_NO_EMPTY) as $login) { |
| 76 | 89 | $sql = new Pluf_SQL('login=%s', array(trim($login))); |
| 77 | 90 | $users = $guser->getList(array('filter'=>$sql->gen())); |
| 78 | 91 | if ($users->count() == 1) { |
| 79 | | Pluf_RowPermission::add($users[0], $this->project, $perm); |
| 92 | Pluf_RowPermission::add($users[0], $project, $perm); |
| 80 | 93 | } |
| 81 | 94 | } |
| 82 | 95 | } |
| src/IDF/Form/SourceConf.php |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Configuration of the source. |
| 27 | * |
| 28 | * Only the modification of the login/password for subversion is |
| 29 | * authorized. |
| 27 | 30 | */ |
| 28 | 31 | class IDF_Form_SourceConf extends Pluf_Form |
| 29 | 32 | { |
| ... | ... | |
| 31 | 34 | public function initFields($extra=array()) |
| 32 | 35 | { |
| 33 | 36 | $this->conf = $extra['conf']; |
| 34 | | $this->fields['scm'] = new Pluf_Form_Field_Varchar( |
| 35 | | array('required' => true, |
| 36 | | 'label' => __('Repository type'), |
| 37 | | 'initial' => $this->conf->getVal('scm', 'git'), |
| 38 | | 'widget_attrs' => array('choices' => |
| 39 | | array( |
| 40 | | __('git') => 'git', |
| 41 | | __('Subversion') => 'svn', |
| 42 | | __('mercurial') => 'mercurial', |
| 43 | | ) |
| 44 | | ), |
| 45 | | 'widget' => 'Pluf_Form_Widget_SelectInput', |
| 46 | | )); |
| 47 | | $this->fields['svn_remote_url'] = new Pluf_Form_Field_Varchar( |
| 48 | | array('required' => false, |
| 49 | | 'label' => __('Remote Subversion repository'), |
| 50 | | 'initial' => $this->conf->getVal('svn_remote_url', ''), |
| 51 | | 'widget_attrs' => array('size' => '30'), |
| 52 | | )); |
| 53 | | |
| 54 | | $this->fields['svn_username'] = new Pluf_Form_Field_Varchar( |
| 37 | if ($this->conf->getVal('scm', 'git') == 'svn') { |
| 38 | $this->fields['svn_username'] = new Pluf_Form_Field_Varchar( |
| 55 | 39 | array('required' => false, |
| 56 | 40 | 'label' => __('Repository username'), |
| 57 | 41 | 'initial' => $this->conf->getVal('svn_username', ''), |
| 58 | 42 | 'widget_attrs' => array('size' => '15'), |
| 59 | 43 | )); |
| 60 | 44 | |
| 61 | | $this->fields['svn_password'] = new Pluf_Form_Field_Varchar( |
| 45 | $this->fields['svn_password'] = new Pluf_Form_Field_Varchar( |
| 62 | 46 | array('required' => false, |
| 63 | 47 | 'label' => __('Repository password'), |
| 64 | 48 | 'initial' => $this->conf->getVal('svn_password', ''), |
| 65 | 49 | 'widget' => 'Pluf_Form_Widget_PasswordInput', |
| 66 | 50 | )); |
| 67 | | } |
| 68 | | |
| 69 | | public function clean_svn_remote_url() |
| 70 | | { |
| 71 | | $url = trim($this->cleaned_data['svn_remote_url']); |
| 72 | | if (strlen($url) == 0) return $url; |
| 73 | | // we accept only starting with http(s):// to avoid people |
| 74 | | // trying to access the local filesystem. |
| 75 | | if (!preg_match('#^(http|https)://#', $url)) { |
| 76 | | throw new Pluf_Form_Invalid(__('Only a remote repository available throught http or https are allowed. For example "http://somewhere.com/svn/trunk".')); |
| 77 | | } |
| 78 | | return $url; |
| 79 | | } |
| 80 | | |
| 81 | | public function clean() |
| 82 | | { |
| 83 | | if ($this->cleaned_data['scm'] == 'git') { |
| 84 | | foreach (array('svn_remote_url', 'svn_username', 'svn_password') |
| 85 | | as $key) { |
| 86 | | $this->cleaned_data[$key] = ''; |
| 87 | | } |
| 88 | 51 | } |
| 89 | | return $this->cleaned_data; |
| 90 | 52 | } |
| 91 | 53 | } |
| 92 | 54 | |
| src/IDF/Views/Admin.php |
| 1 | <?php |
| 2 | /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 3 | /* |
| 4 | # ***** BEGIN LICENSE BLOCK ***** |
| 5 | # This file is part of InDefero, an open source project management application. |
| 6 | # Copyright (C) 2008 Céondo Ltd and contributors. |
| 7 | # |
| 8 | # InDefero is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | # InDefero is distributed in the hope that it will be useful, |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | # GNU General Public License for more details. |
| 17 | # |
| 18 | # You should have received a copy of the GNU General Public License |
| 19 | # along with this program; if not, write to the Free Software |
| 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | # |
| 22 | # ***** END LICENSE BLOCK ***** */ |
| 23 | |
| 24 | Pluf::loadFunction('Pluf_HTTP_URL_urlForView'); |
| 25 | Pluf::loadFunction('Pluf_Shortcuts_RenderToResponse'); |
| 26 | Pluf::loadFunction('Pluf_Shortcuts_GetObjectOr404'); |
| 27 | Pluf::loadFunction('Pluf_Shortcuts_GetFormForModel'); |
| 28 | |
| 29 | /** |
| 30 | * Administration's views. |
| 31 | */ |
| 32 | class IDF_Views_Admin |
| 33 | { |
| 34 | /** |
| 35 | * Home page of the administration. |
| 36 | * |
| 37 | * It should provide an overview of the forge status. |
| 38 | */ |
| 39 | public $home_precond = array('Pluf_Precondition::staffRequired'); |
| 40 | public function home($request, $match) |
| 41 | { |
| 42 | $title = __('Administer'); |
| 43 | return Pluf_Shortcuts_RenderToResponse('idf/gadmin/home.html', |
| 44 | array( |
| 45 | 'page_title' => $title, |
| 46 | ), |
| 47 | $request); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Projects overview. |
| 52 | * |
| 53 | */ |
| 54 | public $projects_precond = array('Pluf_Precondition::staffRequired'); |
| 55 | public function projects($request, $match) |
| 56 | { |
| 57 | $title = __('Projects'); |
| 58 | $pag = new Pluf_Paginator(new IDF_Project()); |
| 59 | $pag->class = 'recent-issues'; |
| 60 | $pag->summary = __('This table shows the projects in the forge.'); |
| 61 | $pag->action = 'IDF_Views_Admin::projects'; |
| 62 | $pag->edit_action = array('IDF_Views_Admin::projectUpdate', 'id'); |
| 63 | $pag->sort_order = array('shortname', 'ASC'); |
| 64 | $list_display = array( |
| 65 | 'shortname' => __('Short Name'), |
| 66 | 'name' => __('Name'), |
| 67 | ); |
| 68 | $pag->configure($list_display, array(), |
| 69 | array('shortname')); |
| 70 | $pag->items_per_page = 25; |
| 71 | $pag->no_results_text = __('No projects were found.'); |
| 72 | $pag->setFromRequest($request); |
| 73 | return Pluf_Shortcuts_RenderToResponse('idf/gadmin/projects/index.html', |
| 74 | array( |
| 75 | 'page_title' => $title, |
| 76 | 'projects' => $pag, |
| 77 | ), |
| 78 | $request); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Edition of a project. |
| 83 | * |
| 84 | * One cannot switch from one source backend to another. |
| 85 | */ |
| 86 | public $projectUpdate_precond = array('Pluf_Precondition::staffRequired'); |
| 87 | public function projectUpdate($request, $match) |
| 88 | { |
| 89 | $project = Pluf_Shortcuts_GetObjectOr404('IDF_Project', $match[1]); |
| 90 | $title = sprintf(__('Update %s'), $project->name); |
| 91 | $params = array( |
| 92 | 'project' => $project, |
| 93 | ); |
| 94 | if ($request->method == 'POST') { |
| 95 | $form = new IDF_Form_Admin_ProjectUpdate($request->POST, $params); |
| 96 | if ($form->isValid()) { |
| 97 | $form->save(); |
| 98 | $request->user->setMessage(__('The project has been updated.')); |
| 99 | $url = Pluf_HTTP_URL_urlForView('IDF_Views_Admin::projectUpdate', |
| 100 | array($project->id)); |
| 101 | return new Pluf_HTTP_Response_Redirect($url); |
| 102 | } |
| 103 | } else { |
| 104 | $form = new IDF_Form_Admin_ProjectUpdate(null, $params); |
| 105 | } |
| 106 | return Pluf_Shortcuts_RenderToResponse('idf/gadmin/projects/update.html', |
| 107 | array( |
| 108 | 'page_title' => $title, |
| 109 | 'project' => $project, |
| 110 | 'form' => $form, |
| 111 | ), |
| 112 | $request); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Creation of a project. |
| 117 | * |
| 118 | */ |
| 119 | public $projectCreate_precond = array('Pluf_Precondition::staffRequired'); |
| 120 | public function projectCreate($request, $match) |
| 121 | { |
| 122 | $title = __('Create Project'); |
| 123 | $extra = array('user' => $request->user); |
| 124 | if ($request->method == 'POST') { |
| 125 | $form = new IDF_Form_Admin_ProjectCreate($request->POST, $extra); |
| 126 | if ($form->isValid()) { |
| 127 | $project = $form->save(); |
| 128 | $request->user->setMessage(__('The project has been created.')); |
| 129 | $url = Pluf_HTTP_URL_urlForView('IDF_Views_Admin::projects'); |
| 130 | return new Pluf_HTTP_Response_Redirect($url); |
| 131 | } |
| 132 | } else { |
| 133 | $form = new IDF_Form_Admin_ProjectCreate(null, $extra); |
| 134 | } |
| 135 | $base = Pluf::f('url_base').Pluf::f('idf_base').'/p/'; |
| 136 | return Pluf_Shortcuts_RenderToResponse('idf/gadmin/projects/create.html', |
| 137 | array( |
| 138 | 'page_title' => $title, |
| 139 | 'form' => $form, |
| 140 | 'base_url' => $base, |
| 141 | ), |
| 142 | $request); |
| 143 | } |
| 144 | |
| 145 | } |
| src/IDF/Views/Project.php |
| 378 | 378 | { |
| 379 | 379 | $prj = $request->project; |
| 380 | 380 | $title = sprintf(__('%s Source'), (string) $prj); |
| 381 | | $extra = array( |
| 382 | | 'conf' => $request->conf, |
| 383 | | ); |
| 384 | | if ($request->method == 'POST') { |
| 385 | | $form = new IDF_Form_SourceConf($request->POST, $extra); |
| 386 | | if ($form->isValid()) { |
| 387 | | foreach ($form->cleaned_data as $key=>$val) { |
| 388 | | $request->conf->setVal($key, $val); |
| 381 | $form = null; |
| 382 | $remote_svn = false; |
| 383 | if ($request->conf->getVal('scm') == 'svn' and |
| 384 | strlen($request->conf->getVal('svn_remote_url')) > 0) { |
| 385 | $remote_svn = true; |
| 386 | $extra = array( |
| 387 | 'conf' => $request->conf, |
| 388 | ); |
| 389 | if ($request->method == 'POST') { |
| 390 | $form = new IDF_Form_SourceConf($request->POST, $extra); |
| 391 | if ($form->isValid()) { |
| 392 | foreach ($form->cleaned_data as $key=>$val) { |
| 393 | $request->conf->setVal($key, $val); |
| 394 | } |
| 395 | $request->user->setMessage(__('The project source configuration has been saved.')); |
| 396 | $url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminSource', |
| 397 | array($prj->shortname)); |
| 398 | return new Pluf_HTTP_Response_Redirect($url); |
| 389 | 399 | } |
| 390 | | $request->user->setMessage(__('The project source configuration has been saved.')); |
| 391 | | $url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminSource', |
| 392 | | array($prj->shortname)); |
| 393 | | return new Pluf_HTTP_Response_Redirect($url); |
| 394 | | } |
| 395 | | } else { |
| 396 | | $params = array(); |
| 397 | | $keys = array('scm', 'svn_remote_url', |
| 398 | | 'svn_username', 'svn_password'); |
| 399 | | foreach ($keys as $key) { |
| 400 | | $_val = $request->conf->getVal($key, false); |
| 401 | | if ($_val !== false) { |
| 402 | | $params[$key] = $_val; |
| 400 | } else { |
| 401 | $params = array(); |
| 402 | foreach (array('svn_username', 'svn_password') as $key) { |
| 403 | $_val = $request->conf->getVal($key, false); |
| 404 | if ($_val !== false) { |
| 405 | $params[$key] = $_val; |
| 406 | } |
| 403 | 407 | } |
| 408 | if (count($params) == 0) { |
| 409 | $params = null; //Nothing in the db, so new form. |
| 410 | } |
| 411 | $form = new IDF_Form_SourceConf($params, $extra); |
| 404 | 412 | } |
| 405 | | if (count($params) == 0) { |
| 406 | | $params = null; //Nothing in the db, so new form. |
| 407 | | } |
| 408 | | $form = new IDF_Form_SourceConf($params, $extra); |
| 409 | 413 | } |
| 414 | $scm = $request->conf->getVal('scm', 'git'); |
| 415 | $options = array( |
| 416 | 'git' => __('git'), |
| 417 | 'svn' => __('Subversion'), |
| 418 | 'mercurial' => __('mercurial'), |
| 419 | ); |
| 420 | $repository_type = $options[$scm]; |
| 410 | 421 | return Pluf_Shortcuts_RenderToResponse('idf/admin/source.html', |
| 411 | 422 | array( |
| 423 | 'remote_svn' => $remote_svn, |
| 424 | 'repository_access' => $prj->getRemoteAccessUrl(), |
| 425 | 'repository_type' => $repository_type, |
| 412 | 426 | 'page_title' => $title, |
| 413 | 427 | 'form' => $form, |
| 414 | 428 | ), |
| src/IDF/templates/idf/admin/source.html |
| 1 | 1 | {extends "idf/admin/base.html"} |
| 2 | 2 | {block docclass}yui-t1{assign $inSource = true}{/block} |
| 3 | 3 | {block body} |
| 4 | | {if $form.errors} |
| 4 | {if $remote_svn and $form.errors} |
| 5 | 5 | <div class="px-message-error"> |
| 6 | 6 | <p>{trans 'The form contains some errors. Please correct them to update the source configuration.'}</p> |
| 7 | 7 | {if $form.get_top_errors} |
| ... | ... | |
| 12 | 12 | <form method="post" action="."> |
| 13 | 13 | <table class="form" summary=""> |
| 14 | 14 | <tr> |
| 15 | | <th><strong>{$form.f.scm.labelTag}:</strong></th> |
| 16 | | <td>{if $form.f.scm.errors}{$form.f.scm.fieldErrors}{/if} |
| 17 | | {$form.f.scm|unsafe} |
| 15 | <th>{trans 'Repository type:'}</th> |
| 16 | <td>{$repository_type} |
| 18 | 17 | </td> |
| 19 | 18 | </tr> |
| 20 | 19 | <tr> |
| 21 | | <th>{$form.f.svn_remote_url.labelTag}:</th> |
| 22 | | <td>{if $form.f.svn_remote_url.errors}{$form.f.svn_remote_url.fieldErrors}{/if} |
| 23 | | {$form.f.svn_remote_url|unsafe} |
| 20 | <th>{trans 'Repository access:'}</th> |
| 21 | <td>{$repository_access} |
| 24 | 22 | </td> |
| 25 | | </tr> |
| 23 | </tr>{if $remote_svn} |
| 26 | 24 | <tr> |
| 27 | 25 | <th>{$form.f.svn_username.labelTag}:</th> |
| 28 | 26 | <td>{if $form.f.svn_username.errors}{$form.f.svn_username.fieldErrors}{/if} |
| ... | ... | |
| 40 | 38 | <td> |
| 41 | 39 | <input type="submit" value="{trans 'Save Changes'}" name="submit" /> |
| 42 | 40 | </td> |
| 43 | | </tr> |
| 41 | </tr>{/if} |
| 44 | 42 | </table> |
| 45 | 43 | </form> |
| 46 | 44 | {/block} |
| 47 | 45 | {block context} |
| 48 | 46 | <div class="issue-submit-info"> |
| 49 | | <p><strong>{trans 'Instructions:'}</strong></p> |
| 50 | | <p>{blocktrans}You can select the type of repository you want. In the case of subversion, you can use optionally a remote repository instead of the local one.{/blocktrans}</p> |
| 47 | <p>{blocktrans}You can find here the current repository configuration of your project.{/blocktrans}</p> |
| 51 | 48 | </div> |
| 52 | 49 | {/block} |
| src/IDF/templates/idf/gadmin/base.html |
| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| 2 | {* |
| 3 | # ***** BEGIN LICENSE BLOCK ***** |
| 4 | # This file is part of InDefero, an open source project management application. |
| 5 | # Copyright (C) 2008 Céondo Ltd and contributors. |
| 6 | # |
| 7 | # InDefero is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 2 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # InDefero is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program; if not, write to the Free Software |
| 19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | # |
| 21 | # ***** END LICENSE BLOCK ***** |
| 22 | *}<html lang="en"> |
| 23 | <head> |
| 24 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 25 | <link rel="stylesheet" type="text/css" href="{media '/idf/css/yui.css'}" /> |
| 26 | <link rel="stylesheet" type="text/css" href="{media '/idf/css/style.css'}" /> |
| 27 | <!--[if lt IE 7]> |
| 28 | <link rel="stylesheet" type="text/css" href="{media '/idf/css/ie6.css'}" /> |
| 29 | <![endif]--> |
| 30 | {block extraheader}{/block} |
| 31 | <title>{block pagetitle}{$page_title|strip_tags}{/block}</title> |
| 32 | </head> |
| 33 | <body> |
| 34 | <div id="{block docid}doc3{/block}" class="{block docclass}yui-t3{/block}"> |
| 35 | <div id="hd"> |
| 36 | <p class="top"><a href="#title" accesskey="2"></a> |
| 37 | {aurl 'url', 'IDF_Views_User::myAccount'}{blocktrans}Welcome, <strong><a class="userw" href="{$url}">{$user}</a></strong>.{/blocktrans} <a href="{url 'IDF_Views::logout'}">{trans 'Sign Out'}</a> |
| 38 | | <a href="{url 'IDF_Views::index'}">{trans 'Project List'}</a> |
| 39 | | <a href="{url 'IDF_Views::faq'}" title="{trans 'Help and accessibility features'}">{trans 'Help'}</a> |
| 40 | </p> |
| 41 | <div id="header"> |
| 42 | <div id="main-tabs"> |
| 43 | <a accesskey="1" href="{url 'IDF_Views_Admin::home'}"{block tabhome}{/block}>{trans 'Administer'}</a> |
| 44 | <a href="{url 'IDF_Views_Admin::projects'}"{block tabprojects}{/block}>{trans 'Projects'}</a> |
| 45 | </div> |
| 46 | <div id="sub-tabs">{block subtabs}{/block}</div> |
| 47 | </div> |
| 48 | <h1 id="title" class="title">{block title}{$page_title}{/block}</h1> |
| 49 | </div> |
| 50 | <div id="bd"> |
| 51 | <div id="yui-main"> |
| 52 | <div class="yui-b"> |
| 53 | <div class="yui-g"> |
| 54 | {if $user and $user.id}{getmsgs $user}{/if} |
| 55 | <div class="content">{block body}{/block}</div> |
| 56 | </div> |
| 57 | </div> |
| 58 | </div> |
| 59 | <div class="yui-b context">{block context}{/block}</div> |
| 60 | </div> |
| 61 | <div id="ft">{block foot}{/block}</div> |
| 62 | </div> |
| 63 | <script type="text/javascript" src="{media '/idf/js/jquery-1.2.6.min.js'}"></script> |
| 64 | {include 'idf/js-hotkeys.html'} |
| 65 | {block javascript}{/block} |
| 66 | </body> |
| 67 | </html> |
| src/IDF/templates/idf/gadmin/projects/create.html |
| 1 | {extends "idf/gadmin/projects/base.html"} |
| 2 | |
| 3 | {block docclass}yui-t3{assign $inCreate=true}{/block} |
| 4 | |
| 5 | {block body} |
| 6 | {if $form.errors} |
| 7 | <div class="px-message-error"> |
| 8 | <p>{trans 'The form contains some errors. Please correct them to create the project.'}</p> |
| 9 | {if $form.get_top_errors} |
| 10 | {$form.render_top_errors|unsafe} |
| 11 | {/if} |
| 12 | </div> |
| 13 | {/if} |
| 14 | <form method="post" action="."> |
| 15 | <table class="form" summary=""> |
| 16 | <tr> |
| 17 | <th><strong>{$form.f.name.labelTag}:</strong></th> |
| 18 | <td> |
| 19 | {if $form.f.name.errors}{$form.f.name.fieldErrors}{/if} |
| 20 | {$form.f.name|unsafe} |
| 21 | </td> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <th><strong>{$form.f.shortname.labelTag}:</strong></th> |
| 25 | <td> |
| 26 | {if $form.f.shortname.errors}{$form.f.shortname.fieldErrors}{/if} |
| 27 | {$base_url}{$form.f.shortname|unsafe}/<br /> |
| 28 | <span class="helptext">{$form.f.shortname.help_text}</span> |
| 29 | </td> |
| 30 | </tr> |
| 31 | <tr> |
| 32 | <th><strong>{$form.f.scm.labelTag}:</strong></th> |
| 33 | <td>{if $form.f.scm.errors}{$form.f.scm.fieldErrors}{/if} |
| 34 | {$form.f.scm|unsafe} |
| 35 | </td> |
| 36 | </tr> |
| 37 | <tr class="svn-form"> |
| 38 | <th>{$form.f.svn_remote_url.labelTag}:</th> |
| 39 | <td>{if $form.f.svn_remote_url.errors}{$form.f.svn_remote_url.fieldErrors}{/if} |
| 40 | {$form.f.svn_remote_url|unsafe} |
| 41 | </td> |
| 42 | </tr> |
| 43 | <tr class="svn-form"> |
| 44 | <th>{$form.f.svn_username.labelTag}:</th> |
| 45 | <td>{if $form.f.svn_username.errors}{$form.f.svn_username.fieldErrors}{/if} |
| 46 | {$form.f.svn_username|unsafe} |
| 47 | </td> |
| 48 | </tr> |
| 49 | <tr class="svn-form"> |
| 50 | <th>{$form.f.svn_password.labelTag}:</th> |
| 51 | <td>{if $form.f.svn_password.errors}{$form.f.svn_password.fieldErrors}{/if} |
| 52 | {$form.f.svn_password|unsafe} |
| 53 | </td> |
| 54 | </tr> |
| 55 | <tr> |
| 56 | <th><strong>{$form.f.owners.labelTag}:</strong></th> |
| 57 | <td> |
| 58 | {if $form.f.owners.errors}{$form.f.owners.fieldErrors}{/if} |
| 59 | {$form.f.owners|unsafe}<br /> |
| 60 | <span class="helptext">{trans 'Provide at least one owner for the project.'}</span> |
| 61 | </td> |
| 62 | </tr> |
| 63 | <tr> |
| 64 | <th>{$form.f.members.labelTag}:</th> |
| 65 | <td> |
| 66 | {if $form.f.members.errors}{$form.f.members.fieldErrors}{/if} |
| 67 | {$form.f.members|unsafe} |
| 68 | </td> |
| 69 | </tr> |
| 70 | <tr> |
| 71 | <td> </td> |
| 72 | <td> |
| 73 | <input type="submit" value="{trans 'Create Project'}" name="submit" /> |
| 74 | </td> |
| 75 | </tr> |
| 76 | </table> |
| 77 | </form> |
| 78 | |
| 79 | {/block} |
| 80 | |
| 81 | {block context} |
| 82 | <div class="issue-submit-info"> |
| 83 | <p><strong>{trans 'Instructions:'}</strong></p> |
| 84 | <p>{blocktrans}You can select the type of repository you want. In the case of subversion, you can use optionally a remote repository instead of the local one.{/blocktrans}</p> |
| 85 | <p>{blocktrans}<strong>Once you have defined the repository type, you cannot change it</strong>.{/blocktrans}</p> |
| 86 | </div> |
| 87 | <div class="issue-submit-info"> |
| 88 | {blocktrans} |
| 89 | <p>Specify each person by its login. Each person must have already registered with the given login.</p> |
| 90 | <p>Separate the logins with commas and/or new lines.</p> |
| 91 | {/blocktrans} |
| 92 | </div> |
| 93 | <div class="issue-submit-info"> |
| 94 | {blocktrans} |
| 95 | <p><strong>Notes:</strong></p> |
| 96 | <p>A project owner may make any change to this project, including removing other project owners. You need to be carefull when you give owner rights.</p> |
| 97 | <p>A project member will not have access to the administration area but will have more options available in the use of the project.</p> |
| 98 | {/blocktrans} |
| 99 | </div> |
| 100 | {/block} |
| 101 | |
| 102 | {block javascript}{literal} |
| 103 | <script type="text/javascript"> |
| 104 | $(document).ready(function() { |
| 105 | // Hide if not svn |
| 106 | if ($("#id_scm option:selected").val() != "svn") { |
| 107 | $(".svn-form").hide(); |
| 108 | } |
| 109 | $("#id_scm").change(function () { |
| 110 | if ($("#id_scm option:selected").val() == "svn") { |
| 111 | $(".svn-form").show(); |
| 112 | } else { |
| 113 | $(".svn-form").hide(); |
| 114 | } |
| 115 | }); |
| 116 | }); |
| 117 | </script> |
| 118 | {/literal}{/block} |
| 119 | {* |
| 120 | |
| 121 | $("select").change(function () { |
| 122 | var str = ""; |
| 123 | $("select option:selected").each(function () { |
| 124 | str += $(this).text() + " "; |
| 125 | }); |
| 126 | $("div").text(str); |
| 127 | }) |
| 128 | .trigger('change'); |
| 129 | |
| 130 | *} |
| src/IDF/templates/idf/gadmin/projects/update.html |
| 1 | {extends "idf/gadmin/projects/base.html"} |
| 2 | {block body} |
| 3 | {if $form.errors} |
| 4 | <div class="px-message-error"> |
| 5 | <p>{trans 'The form contains some errors. Please correct them to update the project.'}</p> |
| 6 | {if $form.get_top_errors} |
| 7 | {$form.render_top_errors|unsafe} |
| 8 | {/if} |
| 9 | </div> |
| 10 | {/if} |
| 11 | <form method="post" action="."> |
| 12 | <table class="form" summary=""> |
| 13 | <tr> |
| 14 | <th><strong>{$form.f.name.labelTag}:</strong></th> |
| 15 | <td> |
| 16 | {if $form.f.name.errors}{$form.f.name.fieldErrors}{/if} |
| 17 | {$form.f.name|unsafe} |
| 18 | </td> |
| 19 | </tr> |
| 20 | <tr> |
| 21 | <th><strong>{$form.f.owners.labelTag}:</strong></th> |
| 22 | <td> |
| 23 | {if $form.f.owners.errors}{$form.f.owners.fieldErrors}{/if} |
| 24 | {$form.f.owners|unsafe}<br /> |
| 25 | <span class="helptext">{trans 'Provide at least one owner for the project.'}</span> |
| 26 | </td> |
| 27 | </tr> |
| 28 | <tr> |
| 29 | <th>{$form.f.members.labelTag}:</th> |
| 30 | <td> |
| 31 | {if $form.f.members.errors}{$form.f.members.fieldErrors}{/if} |
| 32 | {$form.f.members|unsafe} |
| 33 | </td> |
| 34 | </tr> |
| 35 | <tr> |
| 36 | <td> </td> |
| 37 | <td> |
| 38 | <input type="submit" value="{trans 'Update Project'}" name="submit" /> |
| 39 | | <a href="{url 'IDF_Views_Admin::projects'}">{trans 'Cancel'}</a> |
| 40 | </td> |
| 41 | </tr> |
| 42 | </table> |
| 43 | </form> |
| 44 | {/block} |
| 45 | {block context} |
| 46 | <div class="issue-submit-info"> |
| 47 | {blocktrans} |
| 48 | <p><strong>Instructions:</strong></p> |
| 49 | <p>Specify each person by its login. Each person must have already registered with the given login.</p> |
| 50 | <p>Separate the logins with commas and/or new lines.</p> |
| 51 | {/blocktrans} |
| 52 | </div> |
| 53 | <div class="issue-submit-info"> |
| 54 | {blocktrans} |
| 55 | <p><strong>Notes:</strong></p> |
| 56 | <p>A project owner may make any change to this project, including removing other project owners. You need to be carefull when you give owner rights.</p> |
| 57 | <p>A project member will not have access to the administration area but will have more options available in the use of the project.</p> |
| 58 | {/blocktrans} |
| 59 | </div> |
| 60 | {/block} |
| 61 | |
| 62 | |
| 63 | |