46 $user_name =
"Default User";
47 $sql =
"select user_pk from users where user_name='$user_name'";
48 $result = pg_query($PG_CONN, $sql);
50 if (pg_num_rows($result) == 0)
54 $sql =
"INSERT INTO users (user_name,user_desc,user_seed,user_pass,user_perm,user_email,root_folder_fk) 55 VALUES ('$user_name','Default User when nobody is logged in','Seed','Pass',$Perm,NULL,1);";
56 $result = pg_query($PG_CONN, $sql);
59 pg_free_result($result);
63 $sql =
"select user_pk from users where user_name='$user_name'";
64 $result = pg_query($PG_CONN, $sql);
66 if (pg_num_rows($result) == 0)
70 $Seed = rand() . rand();
71 $Hash = sha1($Seed . $user_name);
72 $sql =
"INSERT INTO users (user_name,user_desc,user_seed,user_pass,user_perm,user_email,root_folder_fk) 73 VALUES ('$user_name','Default Administrator','$Seed','$Hash',$Perm,'y',1);";
74 $result = pg_query($PG_CONN, $sql);
77 pg_free_result($result);
80 $sql =
"select user_pk, user_name, root_folder_fk from users";
81 $UserResult = pg_query($PG_CONN, $sql);
89 while($UserRow = pg_fetch_assoc($UserResult))
91 $user_name = $UserRow[
'user_name'];
92 $user_pk = $UserRow[
'user_pk'];
93 $root_folder_fk = $UserRow[
'root_folder_fk'];
94 $sql =
"select group_pk from groups where group_name='$user_name'";
95 $GroupResult = pg_query($PG_CONN, $sql);
97 if (pg_num_rows($GroupResult) == 0)
99 pg_free_result($GroupResult);
101 $sql =
"insert into groups(group_name) values ('$user_name')";
102 $result = pg_query($PG_CONN, $sql);
105 $sql =
"select group_pk from groups where group_name='$user_name'";
106 $GroupResult = pg_query($PG_CONN, $sql);
109 $GroupRow = pg_fetch_assoc($GroupResult);
110 $group_pk = $GroupRow[
'group_pk'];
111 pg_free_result($GroupResult);
114 $sql =
"select * from group_user_member where group_fk='$group_pk' and user_fk='$user_pk'";
115 $GroupUserResult = pg_query($PG_CONN, $sql);
117 if (pg_num_rows($GroupUserResult) == 0)
120 $sql =
"insert into group_user_member(group_fk, user_fk, group_perm) values($group_pk, $user_pk, 1)";
121 $result = pg_query($PG_CONN, $sql);
124 pg_free_result($GroupUserResult);
129 $sql =
"select upload_pk from upload where user_fk='$user_pk'";
130 $UploadResult = pg_query($PG_CONN, $sql);
132 while($UploadRow = pg_fetch_assoc($UploadResult))
134 $upload_pk = $UploadRow[
'upload_pk'];
135 $sql =
"select perm_upload_pk from perm_upload where group_fk='$group_pk' and upload_fk='$upload_pk'";
136 $PermUploadResult = pg_query($PG_CONN, $sql);
138 if (pg_num_rows($PermUploadResult) == 0)
141 $sql =
"insert into perm_upload(perm, upload_fk, group_fk) values($perm_admin, $upload_pk, $group_pk)";
142 $result = pg_query($PG_CONN, $sql);
145 pg_free_result($PermUploadResult);
147 pg_free_result($UploadResult);
150 pg_free_result($UserResult);
154 $sql =
"delete from sysconfig where variablename = 'GlobalBrowse'";
155 $result = pg_query($PG_CONN, $sql);
157 pg_free_result($result);
160 $sql =
"SELECT conname from pg_constraint where conname= 'license_ref_rf_shortname_key';";
161 $conresult = pg_query($PG_CONN, $sql);
163 $tt = pg_num_rows($conresult);
164 if (pg_num_rows($conresult) == 0) {
165 $sql =
"ALTER TABLE license_ref ADD CONSTRAINT license_ref_rf_shortname_key UNIQUE (rf_shortname); ";
166 $result = pg_query($PG_CONN, $sql);
168 pg_free_result($result);
170 pg_free_result($conresult);
173 $sql =
"CREATE VIEW uploadtree_a_upload AS SELECT uploadtree_pk,upload_fk,upload_pk FROM uploadtree_a LEFT OUTER JOIN upload ON upload_fk=upload_pk; 174 DELETE FROM uploadtree_a WHERE uploadtree_pk IN (SELECT uploadtree_pk FROM uploadtree_a_upload WHERE upload_pk IS NULL); 175 DROP VIEW uploadtree_a_upload;";
176 $result = pg_query($PG_CONN, $sql);
178 pg_free_result($result);
180 $sql =
"SELECT conname from pg_constraint where conname= 'uploadtree_a_upload_fk_fkey';";
181 $conresult = pg_query($PG_CONN, $sql);
183 if (pg_num_rows($conresult) == 0) {
184 $sql =
"ALTER TABLE uploadtree_a ADD CONSTRAINT uploadtree_a_upload_fk_fkey FOREIGN KEY (upload_fk) REFERENCES upload (upload_pk) ON DELETE CASCADE; ";
185 $result = pg_query($PG_CONN, $sql);
187 pg_free_result($result);
189 pg_free_result($conresult);
194 $command =
"$MODDIR/nomos/agent/nomos -V";
195 $version = exec($command, $out, $return_var);
196 if (0 == $return_var)
198 $pattern =
'/r\((\w+)\)/';
199 preg_match($pattern, $version, $matches);
204 if (empty($matches[1]) || (5 > strlen($matches[1]) && $matches[1] <= $version230)) {
205 require_once(
"$LIBEXECDIR/fo_mapping_license.php");
206 print
"Rename license in $LIBEXECDIR\n";
213 print
"Clear out the report cache.\n";
214 $sql =
"DELETE FROM report_cache;";
215 $result = pg_query($PG_CONN, $sql);
217 pg_free_result($result);
renameLicenses21to22($verbose)
Create map of old_shortname to new_shortname for 2.1 to 2.2 and call renameLicenses.
Migrate_21_22($Verbose)
Create new groups, group_user_member, perm_upload and perm_folder records to support 2...
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
#define PERM_ADMIN
Administrator.