| |
240 |
240 |
} |
| |
241 |
241 |
|
| |
242 |
242 |
|
| |
243 |
243 |
ad_proc -public fs::new_folder { |
| |
244 |
244 |
{-name:required} |
| |
245 |
245 |
{-pretty_name:required} |
| |
246 |
246 |
{-parent_id:required} |
| |
247 |
247 |
{-creation_user ""} |
| |
248 |
248 |
{-creation_ip ""} |
| |
249 |
249 |
{-description ""} |
| |
250 |
250 |
{-package_id ""} |
| |
251 |
251 |
-no_callback:boolean |
| |
252 |
252 |
} { |
| |
253 |
253 |
Create a new folder. |
| |
254 |
254 |
|
| |
255 |
255 |
@param name Internal name of the folder, must be unique under a given |
| |
256 |
256 |
parent_id |
| |
257 |
257 |
@param pretty_name What we show to users of the system |
| |
258 |
258 |
@param parent_id Where we create this folder |
| |
259 |
259 |
@param creation_user Who created this folder |
| |
260 |
|
@param creation_ip What is the ip address of the creation_user |
| |
|
260 |
@param creation_ip What is the IP address of the creation_user |
| |
261 |
261 |
@param description of the folder. Not used in the current FS UI but might be used elsewhere. |
| |
262 |
262 |
@param package_id Package_id of the package for which to create the new folder. Preferably a file storage package_id |
| |
263 |
263 |
@param no_callback defines if the callback should be called. Defaults to yes |
| |
264 |
264 |
@return folder_id of the newly created folder |
| |
265 |
265 |
} { |
| |
266 |
266 |
if {$creation_user eq ""} { |
| |
267 |
267 |
set creation_user [ad_conn user_id] |
| |
268 |
268 |
} |
| |
269 |
269 |
|
| |
270 |
270 |
if {$creation_ip eq ""} { |
| |
271 |
271 |
set creation_ip [ns_conn peeraddr] |
| |
272 |
272 |
} |
| |
273 |
273 |
|
| |
274 |
274 |
# If the package_id is empty, try the package_id from the parent_object |
| |
275 |
275 |
if {$package_id eq ""} { |
| |
276 |
276 |
set package_id [acs_object::package_id -object_id $parent_id] |
| |
277 |
277 |
|
| |
278 |
278 |
# If the package_id from the parent_id exists, make sure it is a file-storage package_id |
| |
279 |
279 |
if {$package_id ne ""} { |
| |
280 |
280 |
if {[apm_package_key_from_id $package_id] ne "file-storage"} { |
|
| |
810 |
810 |
|
| |
811 |
811 |
db_transaction { |
| |
812 |
812 |
if {![db_string item_exists {}]} { |
| |
813 |
813 |
|
| |
814 |
814 |
set item_id [content::item::new \ |
| |
815 |
815 |
-item_id $item_id \ |
| |
816 |
816 |
-parent_id $parent_id \ |
| |
817 |
817 |
-creation_user "$creation_user" \ |
| |
818 |
818 |
-creation_ip "$creation_ip" \ |
| |
819 |
819 |
-package_id "$package_id" \ |
| |
820 |
820 |
-name $name \ |
| |
821 |
821 |
-storage_type "$storage_type" \ |
| |
822 |
822 |
-content_type "file_storage_object" \ |
| |
823 |
823 |
-mime_type "text/plain" |
| |
824 |
824 |
] |
| |
825 |
825 |
|
| |
826 |
826 |
if {$creation_user ne ""} { |
| |
827 |
827 |
permission::grant -party_id $creation_user -object_id $item_id -privilege admin |
| |
828 |
828 |
} |
| |
829 |
829 |
|
| |
830 |
|
# Deal with notifications. Usually send out the notification |
| |
|
830 |
# Deal with notifications. Usually, send out the notification |
| |
831 |
831 |
# But suppress it if the parameter is given |
| |
832 |
832 |
if {$no_notification_p} { |
| |
833 |
833 |
set do_notify_here_p "f" |
| |
834 |
834 |
} else { |
| |
835 |
835 |
set do_notify_here_p "t" |
| |
836 |
836 |
} |
| |
837 |
837 |
} else { |
| |
838 |
838 |
# th: fixed to set old item_id if item already exists and no new item needed to be created |
| |
839 |
839 |
db_1row get_old_item "" |
| |
840 |
840 |
set do_notify_here_p "f" |
| |
841 |
841 |
} |
| |
842 |
842 |
if {$no_callback_p} { |
| |
843 |
843 |
set revision_id [fs::add_version \ |
| |
844 |
844 |
-name $name \ |
| |
845 |
845 |
-tmp_filename $tmp_filename \ |
| |
846 |
846 |
-package_id $package_id \ |
| |
847 |
847 |
-item_id $item_id \ |
| |
848 |
848 |
-creation_user $creation_user \ |
| |
849 |
849 |
-creation_ip $creation_ip \ |
| |
850 |
850 |
-title $title \ |