jeffd
committed
on 25 Mar 04
make static pages work with tip 43; bump to 5.2.0d2, upgrade oracle, postgres
openacs-4/.../oracle/static-page-pb.sql (+6 -3)
108 108         end;
109 109
110 110         function get_root_folder (
111 111                 package_id      in apm_packages.package_id%TYPE
112 112         ) return sp_folders.folder_id%TYPE is
113 113                 folder_exists_p integer;
114 114                 folder_id       sp_folders.folder_id%TYPE;
115 115         begin
116 116                 -- If there isn't a root folder for this package, create one.
117 117                 -- Otherwise, just return its id.
118 118                 select count(*) into folder_exists_p from dual where exists (
119 119                         select 1 from sp_folders
120 120                         where package_id = static_page.get_root_folder.package_id
121 121                         and parent_id is null
122 122                 );
123 123
124 124                 if folder_exists_p = 0 then
125 125                         folder_id := static_page.new_folder (
126 126                           -- name NEEDS to be unique, label does not
127 127                           name  => 'sp_root_package_id_' || package_id,
128                             label => 'sp_root_package_id_' || package_id
  128                           label => 'sp_root_package_id_' || package_id,
  129                           package_id => package_id
129 130                         );
130 131
131 132                         update sp_folders
132 133                                 set package_id = static_page.get_root_folder.package_id
133 134                                 where folder_id = static_page.get_root_folder.folder_id;
134 135
135 136                         acs_permission.grant_permission (
136 137                                 object_id => folder_id,
137 138                                 grantee_id => acs.magic_object_id('the_public'),
138 139                                 privilege => 'general_comments_create'
139 140                         );
140 141                         -- The comments will inherit read permission from the pages,
141 142                         -- so the public should be able to read the static pages.
142 143                         acs_permission.grant_permission (
143 144                                 object_id => folder_id,
144 145                                 grantee_id => acs.magic_object_id('the_public'),
145 146                                 privilege => 'read'
146 147                         );
147 148                 else
148 149                         select folder_id into folder_id from sp_folders
 
151 152                 end if;
152 153
153 154                 return folder_id;
154 155         end get_root_folder;
155 156
156 157
157 158         function new_folder (
158 159                 folder_id       in sp_folders.folder_id%TYPE
159 160                                         default null,
160 161                 name    in cr_items.name%TYPE,
161 162                 label   in cr_folders.label%TYPE,
162 163                 description     in cr_folders.description%TYPE default null,
163 164                 parent_id       in cr_items.parent_id%TYPE default null,
164 165                 creation_date   in acs_objects.creation_date%TYPE
165 166                                         default sysdate,
166 167                 creation_user   in acs_objects.creation_user%TYPE
167 168                                         default null,
168 169                 creation_ip     in acs_objects.creation_ip%TYPE
169 170                                         default null,
170 171                 context_id      in acs_objects.context_id%TYPE
  172                                         default null,
  173                 package_id      in apm_packages.package_id%TYPE
171 174                                         default null
172 175         ) return sp_folders.folder_id%TYPE is
173 176                 v_folder_id     sp_folders.folder_id%TYPE;
174 177                 v_parent_id     cr_items.parent_id%TYPE;
175 178                 v_package_id    apm_packages.package_id%TYPE;
176 179         begin
177 180                 if parent_id is null then
178 181                         v_parent_id := 0;
179 182                 else
180 183                         v_parent_id := parent_id;
181 184                 end if;
182 185
183 186                 v_folder_id := content_folder.new (
184 187                         name    => static_page.new_folder.name,
185 188                         label   => static_page.new_folder.label,
186 189                         folder_id       => static_page.new_folder.folder_id,
187 190                         parent_id       => v_parent_id,
188 191                         description     => static_page.new_folder.description,
189 192                         creation_date   => static_page.new_folder.creation_date,
190 193                         creation_user   => static_page.new_folder.creation_user,