mode = variable_get('subdomain_mode', 'user'); $this->source = variable_get('subdomain_source', 'default'); $this->home = variable_get('subdomain_home', 'default'); $this->view = variable_get('subdomain_view', ''); if ($this->source == 'default') { $this->form_field = $this->default_form_field(); } else { $this->form_field = 'subdomain'; } } function default_form_field() { return 'name'; } function get_homepage_path($sid) { if ($this->home == 'default') { return subdomain()->base_path($sid); } else { return "subdomain/homepage/$sid"; } } function data_handler($op, $object) { switch ($op) { case 'insert': case 'update': $this->save($object); break; case 'delete': $this->delete($object); break; } } /** * Prepares subdomain for saving */ function clean($raw) { return strtolower(preg_replace("/[^a-zA-Z-]/", "", $raw)); } function exists($value) { $sid = subdomain_get_sid($value); return !empty($sid); } function save_record($id, $raw, $insert = FALSE) { $row->sid = $id; $row->subdomain = subdomain()->clean($raw); drupal_write_record('subdomain', $row, $insert ? array() : array('sid')); } function delete_record($sid) { db_query('DELETE FROM {subdomain} WHERE sid = %d', $sid); } }