You are here

party_profile.module in Party 7

Same filename and directory in other branches
  1. 8.2 modules/party_profile/party_profile.module

Support for configurable user profiles which are not attached to users.

File

modules/party_profile/party_profile.module
View source
<?php

/**
 * @file
 * Support for configurable user profiles which are not attached to users.
 */

/**
 * Implements hook_profile2_type_insert().
 */
function party_profile_profile2_type_insert($type) {
  cache_clear_all('party:data_set_info', 'cache');
}

/**
 * Implements hook_profile2_type_update().
 */
function party_profile_profile2_type_update($type) {
  cache_clear_all('party:data_set_info', 'cache');
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function party_profile_form_profile2_type_form_alter(&$form, &$form_state) {
  unset($form['data']['registration']);
  $form['registration'] = array();
}

/**
 * Implements hook_profile2_access().
 */
function party_profile_profile2_access($op, $profile, $account) {

  // An object means we're dealing with an actual entity. We will ignore any
  // other mode, as creation etc of data sets will need to be done through a
  // data controller for it to be attached. Operations on an existing profile
  // can be done directly.
  if (is_object($profile) && !empty($profile->party_attaching_party)) {
    $party = party_load($profile->party_attaching_party);
    if (party_access($op, $party, $profile->data_set_name, $account)) {
      return TRUE;
    }
  }
}