3 * Project Management Facility : Admin
5 * Copyright 1999/2000, Sourceforge.net Tim Perdue
6 * Copyright 2002 GForge, LLC, Tim Perdue
7 * Copyright 2010, FusionForge Team
8 * Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
9 * Copyright 2013, Franck Villaume - TrivialDev
10 * http://fusionforge.org
12 * This file is part of FusionForge. FusionForge is free software;
13 * you can redistribute it and/or modify it under the terms of the
14 * GNU General Public License as published by the Free Software
15 * Foundation; either version 2 of the Licence, or (at your option)
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 require_once '../../env.inc.php';
29 require_once $gfcommon.'include/pre.php';
30 require_once $gfwww.'pm/include/ProjectGroupHTML.class.php';
31 require_once $gfcommon.'pm/ProjectGroupFactory.class.php';
32 require_once $gfcommon.'pm/ProjectCategory.class.php';
34 if (!session_loggedin()) {
38 $group_id = getIntFromRequest('group_id');
39 $group_project_id = getIntFromRequest('group_project_id');
45 $g = group_get_object($group_id);
46 if (!$g || !is_object($g)) {
48 } elseif ($g->isError()) {
49 exit_error($g->getErrorMessage(),'pm');
52 $update_cat = getStringFromRequest('update_cat');
53 $add_cat = getStringFromRequest('add_cat');
54 $delete = getStringFromRequest('delete');
55 $id = getIntFromRequest('id');
57 if (getStringFromRequest('post_changes')) {
61 $pg = new ProjectGroup($g,$group_project_id);
62 if (!$pg || !is_object($pg)) {
63 exit_error(_('Unable to create ProjectCategory Object'),'pm');
64 } elseif ($pg->isError()) {
65 exit_error($pg->getErrorMessage(),'pm');
68 if (getStringFromRequest('addproject')) {
69 $project_name = getStringFromRequest('project_name');
70 $description = getStringFromRequest('description');
71 $send_all_posts_to = getStringFromRequest('send_all_posts_to');
76 session_require_perm ('pm_admin', $group_id) ;
77 if (!$pg->create($project_name,$description,$send_all_posts_to)) {
78 exit_error($pg->getErrorMessage(),'pm');
80 $feedback .= _('Subproject Inserted');
81 $feedback .= '<br />';
82 $feedback .= _("Please configure also the roles (by default, it's “No Access”)");
86 $name = getStringFromRequest('name');
89 Add a project_category
91 session_require_perm ('pm', $pg->getID(), 'manager') ;
93 $pc = new ProjectCategory($pg);
94 if (!$pc || !is_object($pc)) {
95 exit_error(_('Unable to create ProjectCategory Object'),'pm');
97 if (!$pc->create($name)) {
98 $error_msg .= _('Insert Error')._(': ').$pc->getErrorMessage();
100 $feedback .= _('Category Inserted');
104 } elseif ($update_cat) {
105 $id = getIntFromRequest('id');
106 $name = getStringFromRequest('name');
109 Update a project_category
111 session_require_perm ('pm', $pg->getID(), 'manager') ;
113 $pc = new ProjectCategory($pg,$id);
114 if (!$pc || !is_object($pc)) {
115 exit_error(_('Unable to create ProjectCategory Object'),'pm');
116 } elseif ($pc->isError()) {
117 exit_error($pc->getErrorMessage(),'pm');
119 if (!$pc->update($name)) {
120 exit_error(_('Update failed')._(': ').$pc->getErrorMessage(),'pm');
122 $feedback .= _('Category Updated');
128 } elseif (getStringFromRequest('update_pg')) {
129 $project_name = getStringFromRequest('project_name');
130 $description = getStringFromRequest('description');
131 $send_all_posts_to = getStringFromRequest('send_all_posts_to');
136 session_require_perm ('pm', $pg->getID(), 'manager') ;
138 if (!$pg->update($project_name,$description,$send_all_posts_to)) {
139 exit_error($pg->getErrorMessage(),'pm');
141 $feedback .= _('Subproject Updated successfully');
145 $sure = getStringFromRequest('sure');
146 $really_sure = getStringFromRequest('really_sure');
151 session_require_perm ('pm', $pg->getID(), 'manager') ;
153 if (!$pg->delete(getStringFromRequest('sure'),getStringFromRequest('really_sure'))) {
154 exit_error($pg->getErrorMessage(),'pm');
156 $feedback .= _('Subproject successfully deleted.');
165 if ($add_cat && $group_project_id) {
167 // FORM TO ADD CATEGORIES
170 $pg = new ProjectGroup($g,$group_project_id);
171 if (!$pg || !is_object($pg)) {
172 exit_error(_('Unable to create ProjectCategory Object'),'pm');
173 } elseif ($pg->isError()) {
174 exit_error($pg->getErrorMessage(),'pm');
177 session_require_perm ('pm', $pg->getID(), 'manager') ;
179 $title = sprintf(_('Add Categories to: %s'), $pg->getName());
180 pm_header(array('title'=>$title));
183 List of possible categories for this ArtifactType
185 $result=$pg->getCategories();
186 $rows=db_numrows($result);
187 if ($result && $rows > 0) {
189 $title_arr[]=_('Id');
190 $title_arr[]=_('Title');
192 echo $GLOBALS['HTML']->listTableTop ($title_arr);
194 for ($i=0; $i < $rows; $i++) {
195 echo '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'.
196 '<td>'.db_result($result, $i, 'category_id').'</td>'.
197 '<td><a href="'.getStringFromServer('PHP_SELF').'?update_cat=1&id='.
198 db_result($result, $i, 'category_id').'&group_id='.$group_id.'&group_project_id='. $pg->getID() .'">'.
199 db_result($result, $i, 'category_name').'</a></td></tr>';
202 echo $GLOBALS['HTML']->listTableBottom();
205 echo "\n<p class=\"information\">"._('No categories defined')."</p>";
209 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post">
211 <input type="hidden" name="add_cat" value="y" />
212 <input type="hidden" name="group_project_id" value="<?php echo $pg->getID(); ?>" />
214 <strong><?php echo _('Category Name') . _(':'); ?></strong>
216 <input id="name" required="required" type="text" name="name" value="" />
218 <p class="important"><?php echo _('Once you add a category, it cannot be deleted') ?></p>
219 <p><input type="submit" name="post_changes" value="<?php echo _('Submit') ?>" /></p>
225 } elseif ($update_cat && $group_project_id && $id) {
228 // FORM TO UPDATE CATEGORIES
231 Allow modification of a category
234 $pg = new ProjectGroup($g,$group_project_id);
235 if (!$pg || !is_object($pg)) {
236 exit_error(_('Unable to create ProjectCategory Object'),'pm');
237 } elseif ($pg->isError()) {
238 exit_error($pg->getErrorMessage(),'pm');
241 session_require_perm ('pm', $pg->getID(), 'manager') ;
243 $title = sprintf(_('Modify a Category in: %s'), $pg->getName());
245 $ac = new ProjectCategory($pg,$id);
246 if (!$ac || !is_object($ac)) {
247 exit_error(_('Unable to create ProjectCategory Object'),'pm');
248 } elseif ($ac->isError()) {
249 exit_error($ac->getErrorMessage(),'pm');
251 pm_header(array ('title'=>$title));
253 <p class="information"><?php echo _('It is not recommended that you change the category name because other things are dependent upon it. When you change the category name, all related items will be changed to the new name.')?></p>
254 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post">
256 <input type="hidden" name="update_cat" value="y" />
257 <input type="hidden" name="id" value="<?php echo $ac->getID(); ?>" />
258 <input type="hidden" name="group_project_id" value="<?php echo $pg->getID(); ?>" />
260 <strong><?php echo _('Category Name') . _(': '); ?></strong>
262 <input id="name" required="required" type="text" name="name" value="<?php echo $ac->getName(); ?>" />
264 <p><input type="submit" name="post_changes" value="<?php echo _('Submit') ?>" /></p>
271 } elseif (getStringFromRequest('addproject')) {
273 Create a new subproject
275 session_require_perm ('pm_admin', $group_id) ;
277 pm_header(array('title'=>_('Add a new subproject')));
280 <p><?php echo _('Add a new subproject to the Tasks. <strong>This is different than adding a task to a subproject.</strong>') ?></p>
282 <form action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id"; ?>" method="post">
284 <input type="hidden" name="addproject" value="y" />
285 <input type="hidden" name="post_changes" value="y" />
286 <strong><?php echo _('New Subproject Name').utils_requiredField()?></strong>
288 <input type="text" name="project_name" value="" size="15" maxlength="30" required="required" pattern=".{5,}" title="<?php echo _('At least 5 characters') ?>" />
290 <strong><?php echo _('Description').utils_requiredField() ?></strong><br />
291 <input type="text" name="description" value="" size="40" maxlength="80" required="required" pattern=".{10,}" title="<?php echo _('At least 10 characters') ?>" />
293 <strong><?php echo _('Send All Updates To')._(':'); ?></strong><br />
294 <input type="text" name="send_all_posts_to" value="" size="40" maxlength="80" /><p />
295 <input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
300 } elseif (getStringFromRequest('update_pg') && $group_project_id) {
302 $pg = new ProjectGroup($g,$group_project_id);
303 if (!$pg || !is_object($pg)) {
304 exit_error(_('Could Not Get ProjectGroup'),'pm');
305 } elseif ($pg->isError()) {
306 exit_error($pg->getErrorMessage(),'pm');
308 session_require_perm ('pm', $pg->getID(), 'manager') ;
310 pm_header(array('title'=>_('Change Tasks Status')));
313 <p><?php echo _('You can modify an existing subproject using this form. Please note that private subprojects can still be viewed by members of your project, but not the general public.') ?></p>
315 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post">
316 <input type="hidden" name="post_changes" value="y" />
317 <input type="hidden" name="update_pg" value="y" />
318 <input type="hidden" name="group_project_id" value="<?php echo $pg->getID(); ?>" />
319 <table class="infotable">
322 <label for="project_name">
323 <?php echo _('Subproject Name')._(':'); ?>
327 <input id="project_name" type="text" name="project_name" value="<?php echo $pg->getName() ?>" required="required" pattern=".{5,}" title="<?php echo _('At least 5 characters') ?>" />
332 <label for="description">
333 <?php echo _('Description')._(':'); ?>
337 <input id="description" type="text" name="description" value="<?php echo $pg->getDescription(); ?>" size="40" maxlength="80" required="required" pattern=".{10,}" title="<?php echo _('At least 10 characters') ?>" />
342 <label for="send_all_posts_to">
343 <?php echo _('Send All Updates To')._(':'); ?>
347 <input id="send_all_posts_to" type="text" name="send_all_posts_to" value="<?php echo $pg->getSendAllPostsTo(); ?>" size="40" maxlength="80" />
352 <input type="submit" name="submit" value="<?php echo _('Update') ?>" />
361 } elseif ($delete && $group_project_id) {
363 $pg = new ProjectGroup($g,$group_project_id);
364 if (!$pg || !is_object($pg)) {
365 exit_error(_('Could Not Get ProjectGroup'),'pm');
366 } elseif ($pg->isError()) {
367 exit_error($pg->getErrorMessage(),'pm');
370 session_require_perm ('pm', $pg->getID(), 'manager') ;
372 pm_header(array('title'=>_('Permanently delete this subproject and all its data')));
375 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_project_id='.$group_project_id; ?>" method="post">
377 <input type="hidden" name="post_changes" value="y" />
378 <input type="hidden" name="delete" value="y" />
379 <?php echo _('You are about to permanently and irretrievably delete this subproject and all its related data!'); ?>
382 <input id="sure" type="checkbox" name="sure" value="1" />
384 <?php echo _('I am Sure') ?>
388 <input id="really_sure" type="checkbox" name="really_sure" value="1" />
389 <label for="really_sure">
390 <?php echo _('I am Really Sure'); ?>
394 <input type="submit" name="post_changes" value="<?php echo _('Permanently delete this subproject and all its data') ?>" />
403 $pgf = new ProjectGroupFactory($g);
404 if (!$pgf || !is_object($pgf)) {
405 exit_error(_('Could Not Get Factory'),'pm');
406 } elseif ($pgf->isError()) {
407 exit_error($pgf->getErrorMessage(),'pm');
413 pm_header(array('title'=>_('Tasks Administration')));
416 // Show link to create new subproject
418 if (forge_check_perm ('pm_admin', $group_id)) {
421 <a href="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>&addproject=1"><?php echo _('Add a Subproject') ?></a><br />
422 <?php echo _('Add a subproject, which can contain a set of tasks. This is different than creating a new task.') ?>
427 $pg_arr = $pgf->getProjectGroups();
429 if (count($pg_arr) < 1 || $pg_arr == false) {
430 echo '<p class="information">' . _('No Subprojects Found in this Project') . '</p>';
431 echo '<p>' . _('You may add new Subprojects using the “Add a Subproject” link above.') . '</p>';
434 for ($i=0; $i<count($pg_arr); $i++) {
435 echo '<a href="'. getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_project_id='.$pg_arr[$i]->getID().'&update_pg=1">'._('Edit/Update Subproject').': <strong>'.$pg_arr[$i]->getName().'</strong></a><p />';