I have Role A, with content profile cp_a, and Role B, with content profile cp_b. I want to give users with Role A the permission to create users with Role B (possible thanks to Role delegation module) and the permission to fill their content profile; so it seems I would need the following permissions:

                           Role A    Role B
create cp_a content          X
create cp_b content          X         X
delete any cp_a content
delete any cp_b content      X
delete own cp_a content      X
delete own cp_b content                X
edit any cp_a content
edit any cp_b content        X
edit own cp_a content        X
edit own cp_b content                  X

However, this will make cp_b a content profile for Role A, because content_profile relies on the "create CONTENT_TYPE content" permission to link content types to roles.

See some similar (recent) issues: #375454: Make CP role aware, #598212: Enable administrators to manage other users content profiles, #425144: Other user's profile creation requires "administer content" privilege..

I have created a patch (against 6.x-1.0-beta4) similar to #375454: Make CP role aware (issue closed, but the patch was not integrated) that let site admins link a content type to specific roles in the Content Profile section of a content type edit page. Also, when a content profile node is created for a user, its uid is automatically set to the uid of this user (not the uid of the node creator), even if the node creator does not have the "administer node" permission.

Note that a Role A user can still create a cp_b through the node/add/cp_b URL; however, it will not be shown in its profile.

This patch includes an update to the database (content_profile_update_6005), so you need to run update.php after installing this patch. I strongly advise you to backup your database first.

CommentFileSizeAuthor
#7 content_profile-role-aware-3.patch8.65 KBAnonymous (not verified)
#6 content_profile-role-aware-2.patch8.24 KBAnonymous (not verified)
content_profile-role-aware.patch8.08 KBpfournier

Comments

pfournier’s picture

Update:
This patch includes an update to the database (content_profile_update_6005), so you need to run update.php after installing this patch. I strongly advise you to backup your database first.

cyberwolf’s picture

elseif ($op == 'presave' && is_content_profile($node) && !isset($node->nid)) {
  // If we create a content_profile node, make sure uid matches the user name for which this node is created.
  $uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $node->name));
  // Make extra-sure we only have one content_profile node for this user.
  if ($uid && !content_profile_profile_exists($node, $uid)) {
    $node->uid = $uid;
}

Am I right in saying that this code adds a new requirement to the profile nodes: that its descriptive name needs to match the user login name?

A similar discussion is going on here: http://drupal.org/node/425144.

cyberwolf’s picture

Never mind my remarks about the patch. $node->name apparently refers to the name of the user with id $node->uid. It gets loaded into $node by node_load().

finex’s picture

I'd like this feature too.

marcus_clements’s picture

+1

Anonymous’s picture

StatusFileSize
new8.24 KB

It appears that the line numbering for version 1.0 is off causing hunk #3 (at line 93) to fail, because the hunk should now start at 94. I'm uploading the same patch but with the correct line number.

Anonymous’s picture

StatusFileSize
new8.65 KB

Oops, that was a Mercurial diff instead of a regular diff. Re-attaching.

dawansv’s picture

FilmKnurd: I wanted to try your last patch but it looks like you created that last patch backward (the patch reverts the new code to the old code)...

--- ./content_profile.install 2010-08-12 10:58:46.000000000 -0500
+++ ../content_profile.orig/content_profile.install 2010-08-12 10:58:30.000000000 -0500