4 * GForge Group Role Generator
6 * Copyright 2004 GForge, LLC
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
25 require_once dirname(__FILE__).'/../www/env.inc.php';
26 require_once $gfwww.'include/pre.php';
27 require_once $gfcommon.'frs/FRSFile.class.php';
28 require_once $gfcommon.'frs/FRSRelease.class.php';
29 require_once $gfcommon.'frs/FRSPackage.class.php';
31 // Set up this script to run as the site admin
34 $res = db_query_params ('SELECT user_id FROM user_group WHERE admin_flags=$1 AND group_id=$2',
44 if (db_numrows($res) == 0) {
45 // There are no Admins yet, aborting without failing
50 $id=db_result($res,0,0);
53 $res=db_query_params ('SELECT group_id FROM groups WHERE status != $1',
56 $groups =& group_get_objects(util_result_column_to_array($res));
58 for ($g=0; $g<count($groups); $g++) {
61 $newdirlocation = forge_get_config('upload_dir').'/'.$groups[$g]->getUnixName();
62 $cmd="/bin/mkdir $newdirlocation";
64 if (!is_dir($newdirlocation)){
68 $frsps =& get_frs_packages($groups[$g]);
70 for ($p=0; $p<count($frsps); $p++) {
71 if (!is_object($frsps[$p])) {
75 $newdirlocation = forge_get_config('upload_dir').'/'.$frsps[$p]->Group->getUnixName().'/'.$frsps[$p]->getFileName();
76 $cmd="/bin/mkdir $newdirlocation";
78 if (!is_dir($newdirlocation)){
82 $frsrs =& $frsps[$p]->getReleases();
84 for ($r=0; $r<count($frsrs); $r++) {
85 if (!is_object($frsrs[$r])) {
89 $newdirlocation = forge_get_config('upload_dir').'/'.$frsrs[$r]->FRSPackage->Group->getUnixName().'/'.$frsrs[$r]->FRSPackage->getFileName().'/'.$frsrs[$r]->getFileName();
90 $cmd="/bin/mkdir $newdirlocation";
92 if (!is_dir($newdirlocation)){
96 $frsfs =& $frsrs[$r]->getFiles();
97 for ($f=0; $f<count($frsfs); $f++) {
98 if (!is_object($frsfs[$f])) {
101 $olddirlocation = forge_get_config('upload_dir').'/'.$frsfs[$f]->FRSRelease->FRSPackage->Group->getUnixName().'/'.$frsfs[$f]->getName();
102 $newdirlocation = forge_get_config('upload_dir').'/'.$frsfs[$f]->FRSRelease->FRSPackage->Group->getUnixName().'/'.$frsfs[$f]->FRSRelease->FRSPackage->getFileName().'/'.$frsfs[$f]->FRSRelease->getFileName().'/';
103 if (!is_file($newdirlocation.'/'.$frsfs[$f]->getName())) {
104 $cmd="/bin/mv $olddirlocation $newdirlocation";
108 //echo "Already Exists";
115 $cmd = '/bin/chown -R '.forge_get_config('apache_user').':'.forge_get_config('apache_group').' '.forge_get_config('upload_dir');