CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Multi-Site functionality »
  • Using Civi and Domain Access (Drupal)
Pages: [1] 2

Author Topic: Using Civi and Domain Access (Drupal)  (Read 7729 times)

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Using Civi and Domain Access (Drupal)
May 15, 2012, 12:01:45 pm
I'm using Drupal Domain Access (DA) to create a multi-site - the system allows for enormous flexibility in publishing content across multiple sites, which is exactly what I'm looking to do, and it's working nicely.

I've gone through the instructions at http://wiki.civicrm.org/confluence/display/CRMDOC41/Multi+Site+Installation - the instructions relate to multi-site using the sites folder. Unlike the "sites" method, everything in DA resides in the same folder using the same database and the site determination is done using DNS configuration. So there's no way that I can see to provide the necessary setup file for additional domains.

It looks to my (unsophisticated) eye like the only missing piece here would be for additional Civi domains to be able to read a settings file other than the civicrm.settings.php and even in that case, the only relevant line would be:
Code: [Select]
define( 'CIVICRM_DOMAIN_ID'      , 2 ); It seems like there might be a relatively simple solution here, but it's beyond the scope of my abilities to figure it out.

My particular use case is that of a committee site being able to share resources and content with distributed sites for individual committee members, which has powerful and positive implications.

Any ideas here? Any guidance much appreciated... thanks!

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Using Civi and Domain Access (Drupal)
May 15, 2012, 01:23:30 pm
hi - we are using DA for several clients - I will mention the word 'coffee' to Eileen to get her attention then slip in the idea of responding here ;-)
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: Using Civi and Domain Access (Drupal)
May 15, 2012, 01:35:28 pm
I'd be happy to send over a fresh pot, but it would most certainly be cold by the time it gets there.  :)

Thanks much!

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Using Civi and Domain Access (Drupal)
May 15, 2012, 10:26:52 pm
might be best to watch for her on IRC - you may have more luck than I do sitting across the room from her - either 'coffee' or 'warm beer' should get her attention
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Using Civi and Domain Access (Drupal)
May 28, 2012, 03:45:21 am
I'm also very interested to learn how to use the Domain Access module with CiviCRM to run multisite.
Graham Mitchell
http://mc3.coop

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Using Civi and Domain Access (Drupal)
May 28, 2012, 03:50:31 am
not sure there is much magic sauce being added - here is a snippet for one domain site

