You are here

public function NodeRegistrationNodeSettings::__construct in Node registration 7

Init the node registration node settings object.

File

includes/node_registration.node_settings.inc, line 27
Node settings class.

Class

NodeRegistrationNodeSettings
Node settings class.

Code

public function __construct($node) {
  $nid = empty($node->nid) ? 0 : (int) $node->nid;
  $type = $node->type;

  // Save parent/owner.
  $this->nid = $nid;
  $this->node = $node;

  // Don't do anything for disabled content types.
  if (!_node_registration_node_type_enabled($type)) {
    return;
  }

  // Node type settings.
  $node_type_settings = _node_registration_node_type_settings($type);
  $this
    ->_fill($node_type_settings);

  // Fetch node settings.
  $settings = db_select('node_registration_node', 'rn')
    ->fields('rn')
    ->condition('nid', $nid, '=')
    ->execute()
    ->fetchAssoc();
  if ($settings) {

    // Store node settings.
    $this
      ->_fill($settings);

    // Serialized settings.
    if ($more_settings = @unserialize($settings['settings'])) {
      $this->more_settings = $more_settings;
      $this
        ->_fill($more_settings);
    }
  }

  // Shortcuts for anonymous and authenticated access by # slots.
  $this->allow_anonymous = 0 < $this->max_slots_per_registration_anonymous;
  $this->allow_authenticated = 0 < $this->max_slots_per_registration_authenticated;
}