acs_user::create_portrait (public)

 acs_user::create_portrait -user_id user_id \
    [ -description description ] [ -filename filename ] \
    [ -mime_type mime_type ] -file file

Defined in packages/acs-tcl/tcl/community-core-procs.tcl

Sets (or resets) the portraif for current user to the one specified.

Switches:
-user_id
(required)
user_id of user whose portrait we want to set.
-description
(optional)
A caption for the portrait.
-filename
(optional)
Original filename of the portrait. Used to guess the mimetype if an explicit one is not specified.
-mime_type
(optional)
mimetype of the portrait. If missing, filename will be used to guess one.
-file
(required)
Actual file containing the portrait
Returns:
item_id of the new content item

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_admin_merge_MergeUserInfo acs_admin_merge_MergeUserInfo (test acs-admin) acs_user::create_portrait acs_user::create_portrait test_acs_admin_merge_MergeUserInfo->acs_user::create_portrait test_auth_authenticate auth_authenticate (test acs-authentication) test_auth_authenticate->acs_user::create_portrait test_demote_promote_a_user demote_promote_a_user (test acs-tcl) test_demote_promote_a_user->acs_user::create_portrait acs_user::erase_portrait acs_user::erase_portrait (public) acs_user::create_portrait->acs_user::erase_portrait ad_conn ad_conn (public) acs_user::create_portrait->ad_conn content::item::new content::item::new (public) acs_user::create_portrait->content::item::new db_exec_plsql db_exec_plsql (public) acs_user::create_portrait->db_exec_plsql packages/acs-subsite/www/user/portrait/upload.tcl packages/acs-subsite/ www/user/portrait/upload.tcl packages/acs-subsite/www/user/portrait/upload.tcl->acs_user::create_portrait

Testcases:
acs_admin_merge_MergeUserInfo, auth_authenticate, demote_promote_a_user
Source code:
    # Delete old portrait, if any
    acs_user::erase_portrait -user_id $user_id

    if {$mime_type eq ""} {
        # This simple check will suffice here. CR has its own means to
        # ensure a valid mimetype
        set mime_type [ns_guesstype $filename]
    }

    # Create the new portrait
    set item_id [content::item::new  -name "portrait-of-user-$user_id"  -parent_id $user_id  -content_type image  -storage_type file  -creation_user [ad_conn user_id]  -creation_ip [ad_conn peeraddr]  -description $description  -tmp_filename $file  -is_live t  -mime_type $mime_type]

    # Create portrait relationship
    db_exec_plsql create_rel {}

    return $item_id
Generic XQL file:
packages/acs-tcl/tcl/community-core-procs.xql

PostgreSQL XQL file:
<fullquery name="acs_user::create_portrait.create_rel">
    <querytext>

    select acs_rel__new (
    null,
    'user_portrait_rel',
    :user_id,
    :item_id,
    null,
    null,
    null
    )

  </querytext>
</fullquery>
packages/acs-tcl/tcl/community-core-procs-postgresql.xql

Oracle XQL file:
<fullquery name="acs_user::create_portrait.create_rel">
    <querytext>

    begin
    :1 := acs_rel.new (
    rel_type => 'user_portrait_rel',
    object_id_one => :user_id,
    object_id_two => :item_id);
    end;

  </querytext>
</fullquery>
packages/acs-tcl/tcl/community-core-procs-oracle.xql

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