Code: [Select]
define( 'CIVICRM_MULTISITE'           , 1 );
// define( 'CIVICRM_UNIQ_EMAIL_PER_SITE' , null );
define( 'CIVICRM_DOMAIN_ID'      , 4 );
define( 'CIVICRM_DOMAIN_GROUP_ID', 14 );
define( 'CIVICRM_DOMAIN_ORG_ID'  , 779);
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: Using Civi and Domain Access (Drupal)
May 29, 2012, 09:39:39 am
Thanks, Pete - my issue is with several sites (I'm starting with three).

Are you saying that multiple versions of
Code: [Select]
define( 'CIVICRM_DOMAIN_ID'      , 4 ); in the civicrm.settings.php file would work? For example:

 
Code: [Select]
define( 'CIVICRM_DOMAIN_ID'      , 4 );
define( 'CIVICRM_DOMAIN_ID'      , 6 );
define( 'CIVICRM_DOMAIN_ID'      , 7 );

(and the same for group and org IDs)

and then the civicrm/admin/setting/preferences/multisite?reset=1 page would change depending on what domain it's generated on, allowing parent groups, etc. to be assigned for each domain?

If so, I'll try that on a development sandbox when I get a chance and see if it works - the site I'm working on now is close to deployment and my intention right now is to "punt" by creating an Event content type, which can be controlled on an affiliate basis.

Detailed instructions as in http://wiki.civicrm.org/confluence/display/CRMDOC41/Multi+Site+Installation to use with DA would be great - it seems to me that all the right pieces are there for DA multisite if I only knew how to put it all together... thanks!

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Using Civi and Domain Access (Drupal)
May 29, 2012, 01:26:50 pm
I will get eileen on here later today to clarify
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Using Civi and Domain Access (Drupal)
May 29, 2012, 05:05:44 pm
This is what we have in our civicrm.settings.php (not the real urls obviously) - this one is taken off a drupal 6 example - it might be slightly different for d7

$baseURL = 'https://fuzion.co.nz/';
$subdomain = empty($_domain['subdomain'])?$_SERVER['HTTP_HOST']:$_domain['subdomain'];
if (!empty($subdomain  )) {
  $scheme = empty($_domain['scheme'])?"https":$_domain['scheme'];
  $baseURL  =  $scheme . '://' . $subdomain ;
  switch ($subdomain ){
    case 'eileen.fuzion.co.nz' :
    case 'peter.fuzion.co.nz' :
      define( 'CIVICRM_DOMAIN_ID' , 15 );
      break;
  case 'cat.com' :
  case 'christinemilne.ubox.greens.org.au' :
    define( 'CIVICRM_DOMAIN_ID' , 16 );
     break;
  default:
     define( 'CIVICRM_DOMAIN_ID' , 6 );
    }
define( 'CIVICRM_UF_BASEURL' , $baseURL  );
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: Using Civi and Domain Access (Drupal)
May 30, 2012, 03:06:17 pm
Gosh... thanks, Eileen! (I read your post on Multisite child group resolution and you scare the daylights out of me.)  :o

At the risk of looking like a dum-dum (I'm just a designer, not a coder), I'm assuming that the code is for a Domain Access site with affiliates.

The site(s) are currently in a subdirectory of the company site and the main site is close to being deployed. And I hope you don't mind me getting detailed - I'd prefer to be as specific as I can. ([test_domain] and what's not in quotes inside square brackets are simply placeholders for actual domains. ['subdomain'] and the like are literal.)

OK - here goes...

Main site: http://master.[test_domain].com (it will eventually replace the client's existing site.)
Affiliate site 1: http://gregory.[test_domain].com (this will eventually be http://gregory.com.)
Affiliate site 2: http://smithtown.[test_domain].com (this will eventually be http://smithtown.com)

Let's say the domain names for the affiliate sites would be "The Gregory Site" and "The Smithtown Site."

The domain ID for the main site is 1; for the next two, they are 5 and 6, respectively (as defined in DA).

So, reading the Multi-Site installation instructions, and if I read the PHP snippet properly, I would:

Perform the following SQL command:

Code: [Select]
INSERT INTO `civicrm_domain` (`name`, `description`, `version`)
SELECT 'The Gregory Site', 'Some description here', cd.version FROM civicrm_domain cd WHERE cd.id = 1;
INSERT INTO `civicrm_domain` (`name`, `description`, `version`)
SELECT 'The Smithtown Site', 'Some description here', cd.version FROM civicrm_domain cd WHERE cd.id = 1;

Then I would modify the civicrm_codebase/sql/civicrm_navigation.mysql file as follows:

Change
Code: [Select]
SELECT @domainID := id FROM civicrm_domain where name = 'Default Domain Name'; to
Code: [Select]
SELECT @domainID := id FROM civicrm_domain where name = 'The Gregory Site'; and import the file.

I would then do the same for the next affiliate:

Change
Code: [Select]
SELECT @domainID := id FROM civicrm_domain where name = 'Default Domain Name'; to
Code: [Select]
SELECT @domainID := id FROM civicrm_domain where name = 'The Smithtown Site'; and import the file.

In the civicrm.settings.php file, I would now add the following (sans comments):

Code: [Select]
$baseURL = 'http://master.[test_domain].com/'; /** to eventually become http://[deployed_domain].com */
$subdomain = empty($_domain['subdomain'])?$_SERVER['HTTP_HOST']:$_domain['subdomain'];
if (!empty($subdomain  )) {
  $scheme = empty($_domain['scheme'])?"http":$_domain['scheme'];
  $baseURL  =  $scheme . '://' . $subdomain ;
  switch ($subdomain ){
    case 'gregory.[test_domain].com' :
      define( 'CIVICRM_DOMAIN_ID' , 5 );
      break;
  case 'smithtown.[test_domain].com' :
    define( 'CIVICRM_DOMAIN_ID' , 6 );
     break;
  default:
     define( 'CIVICRM_DOMAIN_ID' , 1 );
    }
define( 'CIVICRM_UF_BASEURL' , $baseURL  );
}

If I've got this straight, this should then work in the sandbox and I'd need to make the appropriate modifications when the main site goes up so that the affiliates refer to the main domain. When the affiliates are ready to be deployed, I'd then add the actual URLs as additional "case" statements; e.g.,
Code: [Select]
case '[smithtown.com]' : for the second affiliate.

Am I on the right track here? Or am I making a complete idiot out of myself?

Regardless, thank you for your guidance and for all the work you're doing! I'm hoping this will prove useful... rock on!
« Last Edit: May 31, 2012, 08:46:44 am by bcobin »

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Using Civi and Domain Access (Drupal)
May 30, 2012, 03:24:21 pm
yes - that's definitely the right track!

Prior to 4.1 you needed to configure a 'domain group' in civicrm.settings.php - however - this setting is now available in the UI. When a contact is created on a site they will be added to that site's domain group.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Using Civi and Domain Access (Drupal)
May 30, 2012, 11:33:05 pm
Excellent stuff. Many thanks to Eileen for sharing this approach, and to bcobin for setting it out so clearly and thoroughly. This is most helpful.
Graham Mitchell
http://mc3.coop

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: Using Civi and Domain Access (Drupal)
May 31, 2012, 05:34:14 am
OK - not quite soup yet...

1. Two changes to the snippet I posted (I've edited it to reflect them):

The snippet (as originally posted) needs a trailing bracket.
Change "https" to "http" - unless it's a secure site.

I should also mention here that
Code: [Select]
define( 'CIVICRM_UF_BASEURL' , 'http://www.example.com/drupal/' ); and
Code: [Select]
define( 'CIVICRM_DOMAIN_ID'      , 1 ); should be replaced or commented out, right?

2. On the main site, I now get "Do not have permission to write to file: /latest-version-cache.txt" and none of the icon images load. This is after resetting directory paths, clearing caches and deleting the templates_c folder.

UPDATE: See http://forum.civicrm.org/index.php/topic,24842.0.html

3. This is the big one: on the first affiliate site, I get the following fatal error upon logging in:

Code: [Select]
Sorry. A non-recoverable error has occurred. The error trace below might help to resolve the issue
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_setting (group_name , name , value , domain_id , is_domain , created_date ) VALUES ('Directory Preferences' , 'customFileUploadDir' , 's:7:\"custom/\";' ,  5 ,  1 ,  20120531080055 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`icrmedia_scdccivi`.`civicrm_setting`, CONSTRAINT `FK_civicrm_setting_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`) ON DELETE CASCADE)]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_setting (group_name , name , value , domain_id , is_domain , created_date ) VALUES ('Directory Preferences' , 'customFileUploadDir' , 's:7:\"custom/\";' ,  5 ,  1 ,  20120531080055 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`icrmedia_scdccivi`.`civicrm_setting`, CONSTRAINT `FK_civicrm_setting_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`) ON DELETE CASCADE)]
    [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_setting (group_name , name , value , domain_id , is_domain , created_date ) VALUES ('Directory Preferences' , 'customFileUploadDir' , 's:7:\"custom/\";' ,  5 ,  1 ,  20120531080055 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`icrmedia_scdccivi`.`civicrm_setting`, CONSTRAINT `FK_civicrm_setting_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`) ON DELETE CASCADE)]"]
)

As I recall, foreign key constraint issues have to do with authentication - DA lets you simultaneously be logged in as admins of the different domains, which is very handy. Perhaps this doesn't play well with multi-site, or perhaps different compile directories need to be defined for each affiliate?

Heck - I dunno.

So I'm turning off multi-site and going back to the original version of civicrm.settings.php for now, while leaving the database changes.

Hope this helps...
« Last Edit: May 31, 2012, 08:49:29 am by bcobin »

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Using Civi and Domain Access (Drupal)
May 31, 2012, 02:11:06 pm
The error implies that you don't have a domain_id 5 in your civicrm_domain table
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: Using Civi and Domain Access (Drupal)
May 31, 2012, 02:59:02 pm
Thanks much, Eileen - I suppose the domain IDs in Civi don't correspond the to Domain IDs in Drupal if this method is used.

There's also the issue in http://forum.civicrm.org/index.php/topic,24842.0.html where the directory paths get totally mangled, so even if we get past this part of it, it doesn't seem like things would work properly.

Thanks, Eileen - bit by bit, I suppose. Perhaps this will be helpful to someone who can dig further...

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Multi-Site functionality »
  • Using Civi and Domain Access (Drupal)

This forum was archived on 2017-11-26.