You are here

function spaces_user_user in Spaces 6.3

Same name and namespace in other branches
  1. 5.2 spaces_user.module \spaces_user_user()
  2. 6 spaces_user/spaces_user.module \spaces_user_user()
  3. 6.2 spaces_user/spaces_user.module \spaces_user_user()

Implementation of hook_user().

File

spaces_user/spaces_user.module, line 66

Code

function spaces_user_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'form':
      if ($category === 'account') {
        module_load_include('inc', 'spaces', 'spaces.admin');
        $presets = spaces_preset_load(NULL, 'user');
        if (count($presets) === 1) {
          $form['spaces_preset_user'] = array(
            '#type' => 'value',
            '#value' => key($presets),
          );
        }
        else {
          if (count($presets) > 1) {
            $form = array();
            $form['spaces_preset'] = spaces_preset_form($presets, 'user');
          }
        }
        return $form;
      }
      break;
    case 'insert':
    case 'update':

      // Save preset values
      if (!empty($edit['spaces_preset_user'])) {
        $space = spaces_load('user', $account->uid);
        if ($space
          ->activate()) {
          $space->controllers->variable
            ->set('spaces_preset_user', $edit['spaces_preset_user']);
        }
      }
      break;
  }
}