FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
mk_fmdirs.php
1 #!/usr/bin/php
2 
3 <?php
4 
5 /***********************************************************
6  mk_fmdirs.php
7  Copyright (C) 2007 Hewlett-Packard Development Company, L.P.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  version 2 as published by the Free Software Foundation.
12 
13  This program 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 along
19  with this program; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  ***********************************************************/
22 
32 // NOTE: This code is not really used anymore !!!!!!!!!!!!!!!!!!!!!!
33 
34 // For now, assume previous process has determined if the archive has changed
35 // and just calls this routine to do the load. That is, this routine is
36 // not expected to determine if the archive has changed.
37 
38 //issues:
39 // what to do if all the data is not present. For example, osrb projects
40 // may not have a version, rank, or other data that is there for projects
41 // from freshmeat. Talk with Bob, use some sort of 'default' if there
42 // is no data.
43 
44 # 1. process parameter(s) and sanity check.
45 # 2. connect to db
46 # 3. If folder doesn't exist, create it.
47 # is it possible to make this recursive and do subfolders as well?
48 # 4. After all needed folders are created,
49 # things are a bit fuzzy below....
50 # 5. create upload record.
51 # 6. unpack
52 # 7. schedule nomos...
53 # What else?
54 /*
55  * general process is: createfolders, then use createfoldercontents to
56  * associate folders with each other....
57  */
58 
59 require_once("FIXMETOBERELATIVE/pathinclude.php");
60 /* the items below no longer exist, my this code is old.... */
61 require_once("$PHPDIR/webcommon.h.php");
62 require_once("$PHPDIR/jobs.h.php");
63 require_once("$PHPDIR/db_postgres.h.php");
64 
65 // if you do it yourself....use the lib...
66 #$_pg_conn = pg_connect(str_replace(";", " ",
67 # file_get_contents("{$SYSCONFDIR}/{$PROJECT}/Db.conf")));
68 
69 $path = "{$SYSCONFDIR}/$PROJECT}/Db.conf";
70 $alpha_buckets = array('a-c',
71  'd-f',
72  'g-i',
73  'j-l',
74  'm-o',
75  'p-r',
76  's-u',
77  'v-z'
78  );
79 db_init($path);
80 
81 if (!$_pg_conn) {
82  echo "ERROR: could not connect to DB\n";
83  exit(1);
84 }
85 
86 /*
87  * Steps are:
88  * 1. create top folder
89  * using value returned from cratefolder,
90  * 2. use that in a loop to create the other folders.
91  * 3. Other folders are created with
92  * createrfolder, and then associated with parent folder with
93  * createfoldercontents.
94  */
95 
96 
97 $sql = 'select users.root_folder_fk from users';
98 
99 // who is my parent?
100 $pfolder4user = db_query1($sql);
101 
102 // Create top level folder 'Freshmeat'
103 $f_pk = createfolder($pfolder4user, 'Freshmeat',
104  "Top folder for FM Archives");
105 
106 $sql_fm =
107  "select folder_pk, folder_name from folder where folder_name='Freshmeat'";
108 $fm_pk = db_query1($sql_fm);
109 
110 // Create the alpha bucket folders and associate them with the
111 // Freshmeat folder.
112 for ($num=0; $num < count($alpha_buckets); $num++){
113 #echo "arraychunks: {$alpha_buckets[$num]}\n";
114 
115 $folder_pk = createfolder(
116  $fm_pk, "{$alpha_buckets[$num]}", "Holds Freshmeat archives");
117 
118 $fold_cont_pk = createfoldercontents($fm_pk, $folder_pk, 1);
119 }
120 
121 
122 ?>