You are here

README.txt in Domain Access 5

README file for Domain Access.

File

README.txt
View source
  1. /**
  2. * @file
  3. * README file for Domain Access.
  4. */
  5. Domain Access
  6. A domain-based access control system.
  7. CONTENTS
  8. --------
  9. 1. Introduction
  10. 1.1 Use-Case
  11. 1.2 Examples
  12. 1.3 Using Multiple Node Access Modules
  13. 1.4 Known Issues
  14. 1.4.1 Logging In To Multiple Domains
  15. 1.4.2 Cron Handling
  16. 1.4.3 Updating Your Site
  17. 2. Installation
  18. 2.1 Patches to Drupal Core
  19. 2.1.1 multiple_node_access.patch
  20. 2.1.2 custom_url_rewrite_outbound.patch
  21. 2.2 Server Configuration
  22. 2.3 Creating Domain Records
  23. 2.4 Setting DOMAIN_INSTALL_RULE
  24. 2.5 Setting DOMAIN_EDITOR_RULE
  25. 2.6 Setting DOMAIN_SITE_GRANT
  26. 3. Permissons
  27. 3.1 Module Permissions
  28. 3.2 Normal Usage
  29. 3.3 Advanced Usage
  30. 3.4 Limitations
  31. 4. Module Configuration
  32. 4.1 Default Domain Settings
  33. 4.1.1 Primary Domain Name
  34. 4.1.2 Site Name
  35. 4.1.3 Domain URL Scheme
  36. 4.2 Domain Module Behaviors
  37. 4.2.1 New Content Settings
  38. 4.2.2 Content Editing Forms
  39. 4.2.3 Debugging Status
  40. 4.2.4 Enforce Rules on Adminstrators
  41. 4.2.5 Sort Domain Lists
  42. 4.3 Advanced Settings
  43. 4.3.1 Domain-based Editing Controls
  44. 4.3.2 Search Settings
  45. 4.3.3 Search Engine Optimization
  46. 4.3.4 Default Source Domain
  47. 4.3.5 WWW Prefix Handling
  48. 4.3.6 Node Access Settings
  49. 4.3.7 Wildcard Redirection
  50. 4.3.8 Redirect Notification
  51. 4.4 Special Page Requests
  52. 4.4.1 Cron Handling
  53. 4.5 Node Link Patterns
  54. 4.6 The Domain List
  55. 4.7 Creating Domain Records
  56. 4.8 Node Settings
  57. 4.8.1 Domain Node Editing
  58. 4.8.2 Domain Node Types
  59. 4.9 Batch Updating
  60. 5. Blocks
  61. 5.1 Block -- Domain Switcher
  62. 5.2 Block -- Domain Access Information
  63. 6. Node Access
  64. 6.1 Assigning Domain Access
  65. 6.2. Editor Access
  66. 6.3 Realms
  67. 6.4 Grants
  68. 6.5 Warnings
  69. 7. Developer Notes
  70. 7.1 Extension Modules
  71. 7.2 The $_domain Global
  72. 7.3 Database Schema
  73. 7.4 API
  74. 7.5 drush and Domain Access
  75. ----
  76. 1. Introduction
  77. Before using the module, you should read the installation instructions found
  78. in INSTALL_QUICKSTART.txt.
  79. The Domain Access module group is designed to run an affiliated network of sites
  80. from a single Drupal installation. The module allows you to share users,
  81. content, and configurations across a group of sites such as:
  82. - example.com
  83. - one.example.com
  84. - two.example.com
  85. - my.example.com
  86. - thisexample.com
  87. - anothersite.com
  88. - example.com:3000 <-- non-standard ports are treated as unique domains.
  89. By default, these sites share all tables in your Drupal installation.
  90. The module uses Drupal's node_access() system to determine what content is
  91. available on each site in the network. Unlike other multi-domain modules for
  92. Drupal, the Domain Access module determines user access based on the active
  93. domain that the user is viewing, rather than which group or site the user
  94. belongs to.
  95. Additionally, when a user creates content, that content will automatically be
  96. assigned to the currently active domain unless the user has specific
  97. privileges to be able to assign domain access. Under advanced setups, the
  98. ability to edit content for a specific domain can be segregated from the
  99. typical Drupal privilege to 'administer nodes.'
  100. For more information about Domain Access privileges, see section 3.
  101. For more information about node_access(), see
  102. http://api.drupal.org/api/group/node_access/5
  103. ----
  104. 1.1 Use-Case
  105. The module was initially developed for a web site that sold franchises of a
  106. monthly magazine. The publishing rules were as follows:
  107. - Content may belong to the national site, one or more affiliates, or to
  108. all affiliates.
  109. - National editors may select to promote affiliate content to other
  110. affiliates, the national site, or to all affiliates.
  111. - Local editors may only create and edit content for their own affiliate
  112. sites.
  113. These rules are enforced programmatically by the Domain Access module. There
  114. was concern that, if given a choice to make, local editors would not assign the
  115. content correctly. Therefore, the module handles this automatically, and local
  116. editors have no control over which domains their content is published to.
  117. ----
  118. 1.2 Examples
  119. For the original example of the module in use, see http://skirt.com/
  120. ----
  121. 1.3 Using Multiple Node Access Modules
  122. Node Access is a complex issue in Drupal. Typically, sites will only use
  123. one node access module at a time. In some cases, you may require
  124. more advances acceess control rules.
  125. Domain Access attempts to integrate with other node access modules
  126. in two ways:
  127. -- First, the multiple_node_access patch allows you to configure the
  128. Domain Access module to use AND logic instead of OR logic when
  129. adding Domain Access controls to your site.
  130. -- Second, Domain Access does not use db_rewrite_sql in any way.
  131. The module lets Drupal's core node access system handle this.
  132. As a result, there may exist conflicts between Domain Access and other
  133. contributed modules that try to solve this issue.
  134. Domain Access has been tested to work with the Organic Groups module,
  135. but may require the solution in http://drupal.org/node/234087.
  136. If you experience conflicts with other node access modules, you
  137. should uninstall the multiple_node_access patch. This will restore the
  138. default Drupal behavior that your other modules are expecting.
  139. For background, see:
  140. -- http://drupal.org/node/196922
  141. -- http://drupal.org/node/191375
  142. -- http://drupal.org/node/122173
  143. -- http://drupal.org/node/201156
  144. ----
  145. 1.4 Known Issues
  146. There are some issues that occur when Domain Access is used outside
  147. of its original use case. These are probably fixable, but may not work
  148. as you expect. You should pay careful attention to your site behavior.
  149. ----
  150. 1.4.1 Logging In To Multiple Domains
  151. The Domain Access module allows the creation of domains with different
  152. hosts. However, security standards dictate that cookies can only be
  153. read from the issuing domain.
  154. If you use the same top-level domain for all sites, setting the $cookie_domain
  155. as specified in INSTALL.txt will allow for multiple logins. For example, a
  156. $cookie_domain = '.example.com' will work for the following domains:
  157. example.com
  158. one.example.com
  159. two.example.com
  160. my.user.example.com
  161. However, if configure your site as follows users cannot be logged in with a
  162. single login cookie.
  163. example.com
  164. one.example.com
  165. myexample.com
  166. thisexample.com
  167. While example.com and one.example.com can share a login cookie, the
  168. other two domains cannot read that cookie. This is an internet standard,
  169. not a bug.
  170. Note: See the INSTALL.txt for instructions regarding Drupal's default
  171. cookie handling.
  172. ----
  173. 1.4.2 Cron Handling
  174. When Drupal's cron function runs, it operates on the domain from which
  175. the cron.php script is invoked. That is, if you setup cron to run from:
  176. http://one.example.com/cron.php
  177. In this case, Domain Access will check the access settings for that domain.
  178. This behavior has been known to cause issues with other contributed modules.
  179. As a solution, we normally disable Domain Access rules when cron runs.
  180. For more information, see section 4.4.1 Cron Handling.
  181. If you encounter any cron-related issues, please report them at:
  182. http://drupal.org/project/issues/domain
  183. ----
  184. 1.4.3 Updating Your Site
  185. This issue only occurs if you use the Domain Prefix module. It is possible
  186. that database updates will not be applied to prefixed tables.
  187. For more information, see the Drupal Upgrades section of the Domain Prefix
  188. README.txt file.
  189. ----
  190. 2. Installation
  191. WARNING: The Domain Access module assumes that you have already installed
  192. and configured your Drupal site. Please do so before continuing.
  193. Installing the module requires that you share a single copy of settings.php
  194. for all domains that will be registered with Domain Access.
  195. You must also add code to that settings.php file in order to load the domain
  196. handling code. See INSTALL_QUICKSTART.txt for instructions.
  197. For detailed instructions, see INSTALL.txt.
  198. After you have completed the steps outlined by the installer, you may enable
  199. the module normally. When you enable the module, it will create a {domain} table
  200. in your Drupal database.
  201. All existing nodes and users on your site will be assigned to the default domain
  202. for your web site. Existing content will be set to be visible on all new
  203. domains. If you wish to alter this behavior, see sections 2.4 through 2.6.
  204. ----
  205. 2.1 Patches to Drupal Core
  206. The following patches are optional. They affect advanced behavior of the
  207. Domain Access module.
  208. Patches are distributed in the 'patches' folder of the download.
  209. To apply these patches, place them in your root Drupal folder.
  210. Then follow the instructions at: http://drupal.org/patch/apply
  211. ----
  212. 2.1.1 multiple_node_access.patch
  213. You should apply this patch only if you use Domain Access along with
  214. another Node Access module, such as Organic Groups (OG), and
  215. have need of advanced access controls.
  216. The multiple_node_access.patch allows Drupal to run more than one
  217. node access control scheme in parallel. Instead of using OR logic to
  218. determine node access, this patch uses subselects to enable AND logic
  219. for multiple node access rules.
  220. WARNING: This patch uses subselect statements and requires pgSQL or
  221. MySQL 4.1 or higher.
  222. Developers: see http://drupal.org/node/191375 for more information.
  223. This patch is being submitted to Drupal core for version 7.
  224. ----
  225. 2.1.2 custom_url_rewrite_outbound.patch
  226. This patch is only needed if:
  227. -- You wish to allow searching of all domains from any domain.
  228. -- You use a content aggregation module such as MySite.
  229. -- You get "access denied" errors when linking to items on a
  230. user's Track page.
  231. -- You want to turn on the advanced setting "Search Engine
  232. Optimization" to avoid content from being indexed on multiple
  233. domains.
  234. This patch allows modules to edit the path to a Drupal object. In the
  235. above cases, some content can only be viewed from certain domains, so
  236. we must write absolute links to that content.
  237. This patch introduces backports custom_url_rewrite_outbound() to Drupal 5.
  238. After you install this patch, you must followi the instructions in INSTALL.txt
  239. Developers: see http://drupal.org/node/207330 for more information.
  240. See section 4.5 Node Link Patterns for more details.
  241. ----
  242. 2.2 Server Configuration
  243. For the module to work correctly, the DNS record of your server must accept
  244. multiple DNS entries pointing at a single IP address that hosts your Drupal
  245. installation.
  246. The two basic methods for doing this are either to:
  247. - Setup WildCard DNS, so that *.example.com resolves to your Drupal site.
  248. - Setup VirtualHosts so that one.example.com, two.example.com, etc. all
  249. resolve to your Drupal site.
  250. For example, on my local testing machine, I have VirtualHosts to the following
  251. sites setup in httpd.conf:
  252. - example.com => 127.0.0.1
  253. - one.example.com => 127.0.0.1
  254. - two.example.com => 127.0.0.1
  255. - three.example.com => 127.0.0.1
  256. It is beyond the scope of this document to explain how to configure your DNS
  257. server. For more information, see:
  258. - http://en.wikipedia.org/wiki/Wildcard_DNS_record
  259. - http://en.wikipedia.org/wiki/Virtual_hosting
  260. After you have enabled multiple DNS entries to resolve to your Drupal
  261. installation, you may activate the module and configure its settings.
  262. No matter how many domains resolve to the same IP, you only need one instance
  263. of Drupal's settings.php file. The sites folder should be named 'default' or
  264. named for your root domain.
  265. ----
  266. 2.3 Creating Domain Records
  267. After you enable the module, you will have a user interface for registering new
  268. domains with your site. For these to work correctly, they must also be
  269. configured by your DNS server.
  270. To be clear: creating a new domain record through this module will not alter
  271. the DNS server of your web server.
  272. ----
  273. 2.4 Setting DOMAIN_INSTALL_RULE
  274. This is an advanced instruction, and may be ignored.
  275. At the top of the domain.module file, you will find this line:
  276. define('DOMAIN_INSTALL_RULE', TRUE);
  277. This setting controls the default behavior of the module when installing over
  278. an existing installation. If set to TRUE, the Domain Access module will assign
  279. all existing nodes to be viewable by your primary domain.
  280. If you set this value to FALSE, existing content will not be visible on your
  281. primary domain unless DOMAIN_SITE_GRANT is set to TRUE.
  282. For more details, see section 5.
  283. ----
  284. 2.5 Setting DOMAIN_EDITOR_RULE
  285. This is an advanced instruction, and may be ignored.
  286. At the top of the domain.module file, you will find this line:
  287. define('DOMAIN_EDITOR_RULE', FALSE);
  288. This setting controls the default behavior for affiliate editors. If
  289. DOMAIN_INSTALL_RULE is set to FALSE, you may change this value to TRUE if you
  290. intend to use editing controls.
  291. If this is set to TRUE, all existing nodes on your site will be editable by
  292. users who are assigned as editors of your root domain.
  293. See section 3 and section 5 for more information.
  294. ----
  295. 2.6 Setting DOMAIN_SITE_GRANT
  296. At the top of the domain.module file, you will find this line:
  297. define('DOMAIN_SITE_GRANT', TRUE);
  298. This setting controls the default behavior for viewing affiliate content.
  299. By design, the Domain Access module allows site administrators to assign
  300. content to 'all affiliates.' If this value is set to TRUE, then content
  301. assigned to all affiliates can be seen by all users on all current domains.
  302. On install, setting this value to TRUE will assign all current content to
  303. be viewable on all domains.
  304. Normally, you will not need to edit this value.
  305. ----
  306. 3. Permissions
  307. After enabling the module, go to Access Control to configure the module's
  308. permissions.
  309. ----
  310. 3.1 Module Permissions
  311. The Domain Access module has the following permissions:
  312. - 'administer domains'
  313. This permission allows users to create and manage domain records
  314. and settings.
  315. 'assign domain editors'
  316. This permission allows users to assign themselves and other users as
  317. affiliate editors. For those users to act as editors, their role(s) must also
  318. have the 'edit domain nodes' permission.
  319. - 'edit domain nodes'
  320. This permission is for advanced use and substitutes for the normal
  321. 'administer nodes' permission for sites that give restricted administrative
  322. privileges. See section 3.3 for more information.
  323. - 'set domain access'
  324. This permission is key. Users with this permission will be given a user
  325. interface for assigning users and nodes to specific domains. Users without
  326. this permission cannot assign domain access; their nodes will automatically
  327. be assigned to the currently active domain.
  328. For example, if a user has this permission and creates a book page on
  329. one.example.com, the user will be given a series of options to assign that
  330. book page to any or all of the registered domains on the site.
  331. If the user does not have this permission, the book page will only be shown
  332. to users who are on http://one.example.com.
  333. - 'view domain publishing'
  334. This permission provides a limited set of options for users to create and
  335. edit content on your site. Users who have this permission will have their
  336. node editing forms processed according to the "Content Editing Form"
  337. settings described in section 4.2.2.
  338. This feature was added in response to http://drupal.org/node/188275.
  339. ----
  340. 3.2 Normal Usage
  341. Under a normal Drupal site, a single administrator (or a handful of equally
  342. trusted administrators) typically have the 'administer nodes' permission and
  343. individual 'edit TYPE nodes' permissions.
  344. If your site follows this method, you will not need to enable the advanced
  345. editing controls provided by Domain Access. Under the module settings, leave
  346. the setting 'Domain-based editing controls' as 'Do not use access control for
  347. editors'. In this case, the 'edit domain nodes' permission becomes irrelevant.
  348. The only choices for permissions would be who gets to administer the module
  349. settings and who gets to assign nodes to specific domains. Generally, only
  350. users who you trust to 'administer site configuration' should be given the
  351. 'administer domains' permission. As for 'set domain access,' that can be given
  352. to any user you trust to use the UI properly.
  353. ----
  354. 3.3 Advanced Usage
  355. In the event that you wish to segregate which content certain editors can
  356. control, you should not use the normal 'edit TYPE nodes' permission provided
  357. by Drupal's core Node module. This permisson grants the ability for a user
  358. to edit all nodes of a given type.
  359. In the Domain Access model, this permission is not used in favor of the provided
  360. 'edit domain nodes' permission. This permission allows editors only to edit
  361. (and delete) nodes that belong to their subdomain.
  362. To enable this feature, you should grant the 'edit domain nodes' permission to
  363. some roles. Then you should enable the 'Use access control for editors' setting
  364. under the Domain Access configuration screen.
  365. ----
  366. 3.4 Limitations
  367. Due to the way node_access() works, the following limitations should be noted.
  368. - Any node that is assigned to more than one domain can be edited
  369. by any editor who belongs to one of the domains.
  370. - Users who look at the sites and have the 'administer nodes' permission
  371. can always see all content on all sites, which can be confusing. To
  372. enforce Domain Access rules on these users, you may enable the
  373. 'Enforce rules on administrators' setting described in 4.2.4.
  374. - Users who have the 'edit TYPE nodes' permission will be able to edit nodes
  375. that do not belong to their domain.
  376. These limitations are due to the permissive nature of node_access(). If any
  377. access rule grants you permission, it cannot be taken away.
  378. ----
  379. 4. Module Configuration
  380. The settings for Domain Access are listed under Site Building. The path is
  381. 'admin/build/domain'.
  382. ----
  383. 4.1 Default Domain Settings
  384. These elements define the 'primary' domain for your site. In the event that a
  385. user tries to access an invalid domain, this domain will be used.
  386. ----
  387. 4.1.1 Primary Domain Name
  388. The primary domain for your site. Typically example.com or www.example.com.
  389. Do not use http or slashes. This domain will be used as the default URL for your
  390. site. If an invalid domain is requested, users will be sent to the primary
  391. domain.
  392. Enter the primary domain for your site here. Typically, you will also enter
  393. this value into settings.php for cookie handling. Do not use http:// or a
  394. trailing slash when entering this value.
  395. NOTE: If you have installed Drupal in a subfolder, such as
  396. http://example.com/drupal you should not include the folder path
  397. as part of the primary domain. Simply use example.com -- Drupal
  398. will automatically detect the presence of the subfolder.
  399. NOTE: As of 5.x.1.5 and higher, you may use a port protocol as part
  400. of any domain. So you could set example.com:8080 as the primary
  401. domain name. Note that port protocols will not be stripped, so that
  402. example.com and example.com:8080 are two separate domains.
  403. ----
  404. 4.1.2 Site Name
  405. This value is taken from your system settings and need not be changed. It is
  406. provided to allow readbility in the domain list.
  407. ----
  408. 4.1.3 Domain URL Scheme
  409. Allows the site to use 'http' or 'https' as the URL scheme. Default is
  410. 'http'. All links and redirects to root site will use the selected scheme.
  411. ----
  412. 4.2 Domain Module Behaviors
  413. These options affect the basic options for how the module behaves.
  414. ----
  415. 4.2.1 New Content Settings
  416. Defines the default behavior for content added to your site. By design, the
  417. module automatically assigns all content to the currently active domain.
  418. If this value is set to 'Show on all sites,' then all new content will be
  419. assigned to all sites _in addition to_ the active domain.
  420. ----
  421. 4.2.2 Content Editing Forms
  422. Defines how to present the forms for node creation and editing to users
  423. who do not have permission to 'set domain access' but need some control
  424. over where their content is published.
  425. Users with the 'view domain publishing' permission will be subject to the
  426. rules defined below.
  427. -- Pass the default form values as hidden fields
  428. The default option. It will assign all content to the root domain and to
  429. the domain from which the form is entered.
  430. -- Take user to the default domain
  431. Before being presented the editing form, users will be taken to the root
  432. domain. If the node is not visible on the root domain, the user may not be
  433. able to edit the node.
  434. -- Take user to their assigned domain
  435. Before being presented the editing form, users will be taken to the
  436. first domain assigned to their user account. This function is most useful
  437. when you users are only allowed to enter content from a single domain.
  438. Note that for users who have more than one assigned domain, this option
  439. will take them to the first match and the user will not be allowed to
  440. change the domain affiliation.
  441. The advantage of this option is the user cannot modify the URL of a
  442. content edit form to match the URL of other domains, forcing all of her
  443. posts to be made to a single domain. Users trying to enter content
  444. from another domain will always be transferred to their assigned domain.
  445. In effect, a user assigned to 'one.example.com' will only be able to post
  446. to that domain, even if she clicks Create Content from two.example.com.
  447. -- Show user their publishing options
  448. The node editing form is shown normally, and the user is presented a
  449. list of checkboxes. These options represent the affilaite domains that
  450. the user is allowed to publish content to, according to the domains
  451. assigned to their user account.
  452. Note that if this option is selected, users with the 'view domain publishing'
  453. permission will also be shown a list of affilates to which the node is
  454. assigned. This list shows only the affiliates that the user cannot edit.
  455. Warning: If this option is selected and the user has no domain publishing
  456. options, the user will not be allowed to post or edit!
  457. Note also that the user is not given the ability to promote content to
  458. 'all affiliates'. Users who need this ability should be given the 'set domain
  459. access' permission instead.
  460. ----
  461. 4.2.3 Debugging Status
  462. If enabled, this will append node access information to the bottom of each
  463. node. This data is only viewable by uses with the 'set domain access'
  464. privilege. It is provided for debugging, since 'adminiseter nodes' will make
  465. all nodes viewable to some users.
  466. ----
  467. 4.2.4 Enforce Rules on Administrators
  468. When using Node Access modules, user 1 (the super-admin) and users with
  469. the 'administer nodes' permission are not subject to node access rules. This
  470. is a design feature of Drupal, and it can lead to confusion when viewing your
  471. site as an administrator.
  472. To help with this confusion, the 'Enfore rules on adminstrators' setting can
  473. be enabled. This setting forces Domain Access rules to be applied _even to
  474. users who can administer nodes_.
  475. The default setting is OFF, but if you regularly login as user 1 or a user with
  476. the 'administer nodes' permission, you may want to enable this feature.
  477. NOTE: This feature _only_ applies Domain Access rules. if you are using
  478. multiple node access modules, not all rules will be applied.
  479. ----
  480. 4.2.5 Sort Domain Lists
  481. Both the Domain Switcher block and the Domain Nav module provide an
  482. end-user visible list of domains. The domain sorting settings control how
  483. these lists are generated and presented to the user.
  484. ----
  485. 4.3 Advanced Settings
  486. These settings control advanced features for the module. Some of these
  487. features require patches to Drupal core. Please read the documentation
  488. carefully before implementing these features.
  489. NOTE: Some of these options may be disabled in the event that patches
  490. have not been applied.
  491. By default, these features are all disabled.
  492. ----
  493. 4.3.1 Domain-based Editing Controls
  494. Uses the Domain Access module to control which editors can edit content.
  495. See section 3.3 for a full discussion of this feature.
  496. ----
  497. 4.3.2 Search Settings
  498. For this feature to work, you must follow the instructions in INSTALL.txt
  499. regarding custom_url_rewrite_outbound(). If you have not followed the
  500. instructions, you should see a warning at the top of the Admin > Build > Domains
  501. page.
  502. Allows the admin to decide if content searches should be run across all
  503. affiliates or just the currently active domain. By design, Drupal will only
  504. find matches for the current domain.
  505. Enabling this feature requires the custom_url_rewrite_outbound patch
  506. discussed in 2.1.2
  507. ----
  508. 4.3.3 Search Engine Optimization
  509. For this feature to work, you must follow the instructions in INSTALL.txt
  510. regarding custom_url_rewrite_outbound(). If you have not followed the
  511. instructions, you should see a warning at the top of the Admin > Build > Domains
  512. page.
  513. There is a risk with these modules that your site could be penalized by search
  514. engines such as Google for having duplicate content. This setting controls the
  515. behavior of URLs written for nodes on your affiliated sites.
  516. - If SEO settings are turned on, all node links are rewritten as absolute
  517. URLs.
  518. - If assigned to 'all affiliates' the node link goes to the 'default source
  519. domain' defined in 4.3.4. Normally. this is your primary domain.
  520. - If assigned to a single affiliate, the node link goes to that affiliate.
  521. - If assigned to multiple affiliates, the node link goes to the first
  522. matching domain.
  523. (Determined by the order in which domains were created, with your primary
  524. domain matched first.)
  525. The optional Domain Source module (included in the download) allows you to
  526. assign the link to specific domains.
  527. Enabling this feature requires the custom_url_rewrite_outbound() patch discussed in 2.1.2.
  528. ----
  529. 4.3.4 Default Source Domain
  530. This setting allows you to control the domain to use when rewriting links that
  531. are sent to 'all affiliates.' Simply select the domain that you wish to use as
  532. the primary domain for URL rewrites.
  533. By default this value is your primary domain.
  534. ----
  535. 4.3.5 WWW Prefix Handling
  536. This setting controls how requests to www.example.com are treated with
  537. respect to example.com. The default behavior is to process all host names
  538. against the registered domain list.
  539. If you set this value to 'Treat www.*.example.com as an
  540. alias of *.example.com' then all host requests will have the 'www.' string
  541. stripped before the domain lookup is processed.
  542. Users going to a www.one.example.com in this case will not automatically
  543. be sent to one.example.com, but your Drupal site will behave as if they
  544. had requested one.example.com.
  545. This feature was requested by Rick and Matt at DZone.com
  546. ----
  547. 4.3.6 Node Access Settings
  548. This setting controls how you want Domain Access to interact with other
  549. node access modules.
  550. If you _are not_ using a module such as Organic Groups or Taxonomy
  551. Access Control, this setting may be disabled. This setting is only
  552. required IF:
  553. -- You are using more than one node access control module.
  554. -- You want to strictly enforce access permissions by requiring
  555. both Domain Access and your other module to grant permission.
  556. By design, the node access system in Drupal 5 is a permissive system.
  557. That is, if you are using multiple node access modules, the permissions
  558. are checked using an OR syntax.
  559. As a result, if any node access module grants access to a node, the user
  560. is granted access.
  561. The included multiple_node_access.patch (discussed in 2.1.1) alters this
  562. behavior. The patch allows Drupal to use AND logic when running more
  563. than one node access module.
  564. For example, when using OG and DA, Drupal's default behavior is:
  565. -- Return TRUE if OG is TRUE -or- DA is TRUE.
  566. This patch allows you to enforce the rule as:
  567. -- Return TRUE if OG is TRUE -and- DA is TRUE.
  568. By design, the default behavior is to use Drupal's OR logic.
  569. For more information, see http://drupal.org/node/191375.
  570. Enabling this feature requires the multiple_node_access patch discussed
  571. in 2.1.1.
  572. ----
  573. 4.3.7 Wildcard Redirection
  574. When using Domain Access with wildcard DNS, an invalid domain (e.g. a
  575. misspelling) results in an alias of the default domain rather than a redirect.
  576. In general you will want to issue a redirect, to avoid spiders indexing wrong
  577. domains, or people making bookmarks to non-existant domains. However, in some
  578. cases you do not want this redirect to take place. For example when testing or
  579. developing on test.example.com, or your localhost.
  580. Check the box if you wish to redirect invalid domain requests to the default
  581. domain. Note that an "invalid" request is a domain that is recognized by your
  582. web server (like foo.example.com) but not registered with Domain Access.
  583. By default this behavior is turned on.
  584. NOTE: This behavior is deprecated in Drupal 6 in favor of the Domain alias
  585. module.
  586. ----
  587. 4.3.8 Redirect Notification
  588. If issuing a redirect from an invalid domain, print a message to the screen
  589. telling the user that he following an outdated link. This is useful for cases
  590. where you have migrated a site or its content onto Domain Access.
  591. By default this behavior is turned on. It will not appear if Wildcard
  592. Redirection is not enabled.
  593. NOTE: This behavior is deprecated in Drupal 6 in favor of the Domain alias
  594. module.
  595. ----
  596. 4.4 Special Page Requests
  597. For this feature to work, you must follow the instructions in INSTALL.txt
  598. regarding custom_url_rewrite_outbound(). If you have not followed the
  599. instructions, you should see a warning at the top of the Admin > Build > Domains
  600. page.
  601. In normal uses, such as the default home page, you want to restrict access
  602. to content based on the active domain. However, in certain cases, this
  603. behavior is not desired.
  604. Take the Track page for each user, for example. The Track page is at
  605. 'user/UID/track' and shows a list of all posts by that user. By design, this
  606. page may show different results if seen from different domains:
  607. -- one.example.com/user/1/track
  608. Shows all posts by user 1 assigned to the domain one.example.com
  609. -- two.example.com/user/1/track
  610. Shows all posts by user 1 assigned to the domain two.example.com
  611. The behavior we really want is to show ALL posts by the user regardless of
  612. the active domain.
  613. The Special Page Requests setting lets you specify Drupal paths for which
  614. this behavior is active. These paths are entered in the same way as block
  615. settings for page visibility.
  616. Some sample pages that might require this setting. Note, some of these
  617. are contributed modules:
  618. -- user/*/track
  619. -- blog/* -- the user blog page
  620. -- mysite/* -- the MySite module
  621. -- popular/alltime -- a View page
  622. -- popular/latest -- a View page
  623. -- taxonomy/term/* -- to show all taxonomy terms at all times
  624. -- taxonomy/term/10 -- to show only term 10 at all times
  625. -- taxonomy/term/*/feed/* -- all taxonomy term feeds
  626. Default and custom Views are often good candidates here as well.
  627. By default, 'user/*/track' is in this list.
  628. The logic for how these links are written is documented in 4.3.3 Search Engine
  629. Optimization.
  630. Note that the 'search' path is handled separately and need not be added here.
  631. ----
  632. 4.4.1 Cron Handling
  633. When Drupal's cron function runs, it runs on a specific domain. This forces
  634. Domain Access to invoke its access control rules, which may not be desired.
  635. In most use cases, you will want Domain Access to allow access to all nodes
  636. during cron runs. For modules such as Subscriptions, this behavior is
  637. required unless all your content is assigned to "all affiliates."
  638. To reflect this, Domain Access provides a configuration option labelled:
  639. [x] Treat cron.php as a special page request
  640. This option is turned on by default. In almost all cases, you should leave
  641. this option checked. Doing so allows Domain Access to ignore access checks
  642. for nodes when cron runs.
  643. Note that this does not affect node access permissions set by other modules.
  644. ----
  645. 4.5 Node Link Patterns
  646. When using this module, there are times when Domain Access will need to
  647. rewrite a node link using custom_url_rewrite_outbound().
  648. Note that these settings are not available if the custom_url_rewrite_outbound
  649. patch is not applied.
  650. Since Drupal is an extensible system, we cannot account for all possible
  651. links to specific nodes. Node Link Patterns are designed to allow you to
  652. extend the module as you add new contributed modules.
  653. By default, the following core link paths will be rewritten as needed if you
  654. have installed the custom_url_rewrite_outbound patch.
  655. -- node/%n
  656. -- comment/reply/%n
  657. -- node/add/book/parent/%n
  658. -- book/export/html/%n
  659. Where %n is a placeholder for the node id.
  660. If you install additional modules such as Forward
  661. (http://drupal.org/project/forward)
  662. or Print
  663. (http://drupal.org/project/print)
  664. you will want to add their paths to this list:
  665. -- forward/%n
  666. -- print/%n
  667. This is an advanced, but necessary feature. Please report any core node path
  668. omissions at http://drupal.org/project/issues/domain.
  669. ----
  670. 4.6 Domain List
  671. This screen shows all active domains registered for use with the site.
  672. Record zero (0) is hardcoded to refer to the "root" site defined as your
  673. Primary domain name.
  674. ----
  675. 4.7 Create domain record
  676. As noted above, this screen does not register DNS records with Apache.
  677. Use this screen to register new allowed domains with your site. This
  678. process is especially important for sites using Wildcard DNS, as it prevents
  679. non-registered sites from resolving.
  680. When you create a new domain record, simply fill in the two fields:
  681. - Domain
  682. This is the full path.example.com, without http:// or a trailing slash.
  683. - Site name
  684. This is the name of the site that will be shown when users access this site.
  685. -- Domain URL scheme
  686. Allows the domain to use 'http' or 'https' as the URL scheme. Default is
  687. 'http'. All links and redirects to the domain will use the selected scheme.
  688. -- Domain status
  689. By default, all domains are Active and anyone can navigate to them. Setting
  690. a domain to Inactive restricts access to users with the 'administer domains'
  691. permission.
  692. Both the Domain and the Site name are required to be unique values.
  693. After you create a record, you may edit or delete it as you see fit.
  694. ----
  695. 4.8 Node Settings
  696. The Node settings page is divided into two parts, each with a different purpose.
  697. ----
  698. 4.8.1 Domain Node Editing
  699. The top section 'Domain node editing' is required for those sites that use the
  700. advanced editing techniques outlined in section 3.
  701. For users without the 'administer nodes' permission, certain elements of the
  702. node editing form are hidden. These settings allow the site administrator to
  703. enable users with the 'edit domain nodes' permission to have access to those
  704. restricted fields.
  705. By default, 'Comment settings', 'Delete node', 'Publshing options', and 'Path
  706. aliasing' are enabled.
  707. ----
  708. 4.8.2 Domain Node Types
  709. The lower section 'Domain node types' is used to extend the 'New content
  710. settings' described in 4.1.
  711. Domain node types presents a list of all active node types on your site. By
  712. checking the box, nodes for that given type will automatically be assigned to
  713. 'all affiliate sites' during node creation and editing.
  714. ----
  715. 4.9 Batch Updating
  716. The module provides for batch actions for common tasks. These actions are
  717. useful for making rapid changes across all domains. The following actions
  718. are available by default.
  719. - Edit all domain values
  720. - Edit all site names
  721. - Edit all URL schemes
  722. - Edit all domain status flags
  723. Additional batch actions are made available for the Domain Configuration
  724. module. Other modules may implement hook_domainbatch() to provide
  725. additional batch actions.
  726. ----
  727. 5. Blocks
  728. The Domain Access module provides two blocks, which can be used to help you
  729. debug your use of the module.
  730. ----
  731. 5.1 Block -- Domain Switcher
  732. The Domain Switcher block presents a list of all active domains. Clicking
  733. on one of the links will take you from your current URL to the same URL on
  734. the selected domain.
  735. For example, if you are looking at example.com/?q=node and click on another
  736. domain, the link will take you to one.example.com/?q=node.
  737. In the Domain Switcher block, domains are listed using their human-readable
  738. sitename variables.
  739. NOTE: This block is for debugging purposes. The included Domain Navigation
  740. module provides block and menu items intended for end users.
  741. ----
  742. 5.2 Block -- Domain Access Information
  743. The Domain Access Information block lets you view node access rules for any
  744. node when you are viewing that node. This block can help you debug the
  745. module for user accounts that do not have the 'set domain access' permission.
  746. NOTE: By design, this block is viewable by all users. However, its content
  747. should only be shown to site developers or during debugging. You should use
  748. the normal block visiblity settings as appropriate to your site.
  749. ----
  750. 6. Node Access
  751. The Domain Access module is a node_access() module. For additional developer
  752. information, see http://api.drupal.org/api/group/node_access/5.
  753. By design, the module sets access to content based on the current domain that
  754. a user is viewing. If a user is at one.example.com, they can see content that
  755. is assigned to that domain or to all domains.
  756. ----
  757. 6.1 Assigning Domain Access
  758. Users who have the 'set domain access' permission can assign any node to any or
  759. all registered sites. During node editing, a series of options will be
  760. displayed as checkboxes under the heading "Domain access options":
  761. Publishing options:
  762. [] Send to all affiliates
  763. Select if this content can be shown to all affiliates. This setting will
  764. override the options below.
  765. Publish to: * (required)
  766. [] Drupal
  767. [] One site
  768. [] Two site
  769. Select which affiliates can access this content.
  770. If you select 'Send to all affiliates,' the node will be viewable on all domains
  771. for your site. If you do not select this option, you must select at least one
  772. domain for the node.
  773. If you do not select at least one option, the module will automatically
  774. assign the node to your default domain.
  775. When creating new content, the currently active domain will be selected for you.
  776. For users who do not have the 'set domain access' permission, the assignment
  777. will be done through a hidden form element. The node will be assigned to the
  778. currently active domain or, if configured , to all domains.
  779. ----
  780. 6.2. Editor Access
  781. Whenever a user account is created and the Domain Access module is active, user
  782. accounts will automatically be tagged with the name of the active domain from
  783. which they registered their account. Users with the 'set domain access'
  784. permission may assign individual users to specific domains in the same way that
  785. nodes can be defined.
  786. These user settings are used to determine what domains an editor belongs to.
  787. Users with the 'edit domain nodes' permission can edit any node that belongs to
  788. the same domain that the user does. (Remember that users and nodes can both
  789. belong to multiple domains.) However, nodes that are assigned to 'all
  790. affiliates' do not grant editing privileges to all editors.
  791. ----
  792. 6.3 Realms
  793. This section contains technical details about Drupal's node access system.
  794. In Domain Access, the following realms are defined:
  795. - domain_all
  796. Indicates whether the view grant should be passed for all nodes on
  797. a given page request. Used in cases such as Search and MySite to
  798. enable aggregation of content across affiliates. The only valid nid
  799. and gid for this grant are zero (0).
  800. - domain_site
  801. Indicates whether a node is assigned to all affliaites. The only valid
  802. grant id for this realm is zero (0).
  803. - domain_id
  804. Indicates that a node belongs to one or more registered domains. The
  805. domain_id key is taken from the {domain} table and is unique.
  806. - domain_editor
  807. Indicates that a node can be edited or deleted by an editor for a specific
  808. domain. This advanced usage is optional.
  809. ----
  810. 6.4 Grants
  811. In each of the realms, there are specific rules for node access grants, as
  812. follows.
  813. - domain_all
  814. In some specific cases, like Search, or MySite, or the user's Tracker page
  815. we want people to be able to see content across all affiliates. Only the
  816. domain_all grant is assigned in these cases. This grants only 'grant_view'.
  817. - domain_site
  818. By design, all site users, including anonymous users, are granted access to
  819. the gid '0' for realm 'domain_site'. This grant allows all users to see
  820. content assigned to 'all affliates'. This grants only 'grant_view'.
  821. - domain_id
  822. When a user, including anonymous users, views a page, the active domain is
  823. identified by the registered domain_id. For that page view, the user is
  824. granted gid of the active domain_id for the realm 'domain_id'. This allows
  825. content to be partitioned to one or many affilaites. This grants only
  826. 'grant_view', since 'grant_edit' would allow content to appear to some users
  827. regardless of the active domain.
  828. - domain_editor
  829. Advanced. If used, this sets the access for users who have the 'edit domain
  830. nodes' permission. This grant works like the domain_id grant, but only grants
  831. editors access if the node belongs to one of their assigned domains. This
  832. grants both the 'grant_edit' and 'grant_delete' permission.
  833. ----
  834. 6.5 Warnings
  835. Node access in Drupal is a permissive system. Once a grant has been issued, it
  836. cannot be revoked. As a result, it is possible for multiple editors to be able
  837. to edit or delete a single node. Here's the use case:
  838. - Node 10 (a book page) is assigned to one.example.com and three.example.com
  839. - User A is an editor for one.example.com.
  840. - User B is an editor for two.example.com
  841. - User C is an editor for three.example.com
  842. Under this scenario, User A and User C will be able to edit node 10.
  843. To be more clear about Drupal permissions:
  844. - User D has 'administer nodes' permission for the site.
  845. - User E has 'edit book nodes' permission for the site.
  846. In this case, User D and User E can also edit or delete node 10. This is why
  847. only super-admins are given 'administer nodes' and 'edit TYPE nodes'
  848. permissions with the Domain Access module. If you want your affiliate editors
  849. to have limited permissions, only grant them 'edit domain nodes'.
  850. However, you still need to give users the 'create TYPE nodes' permission
  851. normally. Domain Access does not affect node creation.
  852. Since Domain Access implements node_access() fully, if you uninstall the module
  853. -- using Drupal's uninstall sequence -- all node_access entries should be reset
  854. to grant 'grant_view' to realm 'all' with gid '0'.
  855. ----
  856. 7. Developer Notes
  857. The Domain Access module is meant to be the core module for a system of small
  858. modules which add functionality.
  859. ----
  860. 7.1 Extension Modules
  861. Currently, the following modules are included in the download. They are not
  862. required, but each adds functionality to the core module.
  863. - Domain Configuration -- Allows you to change select system variables for
  864. each domain, such as offline status, footer message and default home
  865. page.
  866. - Domain Content -- Provides a content administration page for each domain,
  867. so that affiliate editors can administer content for their section of the
  868. site.
  869. - Domain Navigation -- Supplies a navigation block with three themes. Creates
  870. menu items for each domain, suitable for using as primary or secondary
  871. links.
  872. - Domain Prefix -- A powerful module that allows for selective table prefixing
  873. for each domain in your installation.
  874. - Domain Source -- Allows editors to specify a primary "source" domain to be
  875. used when linking to content from another domain.
  876. - Domain Strict -- Forces users to be assigned to a domain in order to view
  877. content on that domain. Note that anonymous users may only see content
  878. assigned to "all affiliates" if this module is enabled.
  879. - Domain Theme -- Allows separate themes for each domain.
  880. - Domain User -- Allows the creation of specific subdomains for each active
  881. site user.
  882. - Domain Views -- Provides a Views filter for the Domain Access module.
  883. ----
  884. 7.2 The $_domain Global
  885. During hook_init(), the Domain Access module creates a nwe global variable,
  886. $_domain, which can be used by other Drupal elements (themes, blocks, modules).
  887. The $_domain global is an array of data taken from the {domain} table for the
  888. currently active domain. If no active domain is found, default values are used:
  889. $_domain['domain_id'] = 0;
  890. $_domain['sitename'] = variable_get('domain_sitename',
  891. variable_get('site_name', 'Drupal'))
  892. $_domain['subdomain'] = variable_get('domain_root', '')
  893. $_domain['scheme'] = 'http'
  894. $_domain['valid'] = TRUE
  895. $_domain['path'] = http://example.com
  896. Some uses for this global variable might include:
  897. - Block placement based on active domain (using PHP for block visibility).
  898. - Ad tags inserted based on active domain.
  899. - Theme switching based on domain.
  900. ----
  901. 7.3 Database Schema
  902. The Domain Access module creates two tables in a Drupal installation. {domain}
  903. contains the following structure:
  904. - domain_id
  905. Integer, unique, auto-incrementing.
  906. The primary key for all domain records.
  907. - subdomain
  908. Varchar, 80, unique (enforced by code)
  909. 'Domain' is a sql-reserved word, so subdomain is used. This value must match
  910. the url 'host' string derived from parse_url() on the current page request.
  911. - sitename
  912. Varchar, 80, unique (enforced by code)
  913. The name for this affiliate, used for readability.
  914. - scheme
  915. Varchar, 8 default 'http'
  916. Indicates the URL scheme to use when accessing this domain. Allowed values,
  917. are currently 'http' and 'https'.
  918. - valid
  919. Char, 1 default 1
  920. Indicates that this domain is active and can be accessed by site users.
  921. The {domain_access} table is a partial mirror of the {node_access} table and
  922. stores information specific to Domain Access. Its structure is:
  923. - nid
  924. Integer, unsigned NOT NULL default '0,
  925. - gid
  926. Integer, unsigned NOT NULL default '0'
  927. - realm
  928. Varchar, 255 NOT NULL default ''
  929. ----
  930. 7.4 API
  931. The Domain Access module has an API for internal module hooks. Documentation is
  932. included in the download as API.php and can be viewed online at:
  933. http://therickards.com/api
  934. The most important developer functions are the internal module hooks:
  935. http://therickards.com/api/group/hooks/Domain
  936. ----
  937. 7.5 drush and Domain Access
  938. Using drush, treat a Domain Access site like a multi-site install. If you do not supply
  939. a URI flag, drush gets confused and will error out.
  940. Enter drush commands in the format:
  941. >> drush --uri=www.example.com NORMAL COMMAND
  942. Generally, use the primary domain as the --uri flag.