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 Alain Peyrat - Alcatel-Lucent
9 * http://fusionforge.org
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once('../../env.inc.php');
28 require_once $gfcommon.'include/pre.php';
29 require_once $gfwww.'pm/include/ProjectGroupHTML.class.php';
30 require_once $gfcommon.'pm/ProjectGroupFactory.class.php';
31 require_once $gfcommon.'pm/ProjectCategory.class.php';
33 if (!session_loggedin()) {
37 $group_id = getIntFromRequest('group_id');
38 $group_project_id = getIntFromRequest('group_project_id');
44 $g = group_get_object($group_id);
45 if (!$g || !is_object($g)) {
47 } elseif ($g->isError()) {
48 exit_error($g->getErrorMessage(),'pm');
51 $update_cat = getStringFromRequest('update_cat');
52 $add_cat = getStringFromRequest('add_cat');
53 $delete = getStringFromRequest('delete');
54 $id = getIntFromRequest('id');
56 if (getStringFromRequest('post_changes')) {
60 $pg = new ProjectGroup($g,$group_project_id);
61 if (!$pg || !is_object($pg)) {
62 exit_error(_('Unable to create ProjectCategory Object'),'pm');
63 } elseif ($pg->isError()) {
64 exit_error($pg->getErrorMessage(),'pm');
67 if (getStringFromRequest('addproject')) {
68 $project_name = getStringFromRequest('project_name');
69 $description = getStringFromRequest('description');
70 $send_all_posts_to = getStringFromRequest('send_all_posts_to');
75 session_require_perm ('pm_admin', $group_id) ;
76 if (!$pg->create($project_name,$description,0,$send_all_posts_to)) {
77 exit_error($pg->getErrorMessage(),'pm');
79 $feedback .= _('Subproject Inserted');
80 $warning_msg .= _("Please configure also the roles (by default, it's 'No Access')");
83 } else if ($add_cat) {
84 $name = getStringFromRequest('name');
87 Add a project_category
89 session_require_perm ('pm', $pg->getID(), 'manager') ;
91 $pc = new ProjectCategory($pg);
92 if (!$pc || !is_object($pc)) {
93 exit_error(_('Unable to create ProjectCategory Object'),'pm');
95 if (!$pc->create($name)) {
96 exit_error(_('Error inserting: ').$pc->getErrorMessage(),'pm');
98 $feedback .= _('Category Inserted');
102 } else if ($update_cat) {
103 $id = getIntFromRequest('id');
104 $name = getStringFromRequest('name');
107 Update a project_category
109 session_require_perm ('pm', $pg->getID(), 'manager') ;
111 $pc = new ProjectCategory($pg,$id);
112 if (!$pc || !is_object($pc)) {
113 exit_error(_('Unable to create ProjectCategory Object'),'pm');
114 } elseif ($pc->isError()) {
115 exit_error($pc->getErrorMessage(),'pm');
117 if (!$pc->update($name)) {
118 exit_error(_('Error updating: '.$pc->getErrorMessage()),'pm');
120 $feedback .= _('Category Updated');
126 } else if (getStringFromRequest('update_pg')) {
127 $project_name = getStringFromRequest('project_name');
128 $description = getStringFromRequest('description');
129 $send_all_posts_to = getStringFromRequest('send_all_posts_to');
134 session_require_perm ('pm', $pg->getID(), 'manager') ;
136 if (!$pg->update($project_name,$description,$send_all_posts_to)) {
137 exit_error($pg->getErrorMessage(),'pm');
139 $feedback .= _('Subproject Updated successfully');
142 } else if ($delete) {
143 $sure = getStringFromRequest('sure');
144 $really_sure = getStringFromRequest('really_sure');
149 session_require_perm ('pm', $pg->getID(), 'manager') ;
151 if (!$pg->delete(getStringFromRequest('sure'),getStringFromRequest('really_sure'))) {
152 exit_error($pg->getErrorMessage(),'pm');
154 $feedback .= _('Subproject Successfully Deleted');
163 if ($add_cat && $group_project_id) {
165 // FORM TO ADD CATEGORIES
168 $pg = new ProjectGroup($g,$group_project_id);
169 if (!$pg || !is_object($pg)) {
170 exit_error(_('Unable to create ProjectCategory Object'),'pm');
171 } elseif ($pg->isError()) {
172 exit_error($pg->getErrorMessage(),'pm');
175 session_require_perm ('pm', $pg->getID(), 'manager') ;
177 $title = sprintf(_('Add Categories to: %s'), $pg->getName());
178 pm_header(array ('title'=>$title));
181 List of possible categories for this ArtifactType
183 $result=$pg->getCategories();
184 $rows=db_numrows($result);
185 if ($result && $rows > 0) {
187 $title_arr[]=_('Id');
188 $title_arr[]=_('Title');
190 echo $GLOBALS['HTML']->listTableTop ($title_arr);
192 for ($i=0; $i < $rows; $i++) {
193 echo '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'.
194 '<td>'.db_result($result, $i, 'category_id').'</td>'.
195 '<td><a href="'.getStringFromServer('PHP_SELF').'?update_cat=1&id='.
196 db_result($result, $i, 'category_id').'&group_id='.$group_id.'&group_project_id='. $pg->getID() .'">'.
197 db_result($result, $i, 'category_name').'</a></td></tr>';
200 echo $GLOBALS['HTML']->listTableBottom();
203 echo "\n<p class=\"information\">"._('No categories defined')."</p>";
207 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post">
209 <input type="hidden" name="add_cat" value="y" />
210 <input type="hidden" name="group_project_id" value="<?php echo $pg->getID(); ?>" />
211 <strong><?php echo _('Category Name') ?>:</strong><br />
212 <input type="text" name="name" value="" size="15" maxlength="30" />
214 <p class="important"><?php echo _('Once you add a category, it cannot be deleted') ?></p>
215 <p><input type="submit" name="post_changes" value="<?php echo _('Submit') ?>" /></p>
221 } elseif ($update_cat && $group_project_id && $id) {
224 // FORM TO UPDATE CATEGORIES
227 Allow modification of a category
230 $pg = new ProjectGroup($g,$group_project_id);
231 if (!$pg || !is_object($pg)) {
232 exit_error(_('Unable to create ProjectCategory Object'),'pm');
233 } elseif ($pg->isError()) {
234 exit_error($pg->getErrorMessage(),'pm');
237 session_require_perm ('pm', $pg->getID(), 'manager') ;
239 $title = sprintf(_('Modify a Category in: %s'), $pg->getName());
241 $ac = new ProjectCategory($pg,$id);
242 if (!$ac || !is_object($ac)) {
243 exit_error(_('Unable to create ProjectCategory Object'),'pm');
244 } elseif ($ac->isError()) {
245 exit_error($ac->getErrorMessage(),'pm');
247 pm_header(array ('title'=>$title));
250 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post" />
251 <input type="hidden" name="update_cat" value="y" />
252 <input type="hidden" name="id" value="<?php echo $ac->getID(); ?>" />
253 <input type="hidden" name="group_project_id" value="<?php echo $pg->getID(); ?>" />
255 <strong><?php echo _('Category Name')?>:</strong><br />
256 <input type="text" name="name" value="<?php echo $ac->getName(); ?>" />
258 <div class="warning"><?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.')?></div>
260 <input type="submit" name="post_changes" value="<?php echo _('Submit') ?>" />
267 } elseif (getStringFromRequest('addproject')) {
269 Create a new subproject
271 session_require_perm ('pm_admin', $group_id) ;
273 pm_header(array ('title'=>_('Add a new subproject')));
276 <p><?php echo _('Add a new subproject to the Tasks. <strong>This is different than adding a task to a subproject.</strong>') ?></p>
278 <form action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id"; ?>" method="post">
280 <input type="hidden" name="addproject" value="y" />
281 <input type="hidden" name="post_changes" value="y" />
282 <strong><?php echo _('New Subproject Name').utils_requiredField()?></strong>
284 <input type="text" name="project_name" value="" size="15" maxlength="30" />
286 <strong><?php echo _('Description').utils_requiredField() ?></strong><br />
287 <input type="text" name="description" value="" size="40" maxlength="80" />
289 <strong><?php echo _('Send All Updates To')?>:</strong><br />
290 <input type="text" name="send_all_posts_to" value="" size="40" maxlength="80" /><p />
291 <input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
296 } else if (getStringFromRequest('update_pg') && $group_project_id) {
298 $pg = new ProjectGroup($g,$group_project_id);
299 if (!$pg || !is_object($pg)) {
300 exit_error(_('Could Not Get ProjectGroup'),'pm');
301 } elseif ($pg->isError()) {
302 exit_error($pg->getErrorMessage(),'pm');
305 session_require_perm ('pm', $pg->getID(), 'manager') ;
307 pm_header(array('title'=>_('Change Tasks Status')));
310 <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>
313 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post">
314 <input type="hidden" name="post_changes" value="y" />
315 <input type="hidden" name="update_pg" value="y" />
316 <input type="hidden" name="group_project_id" value="<?php echo $pg->getID(); ?>" />
319 <td><strong><?php echo _('Subproject Name').utils_requiredField() ?>:</strong><br />
320 <input type="text" name="project_name" value="<?php echo $pg->getName() ?>" />
325 <strong><?php echo _('Description').utils_requiredField() ?>:</strong><br />
326 <input type="text" name="description" value="<?php echo $pg->getDescription(); ?>" size="40" maxlength="80" /><br />
331 <strong><?php echo _('Send All Updates To')?>:</strong><br />
332 <input type="text" name="send_all_posts_to" value="<?php echo $pg->getSendAllPostsTo(); ?>" size="40" maxlength="80" /><br />
337 <strong><a href="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id&add_cat=1&group_project_id=".$pg->getID(); ?>"><?php echo _('Add/Edit Categories')?></a></strong><br />
338 <strong><a href="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id&delete=1&group_project_id=".$pg->getID(); ?>"><?php echo _('Permanently delete this subproject and all its data.')?></a></strong><br />
343 <input type="submit" name="submit" value="<?php echo _('Update') ?>" />
352 } else if ($delete && $group_project_id) {
354 $pg = new ProjectGroup($g,$group_project_id);
355 if (!$pg || !is_object($pg)) {
356 exit_error(_('Could Not Get ProjectGroup'),'pm');
357 } elseif ($pg->isError()) {
358 exit_error($pg->getErrorMessage(),'pm');
361 session_require_perm ('pm', $pg->getID(), 'manager') ;
363 pm_header(array('title'=>_('Delete')));
366 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_project_id='.$group_project_id; ?>" method="post">
367 <input type="hidden" name="post_changes" value="y" />
368 <input type="hidden" name="delete" value="y" /><br />
369 <?php echo _('You are about to permanently and irretrievably delete this subproject and all its related data!'); ?>
371 <input type="checkbox" name="sure" value="1" /><?php echo _('I\'m Sure') ?><br />
372 <input type="checkbox" name="really_sure" value="1" /><?php echo _('I\'m Really Sure'); ?>
374 <input type="submit" name="post_changes" value="<?php echo _('Delete') ?>" />
383 $pgf = new ProjectGroupFactory($g);
384 if (!$pgf || !is_object($pgf)) {
385 exit_error(_('Could Not Get Factory'),'pm');
386 } elseif ($pgf->isError()) {
387 exit_error($pgf->getErrorMessage(),'pm');
393 pm_header(array('title'=>_('Tasks Administration')));
396 // Show link to create new subproject
398 if (forge_check_perm ('pm_admin', $group_id)) {
401 <a href="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>&addproject=1"><?php echo _('Add a Subproject') ?></a><br />
402 <?php echo _('Add a subproject, which can contain a set of tasks. This is different than creating a new task.') ?>
407 $pg_arr = $pgf->getProjectGroups();
409 if (count($pg_arr) < 1 || $pg_arr == false) {
410 echo '<p class="information">' . _('No Subprojects Found in this Project') . '</p>';
411 echo '<p>' . _('You may add new Subprojects using the "Add a Subproject" link above.') . '</p>';
414 for ($i=0; $i<count($pg_arr); $i++) {
415 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 />';