/[drupal]/contributions/modules/domain/API.php
ViewVC logotype

Contents of /contributions/modules/domain/API.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.51 - (show annotations) (download) (as text)
Sun Nov 1 18:20:19 2009 UTC (3 weeks, 4 days ago) by agentken
Branch: MAIN
CVS Tags: DRUPAL-6--2-0, HEAD
Branch point for: DRUPAL-6--2
Changes since 1.50: +6 -1 lines
File MIME type: text/x-php
-- #372887 patch by nonsie and blackdog. Super-awesome set values for all domains in domain batch.
-- Creates the 6.x.2.0 stable release.
1 <?php
2 // $Id: API.php,v 1.50 2009/11/01 16:30:55 agentken Exp $
3
4 /**
5 * @defgroup domain_hooks Domain hook functions
6 *
7 * Core hooks for the Domain module suite.
8 */
9
10 /**
11 * @file
12 * API documentation file.
13 *
14 * @ingroup domain_hooks
15 */
16
17 /**
18 * Notify other modules that we are granting access to a node.
19 *
20 * This hook allows Domain Access modules to overwrite default behaviors.
21 * See http://api.drupal.org/api/function/hook_node_grants/6 for more detail.
22 *
23 * Note: In Drupal 7, this is a core feature.
24 *
25 * @see domain_strict_domaingrants()
26 *
27 * @param &$grants
28 * The existing default $grants, passed by reference.
29 * @param $account
30 * The user object of the user requesting the node.
31 * @param $op
32 * The node operation being performed (view, update, or delete).
33 *
34 * @return
35 * No return value. Modify the $grants array, passed by reference.
36 *
37 * @ingroup domain_hooks
38 */
39 function hook_domaingrants(&$grants, $account, $op) {
40 // Add a sample grant privilege to let a user see their content at all times.
41 $grants['domain_example'][] = $account->uid;
42 }
43
44
45 /**
46 * Notify other modules that we are saving node access records.
47 *
48 * This hook allows Domain Access modules to overwrite the default bahaviors.
49 * See http://api.drupal.org/api/function/hook_node_access_records/6 for more detail.
50 *
51 * Note: In Drupal 7, this is a core feature.
52 *
53 * @param &$grants
54 * The existing default $grants, passed by reference.
55 * @param $node
56 * The node object being saved.
57 *
58 * @return
59 * No return value. Modify the $grants array, passed by reference.
60 *
61 * @ingroup domain_hooks
62 */
63 function hook_domainrecords(&$grants, $node) {
64 // Add a sample access record to let a user see their content at all times.
65 $grants[] = array(
66 'realm' => 'domain_example',
67 'gid' => $node->uid,
68 'grant_view' => TRUE,
69 'grant_update' => TRUE,
70 'grant_delete' => TRUE,
71 'priority' => 0, // If this value is > 0, then other grants will not be recorded
72 );
73 // Remove the domain_site grant.
74 foreach ($grants as $key => $grant) {
75 if ($grant['realm'] == 'domain_site') {
76 unset($grants[$key]);
77 }
78 }
79 }
80
81 /**
82 * Notifies other modules that we are loading a domain record from the database.
83 *
84 * Modules may overwrite or add to the $domain array for each domain.
85 *
86 * When loading lists of domains or generating domain information, either use the proper
87 * functions -- domain_default(), domain_lookup(), and domain_domains() -- or invoke this hook.
88 *
89 * Invoked by domain_lookup() and domain_default().
90 *
91 * @param &$domain
92 * The current $domain array.
93 *
94 * @return
95 * No return value. The $domain array is modified by reference..
96 *
97 * @ingroup domain_hooks
98 */
99 function hook_domainload(&$domain) {
100 // Add a variable to the $domain array.
101 $domain['myvar'] = 'mydomainvar';
102 // Remove the site_grant flag, making it so users can't see content for 'all affiliates.'
103 $domain['site_grant'] = FALSE;
104 }
105
106 /**
107 * Notify other modules that we have created a new domain or
108 * updated a domain record.
109 *
110 * For 'update' and 'delete' operations, the $domain array holds the
111 * original values of the domain record. The $edit array will hold the
112 * new, replacement values. This is useful when making changes to
113 * records, such as in domain_user_domainupdate().
114 *
115 * @param $op
116 * The operation being performed: 'create', 'update', 'delete'
117 * @param $domain
118 * The domain record taken from {domain}, as an array.
119 * @param $form_state
120 * The form values processed by the form. Note that these are not editable since
121 * module_invoke_all() cannot pass by reference. We set $form_state to an array
122 * by default in case this hook gets called by a non-form function.
123 *
124 * @ingroup domain_hooks
125 */
126 function hook_domainupdate($op, $domain, $form_state = array()) {
127 switch ($op) {
128 case 'create':
129 db_query("INSERT INTO {mytable} (subdomain, sitename) VALUES ('%s', '%s')", $domain['subdomain'], $domain['sitename']);
130 break;
131 case 'update':
132 db_query("UPDATE {mytable} SET subdomain = '%s', sitename = '%s' WHERE domain_id = %d", $domain['subdomain'], $domain['sitename'], $domain['domain_id']);
133 break;
134 case 'delete':
135 db_query("DELETE FROM {mytable} WHERE subdomain = '%s'", $domain['subdomain']);
136 break;
137 }
138 }
139
140 /**
141 * Returns links to additional functions for the Domain Access module's admin screen
142 *
143 * Note that if your page requires a user_access check other than 'administer domains'
144 * you should explictly check permissions before returning the array.
145 *
146 * @param $domain
147 * An array of data for the active domain, taken from the {domain} table.
148 * - domain_id -- the unique identifier of this domain
149 * - subdomain -- the host path of the url for this domain
150 * - sitename -- the human-readable name of this domain
151 *
152 * @return
153 * An array of links to append to the admin screen, in the format:
154 * - title -- the link title
155 * - path -- the link path (a Drupal-formatted path)
156 * The data returned by this function will be passed through the l() function.
157 *
158 * If you do not provide a link for a specific domain, return FALSE.
159 *
160 * @ingroup domain_hooks
161 */
162 function hook_domainlinks($domain) {
163 // These actions do not apply to the primary domain.
164 if (user_access('my permission') && $domain['domain_id'] > 0) {
165 $links[] = array(
166 'title' => t('settings'),
167 'path' => 'admin/build/domain/myaction/'. $domain['domain_id']
168 );
169 return $links;
170 }
171 return FALSE;
172 }
173
174 /**
175 * Enables modules to add additional parameters to the $domain array
176 * for use by the Domain Navigation module.
177 *
178 * Used in cases where custom themes may require extra parameters.
179 * This hook is called by domain_nav_render().
180 *
181 * Default parameters should not be changed; these are:
182 *
183 * - domain_id -- the unique identifier of this domain
184 * - subdomain -- the host path of the url for this domain
185 * - sitename -- the human-readable name of this domain
186 * - path -- the link path (a Drupal-formatted path)
187 * - active -- a boolean flag indicating the currently active domain
188 *
189 * @ingroup domain_hooks
190 */
191 function hook_domainnav($domain) {
192 $extra = array();
193 $extra['test'] = 'test';
194 return $extra;
195 }
196
197 /**
198 * Enables Domain Access modules to fire cron hooks across all
199 * active domains.
200 *
201 * Each module implementing this hook will have the function run
202 * once per active domain record. The global $_domain variable
203 * will be set to the current $domain passed as an argument.
204 *
205 * This function is especially useful if you need to run node queries
206 * that obey node access rules.
207 *
208 * Note that Domain Prefix and Domain Conf are activated by this hook.
209 * That means each domain will have its tables and variables loaded before
210 * your function fires.
211 *
212 * @param $domain
213 * The information for the current domain record, taken from {domain}.
214 *
215 * @ingroup domain_hooks
216 */
217 function hook_domaincron($domain) {
218 // Run a node query.
219 $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n ORDER BY n.changed"), 0, 1);
220 $node = db_fetch_object($result);
221 // Set a variable for each domain containing the last node updated.
222 variable_set('domain_'. $domain['domain_id'] .'_lastnode', $node->nid);
223 }
224
225 /**
226 * Some Domain modules require that settings.php be edited to add
227 * additional files during the bootstrap process.
228 *
229 * This hook allows those modules to check to see if they have been installed
230 * correctly. Usually the module is enabled, but the required function is not.
231 *
232 * @see domain_conf_domaininstall()
233 *
234 * @ingroup domain_hooks
235 */
236 function hook_domaininstall() {
237 // If MyModule is being used, check to see that it is installed correctly.
238 if (module_exists('mymodule') && !function_exists('_mymodule_load')) {
239 drupal_set_message(t('MyModule is not installed correctly. Please edit your settings.php file as described in <a href="!url">INSTALL.txt</a>', array('!url' => drupal_get_path('module', 'mymodule') .'/INSTALL.txt')));
240 }
241 }
242
243 /**
244 * Allows Domain modules to add columns to the domain list view at
245 * path 'admin/build/domain/view'.
246 *
247 * @param $op
248 * The operation being performed. Valid requests are:
249 * -- 'header' defines a column header according to theme_table.
250 * -- 'select' defines a string of data to be returned. Must be prefixed.
251 * The {domain} table is prefixed with 'd' -- do not select any columns
252 * from the domain table. You must not select domain_id from your table.
253 * -- 'join' defines a sql join to use to pull extra data. To properly enable
254 * sorting of all records, this MUST be a LEFT JOIN.
255 * -- 'data' defines the data to be written in the column for the
256 * specified domain.
257 * @param $domain
258 * The $domain object prepared by hook_domainload().
259 * @return
260 * Return values vary based on the $op value.
261 * -- 'header' return a $header array formatted as per theme_table().
262 * -- 'select' return a comman-separated list of fields to select from your table.
263 * -- 'join' return a LEFT JOIN statement for connecting your table to the {domain} table.
264 * -- 'data' return a $data element to print in the row.
265 *
266 * @see domain_user_domaininfo()
267 *
268 * @ingroup domain_hooks
269 */
270 function hook_domainview($op, $domain = array()) {
271 switch ($op) {
272 case 'header':
273 return array(array('data' => t('MyData'), 'field' => 'my.uid'), array('data' => t('MyName'), 'field' => 'my.name'));
274 break;
275 case 'select':
276 return 'my.uid, my.name';
277 case 'join':
278 return "LEFT JOIN {mytable} my ON my.domain_id = d.domain_id";
279 break;
280 case 'data':
281 if ($domain['uid']) {
282 $account = user_load(array('uid' => $domain['uid']));
283 return l($account->name, 'user/'. $account->uid);
284 }
285 break;
286 }
287 }
288
289 /**
290 * Allows other modules to add elements to the default Domain settings page.
291 *
292 * @param &$form
293 * The $form array generated for the Domain settings page. This must
294 * be passed by reference.
295 * Normally, you should include your form elements inside a new fieldset.
296 * @return
297 * No return value. The $form is modified by reference, as needed.
298 */
299 function hook_domainform(&$form) {
300 // Add the form element to the main screen.
301 $form['domain_mymodule'] = array(
302 '#type' => 'fieldset',
303 '#title' => t('Mymodule settings'),
304 '#collapsible' => TRUE,
305 '#collapsed' => TRUE
306 );
307 $options = drupal_map_assoc(array(-100, -25, -10, -5, -1, 0, 1, 5, 10, 25, 100));
308 $form['domain_mymodule']['domain_mymodule'] = array(
309 '#type' => 'select',
310 '#title' => t('Mymodule settings variable'),
311 '#options' => $options,
312 '#default_value' => variable_get('domain_mymodule', 0),
313 '#description' => t('You description goes here.')
314 );
315 }
316
317 /**
318 * Allows a warning message to be printed when entering specific forms that
319 * may have values that vary on each domain.
320 *
321 * @return
322 * An array of form_id values representing forms that require warnings.
323 *
324 * @ingroup domain_hooks
325 */
326 function hook_domainwarnings() {
327 // These are the forms for variables set by Domain Conf.
328 return array(
329 'system_admin_theme_settings',
330 'system_date_time_settings',
331 'system_site_information_settings',
332 'system_site_maintenance_settings'
333 );
334 }
335
336 /**
337 * Allows modules to specify the target link for a node.
338 *
339 * @param &$source
340 * The domain array from domain_get_node_match(), passed by reference.
341 * @param $nid
342 * The node id.
343 * @return
344 * No return value; modify $source by reference.
345 */
346 function hook_domain_source_alter(&$source, $nid) {
347 // Taken from the Domain Source module
348 $source = domain_source_lookup($nid);
349 }
350
351 /**
352 * Allows modules to specify the target link for a Drupal path.
353 *
354 * Note: This hook is not meant to be used for node paths, which
355 * are handled by hook_domain_source_alter(). This hook is split
356 * from hook_domain_source_alter() for better performance.
357 *
358 * Currently, no modules in the package implement this hook.
359 *
360 * @param &$source
361 * The domain array from domain_get_node_match(), passed by reference.
362 * @param $nid
363 * The identifier of the obect being rewritten. For nodes, this is the node id.
364 * In other instances, we may pass a $path string or other variable.
365 * @return
366 * No return value; modify $source by reference.
367 */
368 function hook_domain_source_path_alter(&$source, $path) {
369 // Always make admin links go to the primary domain.
370 $base = arg(0, $path);
371 if ($base == 'admin') {
372 $source = domain_default();
373 }
374 }
375
376 /**
377 * Allows modules to add additional form elements for saving as domain-specific
378 * settings.
379 *
380 * When naming your form arrays, remember that the final key is the name of
381 * the variable that you wish to alter. The example below changes the default
382 * user picture depending on the active domain.
383 *
384 * Preferred use is to wrap your form elements in a named fieldset, for easier
385 * viewing.
386 *
387 * This hook is implemented by the Domain Conf module.
388 *
389 * You may wish to pair this hook with hook_domainbatch() to allow the mass update
390 * of your settings.
391 *
392 * If you wish to store settings that are not related to another module, you must pass
393 * the following parameter:
394 *
395 * $form['myform']['#domain_setting'] = TRUE;
396 *
397 * Doing so will tell Domain Access that no default settings page exists, and that values
398 * must be stored for the primary domain. This feature is useful for creating special data
399 * that needs to be associated with a domain record but does not need a separate table.
400 *
401 * Using the variable override of hook_domainconf() is an alternative to creating a module
402 * and database table for use with hook_domainload().
403 *
404 * For site managers who wish to implement this hook in other modules, but cannot wait for
405 * patches, you do not need to hack the code. Simply put your functions inside a domain_conf.inc
406 * file and place that inside the domain_conf directory. This file should begin with <?php and conform
407 * to Drupal coding standards.
408 *
409 * @return
410 * A $form array element as defined by the FormsAPI.
411 *
412 * @ingroup domain_hooks
413 */
414 function hook_domainconf() {
415 $form['pictures'] = array(
416 '#type' => 'fieldset',
417 '#title' => t('User picture'),
418 '#collapsible' => TRUE,
419 '#collapsed' => FALSE,
420 );
421 $form['pictures']['user_picture_default'] = array(
422 '#type' => 'textfield',
423 '#title' => t('Default picture'),
424 '#default_value' => variable_get('user_picture_default', ''),
425 '#size' => 30,
426 '#maxlength' => 255,
427 '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.')
428 );
429 return $form;
430 }
431
432 /**
433 * Allows modules to expose batch editing functions.
434 *
435 * This hook makes it easier for site administrators to perform
436 * bulk updates. It is most useful for handling settings changes
437 * caused by moving from a staging to a production server.
438 *
439 * The function works by defining a $batch array that serves as a combination
440 * of menu hook and form element. The $batch array contains all the information
441 * needed to create an administrative page and form that will process your settings.
442 *
443 * For a basic example, see domain_domainbatch().
444 *
445 * For a more complex example, with custom processing, see domain_theme_domainbatch().
446 *
447 * The $batch array is formatted according to the following rules:
448 *
449 * - '#form' [required] An array that defines the form element for this item. It accepts any
450 * values defined by the FormsAPI. Do not, however, pass the #default_value element
451 * here. That value will be computed dynamically for each domain when the hook is processed.
452 *
453 * - '#system_default' [required] Used to fill the #default_value parameter for domains that do not have custom settings.
454 * Typically, this will be the result of a variable_get(). For domain_delete operations, this value should be set to zero (0).
455 *
456 * - '#meta_description' [required] Used to describe your action to end users.
457 *
458 * - '#override_default' [optional] A boolean value used to tell whether to use variable_get() to retrieve the current value.
459 * Use this when complex variables do not allow a normal usage.
460 * - '#domain_action' [required] Indicates what submit action will be invoked for this setting. Allowed values are:
461 * --- 'domain' == writes the value to the {domain} table. Normally, contributed modules will not use this option.
462 * --- 'domain_conf' == writes the value to the {domain_conf} table. Use in connection with hook_domainconf().
463 * --- 'domain_delete' == used to delete rows from specific tables. If this is used, the #table value must be present.
464 * --- 'custom' == used if you need your own submit handler. Must be paired with a #submit parameter.
465 *
466 * - '#submit' [optional] Used with the 'custom' #domain_action to define a custom submit handler for the form. This value
467 * should be a valid function name. It will be passed the $form_values array for processing.
468 *
469 * - '#validate' [optional] Used to define a validate handler for the form. This value
470 * should be a valid function name. It will be passed the $form_values array for processing.
471 *
472 * - '#lookup' [optional] Used with the 'custom' #domain_action to perform a default value lookup against a custom function.
473 * This value should be a valid function name. Your function must accept the $domain array as a parameter.
474 *
475 * - '#table' [optional] Used with the 'domain_delete' #domain_action to specify which table a row should be deleted from.
476 * This value may be a string or an array, if you need to perform multiple deletes. Deletes are performed against the domain_id
477 * of the selected domains.
478 *
479 * - '#variable' [optional] Used to perform changes for the default domain, which is stored in the {variables} table. If this
480 * value is not set, the root domain will not be exposed for batch editing.
481 *
482 * - '#data_type' [optional] Used to tell the system how to build your data entry query. Defaults to 'string'; possible values are:
483 * --- 'string' == the query will use '%s' to insert the data.
484 * --- 'integer' == the query will use %d to insert the data.
485 * --- 'float' == the query will use %f to insert the data.
486 * --- 'binary' == the query will use %b to insert the data.
487 * For more information, see db_query() in the Drupal API documentation.
488 *
489 * - '#weight' [optional] Used to weight the item in the menu system. Should normally be set to zero. Negative values
490 * are reserved for use by the core Domain Access module. The following values are in use:
491 * --- (-10) items used by Domain Access core.
492 * --- (-8) items used by Domain Configuration.
493 * --- (-6) items used by Domain Theme.
494 * --- (-2) items reserved for batch delete actions.
495 *
496 * - '#group' [optional] Used to place elements into fieldsets for the main domain configuration page. If not set, any
497 * new element will be added to the 'Site configuration' fieldset.
498 *
499 * - '#update_all' [optional] Allows the batch settings form to use one input field to reset all values. This should beginLogging
500 * set to TRUE in most cases. If your value must be unique per domain, set this to FALSE or leave empty.
501 *
502 * - '#module' [optional] Used to group like elements together on the batch action list.
503 *
504 * @ingroup domain_hooks
505 */
506 function hook_domainbatch() {
507 // A simple function to rename my setting in Domain Configuration.
508 $batch = array();
509 $batch['mysetting'] = array(
510 '#form' => array(
511 '#title' => t('My Settings'),
512 '#type' => 'textfield',
513 '#size' => 40,
514 '#maxlength' => 80,
515 '#description' => t('A description for the form'),
516 '#required' => TRUE,
517 ),
518 '#domain_action' => 'domain_conf',
519 '#meta_description' => t('Edit my setting value.'),
520 '#variable' => 'domain_mysetting',
521 '#validate' => 'domain_mysetting_validate',
522 '#data_type' => 'string',
523 '#weight' => 0,
524 '#group' => t('My settings'),
525 '#update_all' => TRUE,
526 '#module' => t('Domain Access'),
527 );
528 return $batch;
529 }
530
531 /**
532 * Return an array of forms for which we cannot run hook_form_alter().
533 * @return
534 * An array of form ids that should not run through domain_form_alter.
535 */
536 function hook_domainignore() {
537 // User login should always be from the current domain.
538 return array('user_login');
539 }
540
541 /**
542 * The Domain Bootstrap Process.
543 *
544 * There are some variables that Domain Access and its modules
545 * need to set before Drupal finishes loading. In effect, we have to add
546 * stages to the Drupal bootstrap process.
547 *
548 * These processes are initiated after settings.php is loaded, during
549 * DRUPAL_BOOTSTRAP_CONFIGURATION. We skip ahead and
550 * load DRUPAL_BOOTSTRAP_DATABASE to access db_query() and
551 * similar functions. However, the majority of Drupal functions are
552 * not yet available.
553 *
554 * The following modules will load during the bootstrap process, if enabled:
555 * -- domain
556 * -- domain_alias
557 * -- domain_conf
558 * -- domain_prefix
559 *
560 * If you create a custom module, it must be registered with the Domain
561 * Bootstrap Process. To register, you must:
562 *
563 * 1) Implement either or both of the following hooks:
564 * -- hook_domain_bootstrap_load().
565 * -- hook_domain_bootstrap_full().
566 * 2) Run domain_bootstrap_register() in mymodule_enable().
567 * 3) Run domain_bootstrap_unregister('mymodule') in mymodule_disable().
568 *
569 */
570 function hook_domain_bootstrap() {
571 // Documentation function.
572 }
573
574 /**
575 * Hook domain_bootstrap_lookup allows modules to modify the domain record used on the
576 * current page on bootstrap level, that is, before it is used anywhere else.
577 *
578 * This allows modules like Domain Alias to change the domain_id matched to the current
579 * domain name before related information is retrieved during domain_init().
580 *
581 * Note: Because this function is usually called VERY early, many Drupal
582 * functions or modules won't be loaded yet.
583 *
584 * In order for this hook to work your module needs to be registered with
585 * domain_bootstrap_register() during hook_enable();
586 *
587 * Modules must also use domain_bootsrap_unregister('mymodule') during hook_disable().
588 *
589 * @param $domain
590 * An array containing current domain (host) name (used during bootstrap) and
591 * the results of lookup against {domain} table.
592 * @return
593 * An array containing at least a valid domain_id.
594 */
595 function hook_domain_bootstrap_lookup($domain) {
596 // Match en.example.org to default domain (id:0)
597 if ($domain['subdomain'] == 'en.example.org') {
598 $domain['domain_id'] = 0;
599 }
600 return $domain;
601 }
602
603 /**
604 * Hook hook_domain_bootstrap_full allows modules to execute code after the domain
605 * bootstrap phases which is called before drupal's hook_boot().
606 *
607 * This hook can be used to modify drupal's variables system or prefix database
608 * tables, as used in the modules domain_conf and domain_prefix.
609 *
610 * Note: Because this function is usually called VERY early, many Drupal
611 * functions or modules won't be loaded yet.
612 *
613 * In order for this hook to work your module needs to be registered with
614 * domain_bootstrap_register() during hook_enable();
615 *
616 * Modules must also use domain_bootsrap_unregister('mymodule') during hook_disable().
617 *
618 * @param $domain
619 * An array containing current domain and domain_id and any other values
620 * added during domain bootstrap phase 2 (DOMAIN_BOOTSTRAP_DOMAINNAME_RESOLVE).
621 *
622 * @return
623 * No return value. However, if you wish to set an error message on failure, you
624 * should load and modify the $_domain global and add an 'error' element to the array.
625 * This element should only include the name of your module.
626 * We do this because drupal_set_message() and t() are not yet loaded.
627 *
628 * Normally, you do not need to validate errors, since this function will not
629 * be called unless $domain is set properly.
630 */
631 function hook_domain_bootstrap_full($domain) {
632 global $conf;
633 // The language variable should not be set yet.
634 // Check for errors.
635 if (isset($conf['language'])) {
636 global $_domain;
637 $_domain['error'] = 'mymodule';
638 return;
639 }
640 // Our test module sets the default language to Spanish.
641 $conf['language'] = 'es';
642 }
643
644 /**
645 * Allows modules to alter path when rewriting URLs.
646 *
647 * This hook will fire for all paths and may be resource-intensive.
648 * Look at Domain Prefix for best practices implementation. In Domain
649 * Prefix, we only include this function if we know it is necessary.
650 *
651 * @see domain_prefix_init()
652 *
653 * @param $domain_id
654 * The domain_id taken from {domain}.
655 * @param $path
656 * The internal drupal path to the node.
657 * @param $path_language
658 * Language code to look up the path in.
659 *
660 * @ingroup domain_hooks
661 */
662 function hook_domainpath($domain_id, &$path, $path_language = '') {
663 // Give a normal path alias
664 $path = drupal_get_path_alias($path);
665 }
666
667 /**
668 * Demonstrates domain_conf_variable_set().
669 *
670 * Allows module to reset domain-specific variables.
671 * This function is not a hook, it is a helper function
672 * that is implemented by the Domain Configuration module.
673 *
674 * Use this function if you need to reset a domain-specific variable
675 * from your own code. It is especially useful in conjunction with
676 * hook_domainupdate().
677 *
678 * @link http://drupal.org/node/367963
679 *
680 * @param $domain_id
681 * The unique domain ID that is being edited.
682 * @param $variable
683 * The name of the variable you wish to set.
684 * @param $value
685 * The value of the variable to set. You may leave this
686 * value blank in order to unset the custom variable.
687 */
688 function mymodule_form_submit($form_state) {
689 // When we save these changes, replicate them across all domains.
690 if (!module_exists('domain_conf')) {
691 return;
692 }
693 $domains = domain_domains();
694 foreach ($domains as $domain) {
695 $value = $form_state['values']['my_variable'];
696 domain_conf_variable_set($domain['domain_id'], 'my_variable', $value);
697 }
698 }

  ViewVC Help
Powered by ViewVC 1.1.2