diff --git a/content_profile.module b/content_profile.module index 5a523ed..4fc45bd 100644 --- a/content_profile.module +++ b/content_profile.module @@ -90,11 +90,7 @@ function content_profile_page_access($type, $account) { } // Else user may view the page when they are going to create their own profile // or have permission to create it for others. - global $user; - if ($user->uid == $account->uid || user_access('administer content profiles') ){ - return node_access('create', $type); - } - return FALSE; + return user_access('administer content profiles') || node_access('create', $type); } /** @@ -282,7 +278,7 @@ function content_profile_form_alter(&$form, $form_state, $form_id) { if (!empty($_GET['uid']) && ($uid = intval($_GET['uid'])) && ($user = user_load($uid))) { $form['author']['name']['#default_value'] = $user->name; } - if (user_access('administer content profiles')) { + if (user_access('administer content profiles') || node_access('create', $form['#node']->type)) { $form['author']['#access'] = TRUE; $form['#submit'] = array_merge(array('content_profile_form_submit'), (array)$form['#submit']); } @@ -293,7 +289,7 @@ function content_profile_form_alter(&$form, $form_state, $form_id) { * Special submit handler for users with 'administer content profiles' role. */ function content_profile_form_submit($form, &$form_state) { - if (user_access('administer content profiles')) { + if (user_access('administer content profiles') || node_access('create', $form['#node']->type)) { if ($account = user_load(array('name' => $form_state['values']['name']))) { $form_state['values']['uid'] = $account->uid; } @@ -394,14 +390,14 @@ function _content_profile_node_delete($node) { */ function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { - if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer content profiles') && arg(0) != 'admin') { + if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !(user_access('administer content profiles') || node_access('create', $node->type)) && arg(0) != 'admin') { // Check if this nodetype already exists if ($nid = content_profile_profile_exists($node, $node->uid)) { // This node already exists, redirect to edit page drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid); } } - elseif ($op == 'validate' && is_content_profile($node) && user_access('administer content profiles')) { + elseif ($op == 'validate' && is_content_profile($node) && (user_access('administer content profiles') || node_access('create', $node->type))) { $form = $a3; // Only validate if the user-name changed or we add a new node if (!empty($node->nid) && $form['author']['name']['#default_value'] == $node->name) {