pa_new_root_folder (private)

 pa_new_root_folder [ package_id ]

Defined in packages/photo-album/tcl/photo-album-procs.tcl

Creates a new root folder for a package, and returns id. A hackish function to get around the fact that we can't run code automatically when a new package instance is created.

Parameters:
package_id (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 pa_get_root_folder_internal pa_get_root_folder_internal (private) pa_new_root_folder pa_new_root_folder pa_get_root_folder_internal->pa_new_root_folder ad_conn ad_conn (public) pa_new_root_folder->ad_conn db_exec_plsql db_exec_plsql (public) pa_new_root_folder->db_exec_plsql db_string db_string (public) pa_new_root_folder->db_string db_transaction db_transaction (public) pa_new_root_folder->db_transaction parameter::get parameter::get (public) pa_new_root_folder->parameter::get

Testcases:
No testcase defined.
Source code:
    if {$package_id eq ""} {
    set package_id [ad_conn package_id]
    }

    # wtem@olywa.net, 2001-09-22
    # the PhotoDir parameter goes away with new CR storage scheme

    # wtem@olywa.net, 2001-09-22
    # original pl/sql wrapped up in function to simplify code and porting
    db_transaction {
    # create new root folder
    
    set new_folder_id [db_exec_plsql make_new_root {
    begin
    :1 := photo_album.new_root_folder(:package_id);
    end;
    }]
    
    # grant default permissions to new root folder

    # default permissions stored in package parameter as a list of grantee privilege pairs
    # the grantee can be anything that is or returns a party_id such as an integer, a subquery,
    # or a function
    
    set perm_lst [split [parameter::get -parameter DefaultRootFolderPrivileges] " "]

    foreach {party privilege}  $perm_lst {
        # wtem@olywa.net, 2001-10-15
        # urgh, originally the parameter had the pl/sql embedded in it
        set grantee_id [db_string get_grantee_id "select acs.magic_object_id('$party') from dual"]
      
        db_exec_plsql grant_default {
        begin
          acs_permission.grant_permission (
                object_id  => :new_folder_id,
                grantee_id => :grantee_id,
                privilege  => :privilege
          );
        end;
        }
    }
    }
    # since this is executed the first time a package instance is accessed,
    # make sure the upload dir exists

    ### probable partial change
    # wtem@olywa.net, 2001-09-19
    # this initializes corresponding directory structure in the file-system
    # we should be able to eliminate this now that we are using CR storage
    # pa_assert_dir -check_base_path ""
    ### clean
    return $new_folder_id
Generic XQL file:
packages/photo-album/tcl/photo-album-procs.xql

PostgreSQL XQL file:
<fullquery name="pa_new_root_folder.make_new_root">
    <querytext>
      select photo_album__new_root_folder(:package_id)  
      </querytext>
</fullquery>

<fullquery name="pa_new_root_folder.get_grantee_id">
    <querytext>
      select acs__magic_object_id('$party') 
      </querytext>
</fullquery>

<fullquery name="pa_new_root_folder.grant_default">
    <querytext>
      select acs_permission__grant_permission (
      :new_folder_id, -- object_id
      :grantee_id, -- grantee_id
      :privilege -- privilege
      )
      </querytext>
</fullquery>
packages/photo-album/tcl/photo-album-procs-postgresql.xql

Oracle XQL file:
<fullquery name="pa_new_root_folder.make_new_root">
    <querytext>
       begin
	:1 := photo_album.new_root_folder(:package_id);
       end;
      </querytext>
</fullquery>

<fullquery name="pa_new_root_folder.get_grantee_id">
    <querytext>
      select acs.magic_object_id('$party') from dual
      </querytext>
</fullquery>

<fullquery name="pa_new_root_folder.grant_default">
    <querytext>
      
		begin
		  acs_permission.grant_permission (
	            object_id  => :new_folder_id,
	            grantee_id => :grantee_id,
	            privilege  => :privilege
		  );
		end;
	    
      </querytext>
</fullquery>
packages/photo-album/tcl/photo-album-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: