You are here

function profile2_regpath_get_profiles in Profile2 Registration Path 7.2

Same name and namespace in other branches
  1. 7 profile2_regpath.module \profile2_regpath_get_profiles()

Returns object containing all p2rp data.

Parameters

string $path: (optional) path value for WHERE condition. Defaults to NULL.

string $groupby: (optional) field to groupby. Defaults to NULL.

Return value

object An object containing all matching profile2 registration path enabled profile types.

4 calls to profile2_regpath_get_profiles()
profile2_regpath_form_alter in ./profile2_regpath.module
Implements hook_form_alter().
profile2_regpath_menu in ./profile2_regpath.module
Implements hook_menu().
profile2_regpath_menu_alter in ./profile2_regpath.module
Implements hook_menu_alter().
profile2_regpath_update_7130 in ./profile2_regpath.install
Implements hook_update_n().

File

./profile2_regpath.module, line 231
Attach profile2 form to registration form according to path.

Code

function profile2_regpath_get_profiles($path = NULL, $groupby = NULL, $pid = NULL) {

  // Get data object of all registration paths.
  $query = db_select('profile2_regpath', 'pr');
  $query
    ->join('profile_type', 'pt', 'pr.profile_id = pt.id');
  $query
    ->fields('pr', array(
    'path',
    'roles',
    'misc',
    'status',
  ));
  $query
    ->fields('pt', array(
    'id',
    'label',
    'type',
  ));
  if ($path) {
    $query
      ->condition('path', $path);
  }
  if ($groupby) {
    $query
      ->groupBy($groupby);
  }
  if ($pid) {
    $query
      ->condition('profile_id', $pid);
  }
  $query
    ->condition('pr.status', 1);
  $query
    ->orderBy('pr.weight', 'ASC');
  $result = $query
    ->execute();
  $profile_types = $result
    ->fetchAll();
  return $profile_types;
}