diff --git a/.gitignore b/.gitignore
index cd0a85b..ebd6797 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,5 @@ sites/*/files
sites/*/private
vendor/*
+
+*.tar.gz
diff --git a/sites/all/modules/contrib/admin/admin_menu/README.txt b/sites/all/modules/contrib/admin/admin_menu/README.txt
index f66a61e..6fe556d 100644
--- a/sites/all/modules/contrib/admin/admin_menu/README.txt
+++ b/sites/all/modules/contrib/admin/admin_menu/README.txt
@@ -1,65 +1,84 @@
+CONTENTS OF THIS FILE
+---------------------
--- SUMMARY --
+ * Introduction
+ * Requirements
+ * Installation
+ * Configuration
+ * Customization
+ * Troubleshooting
+ * FAQ
+ * Maintainers
+
+
+INTRODUCTION
+------------
The Administration menu module displays the entire administrative menu tree (and
most local tasks) in a drop-down menu, providing administrators one- or
two-click access to most pages. Other modules may also add menu links to the
menu using hook_admin_menu_output_alter().
-For a full description of the module, visit the project page:
- http://drupal.org/project/admin_menu
+For a full description of the project visit the project page:
+http://drupal.org/project/admin_menu
To submit bug reports and feature suggestions, or to track changes:
- http://drupal.org/project/issues/admin_menu
+http://drupal.org/project/issues/admin_menu
--- REQUIREMENTS --
+REQUIREMENTS
+------------
-None.
+No special requirements
--- INSTALLATION --
+INSTALLATION
+------------
-* Install as usual, see http://drupal.org/node/70151 for further information.
+Install as you would normally install a contributed Drupal. See:
+https://drupal.org/documentation/install/modules-themes/modules-7 for further
+information.
-* You likely want to disable Toolbar module, since its output clashes with
- Administration menu.
+ * You likely want to disable Toolbar module, since its output clashes with
+ Administration menu.
--- CONFIGURATION --
+CONFIGURATION
+-------------
-* Configure user permissions in Administration » People » Permissions:
+ * Configure user permissions in Administration » People » Permissions:
- - Use the administration pages and help (System module)
+ - Use the administration pages and help (System module)
- The top-level administration categories require this permission to be
- accessible. The administration menu will be empty unless this permission is
- granted.
+ The top-level administration categories require this permission to be
+ accessible. The administration menu will be empty unless this permission is
+ granted.
- - Access administration menu
+ - Access administration menu
- Users in roles with the "Access administration menu" permission will see
- the administration menu at the top of each page.
+ Users in roles with the "Access administration menu" permission will see
+ the administration menu at the top of each page.
- - Display Drupal links
+ - Display Drupal links
- Users in roles with the "Display drupal links" permission will receive
- links to drupal.org issue queues for all enabled contributed modules. The
- issue queue links appear under the administration menu icon.
+ Users in roles with the "Display drupal links" permission will receive
+ links to drupal.org issue queues for all enabled contributed modules. The
+ issue queue links appear under the administration menu icon.
- Note that the menu items displayed in the administration menu depend on the
- actual permissions of the viewing user. For example, the "People" menu item
- is not displayed to a user who is not a member of a role with the "Administer
- users" permission.
+ Note that the menu items displayed in the administration menu depend on the
+ actual permissions of the viewing user. For example, the "People" menu item
+ is not displayed to a user who is not a member of a role with the
+ "Administer users" permission.
-* Customize the menu settings in Administration » Configuration and modules »
- Administration » Administration menu.
+ * Customize the menu settings in Administration » Configuration and modules »
+ Administration » Administration menu.
-* To prevent administrative menu items from appearing twice, you may hide the
- "Management" menu block.
+ * To prevent administrative menu items from appearing twice, you may hide the
+ "Management" menu block.
--- CUSTOMIZATION --
+CUSTOMIZATION
+-------------
* To override the default administration menu icon, you may:
@@ -82,12 +101,13 @@ None.
body #admin-menu { font-size: 10px; }
--- TROUBLESHOOTING --
+TROUBLESHOOTING
+-------------
* If the menu does not display, check the following:
- - Are the "Access administration menu" and "Use the administration pages and help"
- permissions enabled for the appropriate roles?
+ - Are the "Access administration menu" and "Use the administration pages and
+ help" permissions enabled for the appropriate roles?
- Does html.tpl.php of your theme output the $page_bottom variable?
@@ -99,90 +119,102 @@ None.
See http://drupal.org/node/195386 for further information.
--- FAQ --
+FAQ
+---
-Q: When the administration menu module is enabled, blank space is added to the
- bottom of my theme. Why?
+ Q: When the administration menu module is enabled, blank space is added to the
+ bottom of my theme. Why?
-A: This is caused by a long list of links to module issue queues at Drupal.org.
- Use Administer >> User management >> Permissions to disable the "display
- drupal links" permission for all appropriate roles. Note that since UID 1
- automatically receives all permissions, the list of issue queue links cannot
- be disabled for UID 1.
+ A: This is caused by a long list of links to module issue queues at Drupal.org.
+ Use Administer >> User management >> Permissions to disable the "display
+ drupal links" permission for all appropriate roles. Note that since UID 1
+ automatically receives all permissions, the list of issue queue links cannot
+ be disabled for UID 1.
-Q: After upgrading to 6.x-1.x, the menu disappeared. Why?
+ Q: After upgrading to 6.x-1.x, the menu disappeared. Why?
-A: You may need to regenerate your menu. Visit
- http://example.com/admin/build/modules to regenerate your menu (substitute
- your site name for example.com).
+ A: You may need to regenerate your menu. Visit
+ http://example.com/admin/build/modules to regenerate your menu (substitute
+ your site name for example.com).
-Q: Can I configure the administration menu module to display another menu (like
- the Navigation menu, for instance)?
+ Q: Can I configure the administration menu module to display another menu (like
+ the Navigation menu, for instance)?
-A: No. As the name implies, administration menu module is for administrative
- menu links only. However, you can copy and paste the contents of
- admin_menu.css into your theme's stylesheet and replace #admin-menu with any
- other menu block id (#block-menu-1, for example).
+ A: No. As the name implies, administration menu module is for administrative
+ menu links only. However, you can copy and paste the contents of
+ admin_menu.css into your theme's stylesheet and replace #admin-menu with any
+ other menu block id (#block-menu-1, for example).
-Q: Sometimes, the user counter displays a lot of anonymous users, but no spike
- of users or requests appear in Google Analytics or other tracking tools.
+ Q: Sometimes, the user counter displays a lot of anonymous users, but no spike
+ of users or requests appear in Google Analytics or other tracking tools.
-A: If your site was concurrently spidered by search-engine robots, it may have
- a significant number of anonymous users for a short time. Most web tracking
- tools like Google Analytics automatically filter out these requests.
+ A: If your site was concurrently spidered by search-engine robots, it may have
+ a significant number of anonymous users for a short time. Most web tracking
+ tools like Google Analytics automatically filter out these requests.
-Q: I enabled "Aggregate and compress CSS files", but admin_menu.css is still
- there. Is this normal?
+ Q: I enabled "Aggregate and compress CSS files", but admin_menu.css is still
+ there. Is this normal?
-A: Yes, this is the intended behavior. the administration menu module only loads
- its stylesheet as needed (i.e., on page requests by logged-on, administrative
- users).
+ A: Yes, this is the intended behavior. the administration menu module only
+ loads its stylesheet as needed (i.e., on page requests by logged-on,
+ administrative users).
-Q: Why are sub-menus not visible in Opera?
+ Q: Why are sub-menus not visible in Opera?
-A: In the Opera browser preferences under "web pages" there is an option to fit
- to width. By disabling this option, sub-menus in the administration menu
- should appear.
+ A: In the Opera browser preferences under "web pages" there is an option to fit
+ to width. By disabling this option, sub-menus in the administration menu
+ should appear.
-Q: How can the administration menu be hidden on certain pages?
+ Q: How can the administration menu be hidden on certain pages?
-A: You can suppress it by simply calling the following function in PHP:
+ A: You can suppress it by simply calling the following function in PHP:
+ module_invoke('admin_menu', 'suppress');
- module_invoke('admin_menu', 'suppress');
-
- However, this needs to happen as early as possible in the page request, so
- placing it in the theming layer (resp. a page template file) is too late.
- Ideally, the function is called in hook_init() in a custom module. If you do
- not have a custom module, placing it into some conditional code at the top of
- template.php may work out, too.
+ However, this needs to happen as early as possible in the page request, so
+ placing it in the theming layer (resp. a page template file) is too late.
+ Ideally, the function is called in hook_init() in a custom module. If you
+ do not have a custom module, placing it into some conditional code at the
+ top of template.php may work out, too.
--- CONTACT --
+Q: What does the "Administration Development Tools" module do?
+
+A: The Administration Development Tools adds a jQuery Debugger which allows
+ a developer to debug and inspect arbitrary data/variables in Firebug's
+ console, and also to access them again in the global window object
+ (optionally using a named identifier, e.g. window.debug.myValue).
+ Chainable via jQuery. Especially useful for re-accessing and debugging
+ selected data via Firebug's console.
+
+
+MAINTAINERS
+-----------
Current maintainers:
-* Daniel F. Kudwien (sun) - http://drupal.org/user/54136
-* Peter Wolanin (pwolanin) - http://drupal.org/user/49851
-* Stefan M. Kudwien (smk-ka) - http://drupal.org/user/48898
-* Dave Reid (Dave Reid) - http://drupal.org/user/53892
+ * Daniel F. Kudwien (sun) - http://drupal.org/user/54136
+ * Peter Wolanin (pwolanin) - http://drupal.org/user/49851
+ * Stefan M. Kudwien (smk-ka) - http://drupal.org/user/48898
+ * Dave Reid (Dave Reid) - http://drupal.org/user/53892
+ * Truls S. Yggeseth (truls1502) - http://drupal.org/user/325866
+ * Sebastian Siemssen (fubhy) - https://www.drupal.org/user/761344
Major rewrite for Drupal 6 by Peter Wolanin (pwolanin).
This project has been sponsored by:
-* UNLEASHED MIND
- Specialized in consulting and planning of Drupal powered sites, UNLEASHED
- MIND offers installation, development, theming, customization, and hosting
- to get you started. Visit http://www.unleashedmind.com for more information.
+ * UNLEASHED MIND
+ Specialized in consulting and planning of Drupal powered sites, UNLEASHED
+ MIND offers installation, development, theming, customization, and hosting
+ to get you started. Visit http://www.unleashedmind.com for more information.
-* Lullabot
- Friendly Drupal experts providing professional consulting & education
- services. Visit http://www.lullabot.com for more information.
-
-* Acquia
- Commercially Supported Drupal. Visit http://acquia.com for more information.
+ * Lullabot
+ Friendly Drupal experts providing professional consulting & education
+ services. Visit http://www.lullabot.com for more information.
+ * Acquia
+ Commercially Supported Drupal. Visit http://acquia.com for more information.
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_devel/admin_devel.info b/sites/all/modules/contrib/admin/admin_menu/admin_devel/admin_devel.info
index 6408a1b..8b09eb1 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_devel/admin_devel.info
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_devel/admin_devel.info
@@ -4,9 +4,8 @@ package = Administration
core = 7.x
scripts[] = admin_devel.js
-; Information added by drupal.org packaging script on 2013-01-31
-version = "7.x-3.0-rc4"
+; Information added by Drupal.org packaging script on 2018-12-03
+version = "7.x-3.0-rc6"
core = "7.x"
project = "admin_menu"
-datestamp = "1359651687"
-
+datestamp = "1543859284"
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu-rtl.css b/sites/all/modules/contrib/admin/admin_menu/admin_menu-rtl.css
index 9414dcf..ff9f500 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu-rtl.css
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu-rtl.css
@@ -1,4 +1,3 @@
-
#admin-menu {
text-align: right;
}
@@ -25,7 +24,7 @@
border-right: 0;
}
#admin-menu .dropdown .admin-menu-tab a {
- border-left: 1px solid #52565E;
+ border-left: 1px solid #52565e;
border-right: 0;
}
#admin-menu .dropdown li li a {
@@ -42,13 +41,13 @@
/* Second-level lists */
#admin-menu .dropdown li ul {
left: auto;
- right: -999em;
+ right: auto;
}
/* Third-and-above-level lists */
#admin-menu .dropdown li li.expandable ul {
- margin-left: 0;
- margin-right: 160px;
+ margin-left: 0 !important;
+ margin-right: 160px !important;
}
/* Lists nested under hovered list items */
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.admin.js b/sites/all/modules/contrib/admin/admin_menu/admin_menu.admin.js
index 9ee9f36..3753463 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.admin.js
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.admin.js
@@ -1,4 +1,8 @@
-(function($) {
+/**
+ * @file
+ */
+
+(function ($) {
/**
* Live preview of Administration menu components.
@@ -45,9 +49,9 @@ Drupal.behaviors.adminMenuPermissionsSetupHelp = {
// Figure out which is the other, check whether it still disabled,
// and if so, ask whether to auto-enable it.
var other = (this == $admin[index] ? $menu[index] : $admin[index]);
- if (!other.checked && confirm(Drupal.t('Also allow !name role to !permission?', {
- '!name': $roles[index].textContent,
- '!permission': (this == $admin[index] ? menuPermission : adminPermission)
+ if (!other.checked && confirm(Drupal.t('Also allow @name role to @permission?', {
+ '@name': $roles[index].textContent,
+ '@permission': (this == $admin[index] ? menuPermission : adminPermission)
}))) {
other.checked = 'checked';
}
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.color.css b/sites/all/modules/contrib/admin/admin_menu/admin_menu.color.css
index f2491cd..00cbf65 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.color.css
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.color.css
@@ -1,4 +1,3 @@
-
/**
* @file
* Administration menu color override.
@@ -17,7 +16,7 @@
border-right-color: #a91f1f;
}
#admin-menu ul li.admin-menu-tab a {
- border-right-color: #52565E;
+ border-right-color: #52565e;
}
#admin-menu li li a {
border-top-color: #801f1f;
@@ -32,8 +31,7 @@
#admin-menu li li.expandable {
background-color: #b93f3f;
}
-#admin-menu li li:hover,
-#admin-menu li li.iehover {
+#admin-menu li li:hover {
background-color: #690f0f;
}
#admin-menu li li.expandable:hover a,
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.css b/sites/all/modules/contrib/admin/admin_menu/admin_menu.css
index fd86dd7..73f15e3 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.css
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.css
@@ -1,4 +1,3 @@
-
/**
* @file
* Administration menu.
@@ -16,6 +15,7 @@
position: absolute;
text-align: left;
top: 0;
+ height: 30px;
width: 100%;
}
#admin-menu-wrapper {
@@ -62,7 +62,7 @@ body.admin-menu {
#admin-menu li > span {
background: transparent none;
border: none;
- color: #EEE;
+ color: #eee;
font-weight: normal;
text-align: left; /* LTR */
text-decoration: none;
@@ -74,7 +74,7 @@ body.admin-menu {
padding: 4px 8px;
}
#admin-menu .dropdown .admin-menu-tab a {
- border-right: 1px solid #52565E; /* LTR */
+ border-right: 1px solid #52565e; /* LTR */
}
#admin-menu .dropdown li li a {
border-right: none; /* LTR */
@@ -98,6 +98,7 @@ body.admin-menu {
#admin-menu .dropdown li li {
background: #202020;
filter: Alpha(opacity=88);
+ float: none;
opacity: 0.88;
width: 160px; /* Required for Opera */
}
@@ -126,11 +127,7 @@ body.admin-menu {
#admin-menu .dropdown li:hover ul ul,
#admin-menu .dropdown li:hover ul ul ul,
#admin-menu .dropdown li:hover ul ul ul ul,
-#admin-menu .dropdown li:hover ul ul ul ul ul,
-#admin-menu .dropdown li.iehover ul ul,
-#admin-menu .dropdown li.iehover ul ul ul,
-#admin-menu .dropdown li.iehover ul ul ul ul,
-#admin-menu .dropdown li.iehover ul ul ul ul ul {
+#admin-menu .dropdown li:hover ul ul ul ul ul {
display: none;
left: -999em; /* LTR */
}
@@ -140,12 +137,7 @@ body.admin-menu {
#admin-menu .dropdown li li:hover ul,
#admin-menu .dropdown li li li:hover ul,
#admin-menu .dropdown li li li li:hover ul,
-#admin-menu .dropdown li li li li li:hover ul,
-#admin-menu .dropdown li.iehover ul,
-#admin-menu .dropdown li li.iehover ul,
-#admin-menu .dropdown li li li.iehover ul,
-#admin-menu .dropdown li li li li.iehover ul,
-#admin-menu .dropdown li li li li li.iehover ul {
+#admin-menu .dropdown li li li li li:hover ul {
display: block;
left: auto; /* LTR */
}
@@ -155,36 +147,27 @@ body.admin-menu {
/* Second-and-more-level hovering */
#admin-menu .dropdown li li.expandable {
- background: #45454A url(images/arrow.png) no-repeat 145px 6px;
+ background: #45454a url(images/arrow.png) no-repeat 145px 6px;
}
-#admin-menu .dropdown li li:hover,
-#admin-menu .dropdown li li.iehover {
+#admin-menu .dropdown li li:hover {
background-color: #111;
}
#admin-menu .dropdown li li:hover a,
#admin-menu .dropdown li li:hover li:hover a,
#admin-menu .dropdown li li:hover li:hover li:hover a {
- color: #FFF;
+ color: #fff;
}
#admin-menu .dropdown li li.expandable:hover a,
#admin-menu .dropdown li li.expandable:hover li.expandable:hover a {
border-color: #444;
- color: #EEE;
+ color: #eee;
}
#admin-menu .dropdown li li.expandable:hover li a,
#admin-menu .dropdown li li.expandable:hover li.expandable:hover li a {
border-color: #323232;
}
-#admin-menu .dropdown li li:hover li a,
-#admin-menu .dropdown li li.iehover li a,
-#admin-menu .dropdown li li.iehover li.iehover li a {
- color: #EEE;
-}
-#admin-menu .dropdown li li.iehover a,
-#admin-menu .dropdown li li.iehover li.iehover a,
-#admin-menu .dropdown li li.iehover li.iehover li.iehover a {
- color: #FFF;
- width: 90%; /* IE */
+#admin-menu .dropdown li li:hover li a {
+ color: #eee;
}
/* Search form */
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.inc b/sites/all/modules/contrib/admin/admin_menu/admin_menu.inc
index e212970..5721d9a 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.inc
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.inc
@@ -97,7 +97,7 @@ function admin_menu_tree_dynamic(array $expand_map) {
$db_or = db_or();
foreach ($plids as $path_plids) {
$db_and = db_and();
- // plids with value 0 may be ignored.
+ // Plids with value 0 may be ignored.
foreach (array_filter($path_plids) as $column => $plid) {
$db_and->condition($column, $plid);
}
@@ -204,7 +204,7 @@ function admin_menu_merge_tree(array &$tree, array $tree_dynamic, array $expand_
foreach ($load_functions as $index => $function) {
if ($function) {
if (is_array($function)) {
- list($function,) = each($function);
+ $function = key($function);
}
// Add the loader function name minus "_load".
$placeholder = '%' . substr($function, 0, -5);
@@ -269,7 +269,7 @@ function admin_menu_translate($router_item, $map) {
// replace any other.
// @todo Doing this instead leads to plenty of duplicate links below
// admin/structure/menu; likely a hidden recursion problem.
- // $router_item['mlid'] = $router_item['href'] . $router_item['mlid'];
+ // $router_item['mlid'] = $router_item['href'] . $router_item['mlid'];.
$router_item['mlid'] = $router_item['href'];
// Turn menu callbacks into regular menu items to make them visible.
if ($router_item['type'] == MENU_CALLBACK) {
@@ -278,10 +278,12 @@ function admin_menu_translate($router_item, $map) {
// @see _menu_tree_check_access()
$key = (50000 + $router_item['weight']) . ' ' . $router_item['title'] . ' ' . $router_item['mlid'];
- return array($key => array(
- 'link' => $router_item,
- 'below' => array(),
- ));
+ return array(
+ $key => array(
+ 'link' => $router_item,
+ 'below' => array(),
+ ),
+ );
}
return array();
@@ -461,20 +463,22 @@ function admin_menu_links_icon() {
'#access' => user_access('display drupal links'),
'#href' => 'http://drupal.org',
);
- // Add links to project issue queues.
- foreach (module_list(FALSE, TRUE) as $module) {
- $info = drupal_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info');
- if (!isset($info['project']) || isset($links['icon']['drupal.org'][$info['project']])) {
- continue;
+ if (variable_get('admin_menu_issue_queues', TRUE)) {
+ // Add links to project issue queues.
+ foreach (module_list(FALSE, TRUE) as $module) {
+ $info = drupal_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info');
+ if (!isset($info['project']) || isset($links['icon']['drupal.org'][$info['project']])) {
+ continue;
+ }
+ $links['icon']['drupal.org'][$info['project']] = array(
+ '#title' => t('@project issue queue', array('@project' => $info['name'])),
+ '#weight' => ($info['project'] == 'drupal' ? -10 : 0),
+ '#href' => 'http://drupal.org/project/issues/' . $info['project'],
+ '#options' => array(
+ 'query' => array('version' => (isset($info['core']) ? $info['core'] : 'All')),
+ ),
+ );
}
- $links['icon']['drupal.org'][$info['project']] = array(
- '#title' => t('@project issue queue', array('@project' => $info['name'])),
- '#weight' => ($info['project'] == 'drupal' ? -10 : 0),
- '#href' => 'http://drupal.org/project/issues/' . $info['project'],
- '#options' => array(
- 'query' => array('version' => (isset($info['core']) ? $info['core'] : 'All')),
- ),
- );
}
// Add items to flush caches.
$links['icon']['flush-cache'] = array(
@@ -497,18 +501,6 @@ function admin_menu_links_icon() {
);
}
- // Add link to toggle developer modules (performance).
- $saved_state = variable_get('admin_menu_devel_modules_enabled', NULL);
- $links['icon']['toggle-modules'] = array(
- '#title' => isset($saved_state) ? t('Enable developer modules') : t('Disable developer modules'),
- '#weight' => 88,
- '#access' => user_access('administer modules'),
- '#href' => 'admin_menu/toggle-modules',
- '#options' => array(
- 'query' => $destination + array('token' => drupal_get_token('admin_menu/toggle-modules')),
- ),
- );
-
// Add Devel module menu links.
if (module_exists('devel')) {
$devel_tree = menu_build_tree('devel');
@@ -582,7 +574,7 @@ function admin_menu_links_users() {
'#description' => t('Current anonymous / authenticated users'),
'#weight' => -90,
'#attributes' => array('class' => array('admin-menu-action', 'admin-menu-users')),
- '#href' => (user_access('administer users') ? 'admin/people/people' : 'user'),
+ '#href' => (user_access('administer users') ? 'admin/people' : 'user'),
);
return $links;
}
@@ -670,7 +662,7 @@ function admin_menu_theme_settings() {
'#default_value' => variable_get('admin_menu_tweak_modules', 0),
);
if (module_exists('util')) {
- $form['tweaks']['admin_menu_tweak_modules']['#description'] .= ' ' . t('If the Utility module was installed for this purpose, it can be safely disabled and uninstalled.') . '';
+ $form['tweaks']['admin_menu_tweak_modules']['#description'] = ' ' . t('If the Utility module was installed for this purpose, it can be safely disabled and uninstalled.') . '';
}
$form['tweaks']['admin_menu_tweak_permissions'] = array(
'#type' => 'checkbox',
@@ -697,28 +689,10 @@ function admin_menu_theme_settings() {
'#title' => t('Cache menu in client-side browser'),
'#default_value' => variable_get('admin_menu_cache_client', 1),
);
- // Fetch all available modules manually, since module_list() only returns
- // currently enabled modules, which makes this setting pointless if developer
- // modules are currently disabled.
- $all_modules = array();
- $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' ORDER BY name ASC");
- foreach ($result as $module) {
- if (file_exists($module->filename)) {
- $info = unserialize($module->info);
- $all_modules[$module->name] = $info['name'];
- }
- }
- $devel_modules = variable_get('admin_menu_devel_modules', _admin_menu_developer_modules());
- $devel_modules = array_intersect_key($all_modules, array_flip($devel_modules));
- $form['performance']['admin_menu_devel_modules_skip'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Developer modules to keep enabled'),
- '#default_value' => variable_get('admin_menu_devel_modules_skip', array()),
- '#options' => $devel_modules,
- '#access' => !empty($devel_modules),
- '#description' => t('The selected modules will not be disabled when the link %disable-developer-modules below the icon in the menu is invoked.', array(
- '%disable-developer-modules' => t('Disable developer modules'),
- )),
+ $form['performance']['admin_menu_issue_queues'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Show Issue Queue links in icon menu'),
+ '#default_value' => variable_get('admin_menu_issue_queues', 1),
);
return system_settings_form($form);
@@ -783,94 +757,6 @@ function _admin_menu_form_devel_admin_settings_alter(&$form, $form_state) {
);
}
-/**
- * Menu callback; Enable/disable developer modules.
- *
- * This can save up to 150ms on each uncached page request.
- */
-function admin_menu_toggle_modules() {
- if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], current_path())) {
- return MENU_ACCESS_DENIED;
- }
-
- $rebuild = FALSE;
- $saved_state = variable_get('admin_menu_devel_modules_enabled', NULL);
- if (isset($saved_state)) {
- // Re-enable modules that were enabled before.
- module_enable($saved_state);
- variable_del('admin_menu_devel_modules_enabled');
- drupal_set_message(t('Enabled these modules: !module-list.', array('!module-list' => implode(', ', $saved_state))));
- $rebuild = TRUE;
- }
- else {
- // Allow site admins to override this variable via settings.php.
- $devel_modules = variable_get('admin_menu_devel_modules', _admin_menu_developer_modules());
- // Store currently enabled modules in a variable.
- $devel_modules = array_intersect(module_list(FALSE, FALSE), $devel_modules);
- $devel_modules = array_diff($devel_modules, variable_get('admin_menu_devel_modules_skip', array()));
- if (!empty($devel_modules)) {
- variable_set('admin_menu_devel_modules_enabled', $devel_modules);
- // Disable developer modules.
- module_disable($devel_modules);
- drupal_set_message(t('Disabled these modules: !module-list.', array('!module-list' => implode(', ', $devel_modules))));
- $rebuild = TRUE;
- }
- else {
- drupal_set_message(t('No developer modules are enabled.'));
- }
- }
- if ($rebuild) {
- // Make sure everything is rebuilt, basically a combination of the calls
- // from system_modules() and system_modules_submit().
- drupal_theme_rebuild();
- menu_rebuild();
- cache_clear_all('schema', 'cache');
- cache_clear_all();
- drupal_clear_css_cache();
- drupal_clear_js_cache();
- // Synchronize to catch any actions that were added or removed.
- actions_synchronize();
- // Finally, flush admin_menu's cache.
- admin_menu_flush_caches();
- }
- drupal_goto();
-}
-
-/**
- * Helper function to return a default list of developer modules.
- */
-function _admin_menu_developer_modules() {
- return array(
- 'admin_devel',
- 'cache_disable',
- 'coder',
- 'content_copy',
- 'context_ui',
- 'debug',
- 'delete_all',
- 'demo',
- 'devel',
- 'devel_node_access',
- 'devel_themer',
- 'field_ui',
- 'fontyourface_ui',
- 'form_controller',
- 'imagecache_ui',
- 'journal',
- 'l10n_client',
- 'l10n_update',
- 'macro',
- 'rules_admin',
- 'stringoverrides',
- 'trace',
- 'upgrade_status',
- 'user_display_ui',
- 'util',
- 'views_ui',
- 'views_theme_wizard',
- );
-}
-
/**
* Flush all caches or a specific one.
*
@@ -886,18 +772,20 @@ function admin_menu_flush_cache($name = NULL) {
if (!isset($caches[$name])) {
return MENU_NOT_FOUND;
}
+ $message = t('@title cache cleared.', array('@title' => $caches[$name]['title']));
}
else {
$caches[$name] = array(
'title' => t('Every'),
'callback' => 'drupal_flush_all_caches',
);
+ $message = t('All caches cleared.');
}
// Pass the cache to flush forward to the callback.
$function = $caches[$name]['callback'];
$function($name);
- drupal_set_message(t('!title cache cleared.', array('!title' => $caches[$name]['title'])));
+ drupal_set_message($message);
// The JavaScript injects a destination request parameter pointing to the
// originating page, so the user is redirected back to that page. Without
@@ -1030,4 +918,3 @@ function template_preprocess_admin_menu_icon(&$variables) {
function theme_admin_menu_icon($variables) {
return '';
}
-
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.info b/sites/all/modules/contrib/admin/admin_menu/admin_menu.info
index ee58c66..ffd22e4 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.info
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.info
@@ -8,9 +8,8 @@ configure = admin/config/administration/admin_menu
dependencies[] = system (>7.10)
files[] = tests/admin_menu.test
-; Information added by drupal.org packaging script on 2013-01-31
-version = "7.x-3.0-rc4"
+; Information added by Drupal.org packaging script on 2018-12-03
+version = "7.x-3.0-rc6"
core = "7.x"
project = "admin_menu"
-datestamp = "1359651687"
-
+datestamp = "1543859284"
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.install b/sites/all/modules/contrib/admin/admin_menu/admin_menu.install
index 70e31c6..4e5443d 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.install
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.install
@@ -33,9 +33,6 @@ function admin_menu_install() {
function admin_menu_uninstall() {
// Delete variables.
variable_del('admin_menu_components');
- variable_del('admin_menu_devel_modules');
- variable_del('admin_menu_devel_modules_enabled');
- variable_del('admin_menu_devel_modules_skip');
variable_del('admin_menu_margin_top');
variable_del('admin_menu_position_fixed');
variable_del('admin_menu_tweak_modules');
@@ -44,6 +41,10 @@ function admin_menu_uninstall() {
variable_del('admin_menu_display');
variable_del('admin_menu_cache_server');
variable_del('admin_menu_cache_client');
+ // Unused variables still should be deleted.
+ variable_del('admin_menu_devel_modules');
+ variable_del('admin_menu_devel_modules_enabled');
+ variable_del('admin_menu_devel_modules_skip');
}
/**
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.js b/sites/all/modules/contrib/admin/admin_menu/admin_menu.js
index de0bb90..1e32b3d 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.js
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.js
@@ -1,4 +1,8 @@
-(function($) {
+/**
+ * @file
+ */
+
+(function ($) {
Drupal.admin = Drupal.admin || {};
Drupal.admin.behaviors = Drupal.admin.behaviors || {};
@@ -139,7 +143,7 @@ Drupal.admin.getCache = function (hash, onSuccess) {
*
* @see toolbar.js
*/
-Drupal.admin.height = function() {
+Drupal.admin.height = function () {
var $adminMenu = $('#admin-menu');
var height = $adminMenu.outerHeight();
// In IE, Shadow filter adds some extra height, so we need to remove it from
@@ -161,7 +165,7 @@ Drupal.admin.height = function() {
Drupal.admin.attachBehaviors = function (context, settings, $adminMenu) {
if ($adminMenu.length) {
$adminMenu.addClass('admin-menu-processed');
- $.each(Drupal.admin.behaviors, function() {
+ $.each(Drupal.admin.behaviors, function () {
this(context, settings, $adminMenu);
});
}
@@ -206,7 +210,7 @@ Drupal.admin.behaviors.replacements = function (context, settings, $adminMenu) {
*/
Drupal.admin.behaviors.destination = function (context, settings, $adminMenu) {
if (settings.admin_menu.destination) {
- $('a.admin-menu-destination', $adminMenu).each(function() {
+ $('a.admin-menu-destination', $adminMenu).each(function () {
this.search += (!this.search.length ? '?' : '&') + Drupal.settings.admin_menu.destination;
});
}
@@ -219,18 +223,6 @@ Drupal.admin.behaviors.destination = function (context, settings, $adminMenu) {
* it will not run last.
*/
Drupal.admin.behaviors.hover = function (context, settings, $adminMenu) {
- // Hover emulation for IE 6.
- if ($.browser.msie && parseInt(jQuery.browser.version) == 6) {
- $('li', $adminMenu).hover(
- function () {
- $(this).addClass('iehover');
- },
- function () {
- $(this).removeClass('iehover');
- }
- );
- }
-
// Delayed mouseout.
$('li.expandable', $adminMenu).hover(
function () {
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.map.inc b/sites/all/modules/contrib/admin/admin_menu/admin_menu.map.inc
index 72a8960..831e324 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.map.inc
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.map.inc
@@ -58,68 +58,59 @@ function node_admin_menu_map() {
/**
* Implements hook_admin_menu_map() on behalf of Field UI module.
+ *
+ * @todo Figure out how to fix the comment entity bundle mappings.
*/
function field_ui_admin_menu_map() {
$map = array();
- foreach (entity_get_info() as $obj_type => $info) {
- foreach ($info['bundles'] as $bundle_name => $bundle_info) {
- if (isset($bundle_info['admin'])) {
- $arguments = array();
- switch ($obj_type) {
- case 'comment':
- $fields = array();
- foreach (field_info_instances($obj_type, $bundle_name) as $field) {
- $fields[] = $field['field_name'];
- }
- // @todo Make Comment module expose the original node type bundle,
- // pretty please.
- if (drupal_substr($bundle_name, 0, 13) == 'comment_node_') {
- $bundle_name = drupal_substr($bundle_name, 13);
- }
- // @todo Doesn't work yet. Why?
- $arguments = array(
- '%comment_node_type' => array($bundle_name),
- '%field_ui_menu' => $fields,
- );
- break;
- case 'node':
- $fields = array();
- foreach (field_info_instances($obj_type, $bundle_name) as $field) {
- $fields[] = $field['field_name'];
- }
- $arguments = array(
- '%node_type' => array($bundle_name),
- '%field_ui_menu' => $fields,
- );
- break;
+ foreach (entity_get_info() as $entity_type => $entity_info) {
+ if (!$entity_info['fieldable']) {
+ continue;
+ }
- case 'taxonomy_term':
- $fields = array();
- foreach (field_info_instances($obj_type, $bundle_name) as $field) {
- $fields[] = $field['field_name'];
- }
- // Map machine_name to vid.
- $arguments = array(
- '%taxonomy_vocabulary_machine_name' => array($bundle_name),
- '%field_ui_menu' => $fields,
- );
- break;
+ foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
+ // @see field_ui_menu()
+ if (!isset($bundle_info['admin'])) {
+ continue;
+ }
- case 'user':
- $arguments = array(
- '%field_ui_menu' => array_keys(field_info_fields('user')),
- );
- break;
+ // Check access to this bundle.
+ $bundle_info['admin'] += array(
+ 'access callback' => 'user_access',
+ 'access arguments' => array('administer site configuration'),
+ );
+ $access_arguments = $bundle_info['admin']['access arguments'];
+ if (isset($bundle_info['admin']['real path'])) {
+ $menu_item = menu_get_item($bundle_info['admin']['real path']);
+ if (isset($menu_item['map'])) {
+ $access_arguments = menu_unserialize(serialize($access_arguments), $menu_item['map']);
}
- if (!empty($arguments)) {
- $path = $bundle_info['admin']['path'];
- $map["$path/fields/%field_ui_menu"]['parent'] = "$path/fields";
- $map["$path/fields/%field_ui_menu"]['arguments'][] = $arguments;
+ }
+ if (!call_user_func_array($bundle_info['admin']['access callback'], $access_arguments)) {
+ continue;
+ }
+
+ if ($fields = field_info_instances($entity_type, $bundle)) {
+ $path = $bundle_info['admin']['path'];
+ $argument = array();
+ if (isset($bundle_info['admin']['bundle argument'])) {
+ $bundle_arg = arg($bundle_info['admin']['bundle argument'], $path);
+ $argument[$bundle_arg] = array($bundle);
}
+ $argument['%field_ui_menu'] = array_keys($fields);
+
+ if (!isset($map["$path/fields/%field_ui_menu"])) {
+ $map["$path/fields/%field_ui_menu"] = array(
+ 'parent' => "$path/fields",
+ 'arguments' => array(),
+ );
+ }
+ $map["$path/fields/%field_ui_menu"]['arguments'][] = $argument;
}
}
}
+
return $map;
}
@@ -161,4 +152,3 @@ function views_ui_admin_menu_map() {
);
return $map;
}
-
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.module b/sites/all/modules/contrib/admin/admin_menu/admin_menu.module
index 8a8dee1..f9ce3ae 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.module
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.module
@@ -63,7 +63,7 @@ function admin_menu_theme() {
function admin_menu_menu() {
// AJAX callback.
// @see http://drupal.org/project/js
- $items['js/admin_menu/cache'] = array(
+ $items['js/admin_menu/cache/%'] = array(
'page callback' => 'admin_menu_js_cache',
'delivery callback' => 'admin_menu_deliver',
'access arguments' => array('access administration menu'),
@@ -78,7 +78,7 @@ function admin_menu_menu() {
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
- $items['admin/config/administration/admin_menu'] = array(
+ $items['admin/config/administration/admin-menu'] = array(
'title' => 'Administration menu',
'description' => 'Adjust administration menu settings.',
'page callback' => 'drupal_get_form',
@@ -87,12 +87,6 @@ function admin_menu_menu() {
'file' => 'admin_menu.inc',
);
// Menu link callbacks.
- $items['admin_menu/toggle-modules'] = array(
- 'page callback' => 'admin_menu_toggle_modules',
- 'access arguments' => array('administer modules'),
- 'type' => MENU_CALLBACK,
- 'file' => 'admin_menu.inc',
- );
$items['admin_menu/flush-cache'] = array(
'page callback' => 'admin_menu_flush_cache',
'access arguments' => array('flush caches'),
@@ -217,7 +211,7 @@ function admin_menu_page_build(&$page) {
// @todo Drupal.behaviors.adminMenuMarginTop is obsolete, but
// hook_page_build() does not allow to set a CSS class on the body yet.
// @see http://drupal.org/node/1473548, http://drupal.org/node/1194528
- //$page['#attributes']['class'][] = 'admin-menu';
+ // $page['#attributes']['class'][] = 'admin-menu';
}
if ($setting = variable_get('admin_menu_position_fixed', 1)) {
$settings['position_fixed'] = $setting;
@@ -236,7 +230,7 @@ function admin_menu_page_build(&$page) {
if ($_GET['q'] == 'admin/modules' || strpos($_GET['q'], 'admin/modules/list') === 0) {
$settings['tweak_modules'] = variable_get('admin_menu_tweak_modules', 0);
}
- if ($_GET['q'] == 'admin/people/permissions' || $_GET['q'] == 'admin/people/permissions/list') {
+ if (strpos($_GET['q'], 'admin/people/permissions') === 0) {
$settings['tweak_permissions'] = variable_get('admin_menu_tweak_permissions', 0);
}
@@ -508,7 +502,6 @@ function admin_menu_output($complete = FALSE) {
// @todo Move the below callbacks into hook_admin_menu_build()
// implementations (and $module.admin_menu.inc).
-
// Add administration menu.
if (!empty($components['admin_menu.menu']) || $complete) {
$content['menu'] = admin_menu_links_menu(admin_menu_tree('management'));
@@ -554,7 +547,10 @@ function admin_menu_output($complete = FALSE) {
// Store the new hash for this user.
if (!empty($_COOKIE['has_js']) && !$complete) {
- admin_menu_cache_set($cid, md5($content));
+ $cache = cache_get($cid, 'cache_admin_menu');
+ if (!$cache || !isset($cache->data)) {
+ admin_menu_cache_set($cid, md5($content));
+ }
}
return $content;
@@ -609,11 +605,13 @@ function admin_menu_admin_menu_output_build(&$content) {
* Implements hook_admin_menu_output_alter().
*/
function admin_menu_admin_menu_output_alter(&$content) {
- foreach ($content['menu'] as $key => $link) {
- // Move local tasks on 'admin' into icon menu.
- if ($key == 'admin/tasks' || $key == 'admin/index') {
- $content['icon']['icon'][$key] = $link;
- unset($content['menu'][$key]);
+ if (!empty($content['menu'])) {
+ foreach ($content['menu'] as $key => $link) {
+ // Move local tasks on 'admin' into icon menu.
+ if ($key == 'admin/tasks' || $key == 'admin/index') {
+ $content['icon']['icon'][$key] = $link;
+ unset($content['menu'][$key]);
+ }
}
}
}
@@ -683,6 +681,13 @@ function theme_admin_menu_links($variables) {
$elements[$path]['#options']['attributes']['class'][] = 'admin-menu-destination';
}
+ // If the path has an alias replace the href with the alias.
+ if (module_exists('path')) {
+ if ($alias = drupal_get_path_alias($elements[$path]['#href'])) {
+ $elements[$path]['#href'] = $alias;
+ }
+ }
+
$link = l($elements[$path]['#title'], $elements[$path]['#href'], $elements[$path]['#options']);
}
// Handle plain text items, but do not interfere with menu additions.
@@ -757,7 +762,7 @@ function admin_menu_translated_menu_link_alter(&$item, $map) {
}
}
- // Don't waste cycles altering items that are not visible
+ // Don't waste cycles altering items that are not visible.
if (!$item['access']) {
return;
}
@@ -801,8 +806,8 @@ function admin_menu_flush_caches($uid = NULL) {
cache_clear_all($cid, 'cache_menu', TRUE);
// Flush client-side cache hashes.
drupal_static_reset('admin_menu_cache_get');
- // db_table_exists() required for SimpleTest.
- if (db_table_exists('cache_admin_menu')) {
+ // If cache_admin_menu is not empty, flush it.
+ if (!cache_is_empty('cache_admin_menu')) {
cache_clear_all(isset($uid) ? $cid : '*', 'cache_admin_menu', TRUE);
}
}
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu.uid1.css b/sites/all/modules/contrib/admin/admin_menu/admin_menu.uid1.css
index e375cfe..105fd24 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu.uid1.css
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu.uid1.css
@@ -1,4 +1,3 @@
-
/**
* @file
* Administration menu color override for uid1.
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar-rtl.css b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar-rtl.css
new file mode 100644
index 0000000..a159034
--- /dev/null
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar-rtl.css
@@ -0,0 +1,4 @@
+#admin-menu > div > .dropdown > li > a,
+#admin-menu > div > .dropdown > li > span {
+ border-left: 0;
+}
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.css b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.css
index a3e9f3e..f1bc093 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.css
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.css
@@ -1,4 +1,3 @@
-
/**
* @file
* Toolbar style for Administration menu.
@@ -63,8 +62,9 @@ body div#toolbar.toolbar {
background: url(toolbar.png) no-repeat 0 -45px;
text-indent: -9999px;
}
-#admin-menu > div > .dropdown > li > a {
- border-right: 0;
+#admin-menu > div > .dropdown > li > a,
+#admin-menu > div > .dropdown > li > span {
+ border-right: 0; /* LTR */
margin-bottom: 4px;
padding: 2px 10px 3px;
}
@@ -142,4 +142,3 @@ body div#toolbar.toolbar {
#admin-menu .shortcut-toolbar a {
display: block;
}
-
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.info b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.info
index 2514776..340ced0 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.info
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.info
@@ -4,9 +4,8 @@ package = Administration
core = 7.x
dependencies[] = admin_menu
-; Information added by drupal.org packaging script on 2013-01-31
-version = "7.x-3.0-rc4"
+; Information added by Drupal.org packaging script on 2018-12-03
+version = "7.x-3.0-rc6"
core = "7.x"
project = "admin_menu"
-datestamp = "1359651687"
-
+datestamp = "1543859284"
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.install b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.install
index bf067d7..f6449dc 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.install
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.install
@@ -34,4 +34,3 @@ function admin_menu_toolbar_update_6300() {
->condition('name', 'admin_menu_toolbar')
->execute();
}
-
diff --git a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module
index 74a9ee1..0f5c066 100644
--- a/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module
+++ b/sites/all/modules/contrib/admin/admin_menu/admin_menu_toolbar/admin_menu_toolbar.module
@@ -70,7 +70,7 @@ function admin_menu_toolbar_admin_menu_output_build(&$content) {
'#title' => t('Show shortcuts'),
'#href' => '',
'#options' => array(
- 'attributes' => array('class' => 'shortcut-toggle'),
+ 'attributes' => array('class' => array('shortcut-toggle')),
),
);
@@ -115,4 +115,3 @@ function admin_menu_toolbar_admin_menu_output_alter(&$content) {
$content['account']['account']['#options']['html'] = TRUE;
}
}
-
diff --git a/sites/all/modules/contrib/admin/admin_menu/tests/admin_menu.test b/sites/all/modules/contrib/admin/admin_menu/tests/admin_menu.test
index 4b48c9a..b7c611d 100644
--- a/sites/all/modules/contrib/admin/admin_menu/tests/admin_menu.test
+++ b/sites/all/modules/contrib/admin/admin_menu/tests/admin_menu.test
@@ -16,7 +16,10 @@ class AdminMenuWebTestCase extends DrupalWebTestCase {
'admin_menu' => 'access administration menu',
);
- function setUp() {
+ /**
+ *
+ */
+ public function setUp() {
// Enable admin menu module and any other modules.
$modules = func_get_args();
$modules = isset($modules[0]) ? $modules[0] : $modules;
@@ -108,12 +111,17 @@ class AdminMenuWebTestCase extends DrupalWebTestCase {
$xpath = '//div[@id="admin-menu"]/div/ul' . implode('/parent::li/ul', $xpath);
$this->assertNoElementByXPath($xpath, $args, $message . ' link not found.');
}
+
}
/**
* Tests menu links depending on user permissions.
*/
class AdminMenuPermissionsTestCase extends AdminMenuWebTestCase {
+
+ /**
+ *
+ */
public static function getInfo() {
return array(
'name' => 'Menu link access permissions',
@@ -122,14 +130,17 @@ class AdminMenuPermissionsTestCase extends AdminMenuWebTestCase {
);
}
- function setUp() {
+ /**
+ *
+ */
+ public function setUp() {
parent::setUp(array('node'));
}
/**
* Test that the links are added to the page (no JS testing).
*/
- function testPermissions() {
+ public function testPermissions() {
module_enable(array('contact'));
$this->resetAll();
@@ -140,7 +151,7 @@ class AdminMenuPermissionsTestCase extends AdminMenuWebTestCase {
// Create a user who
// - can access content overview
// - cannot access drupal.org links
- // - cannot administer Contact module
+ // - cannot administer Contact module.
$permissions = $this->basePermissions + array(
'access content overview',
);
@@ -156,7 +167,7 @@ class AdminMenuPermissionsTestCase extends AdminMenuWebTestCase {
// Create a user "reversed" to the above; i.e., who
// - cannot access content overview
// - can access drupal.org links
- // - can administer Contact module
+ // - can administer Contact module.
$permissions = $this->basePermissions + array(
'display drupal links',
'administer contact forms',
@@ -172,7 +183,7 @@ class AdminMenuPermissionsTestCase extends AdminMenuWebTestCase {
/**
* Tests handling of links pointing to category/overview pages.
*/
- function testCategories() {
+ public function testCategories() {
// Create a user with minimum permissions.
$admin_user = $this->drupalCreateUser($this->basePermissions);
$this->drupalLogin($admin_user);
@@ -201,7 +212,7 @@ class AdminMenuPermissionsTestCase extends AdminMenuWebTestCase {
/**
* Tests that user role and permission changes are properly taken up.
*/
- function testPermissionChanges() {
+ public function testPermissionChanges() {
// Create a user who is able to change permissions.
$permissions = $this->basePermissions + array(
'administer permissions',
@@ -253,12 +264,17 @@ class AdminMenuPermissionsTestCase extends AdminMenuWebTestCase {
// Verify that Structure » Content types does not appear.
$this->assertNoLinkTrailByTitle(array(t('Structure'), t('Content types')));
}
+
}
/**
* Tests appearance, localization, and escaping of dynamic links.
*/
class AdminMenuDynamicLinksTestCase extends AdminMenuWebTestCase {
+
+ /**
+ *
+ */
public static function getInfo() {
return array(
'name' => 'Dynamic links',
@@ -267,14 +283,17 @@ class AdminMenuDynamicLinksTestCase extends AdminMenuWebTestCase {
);
}
- function setUp() {
+ /**
+ *
+ */
+ public function setUp() {
parent::setUp(array('node'));
}
/**
* Tests node type links.
*/
- function testNode() {
+ public function testNode() {
$type = $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
// Create a content-type with special characters.
$type = $this->drupalCreateContentType(array('type' => 'special', 'name' => 'Cool & Special'));
@@ -324,7 +343,7 @@ class AdminMenuDynamicLinksTestCase extends AdminMenuWebTestCase {
/**
* Tests Add content links.
*/
- function testNodeAdd() {
+ public function testNodeAdd() {
$type = $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
// Verify that "Add content" does not appear for unprivileged users.
@@ -359,12 +378,17 @@ class AdminMenuDynamicLinksTestCase extends AdminMenuWebTestCase {
t('Add content'),
));
}
+
}
/**
* Tests appearance of different types of links.
*/
class AdminMenuLinkTypesTestCase extends AdminMenuWebTestCase {
+
+ /**
+ *
+ */
public static function getInfo() {
return array(
'name' => 'Link types',
@@ -373,7 +397,10 @@ class AdminMenuLinkTypesTestCase extends AdminMenuWebTestCase {
);
}
- function setUp() {
+ /**
+ *
+ */
+ public function setUp() {
parent::setUp(array('help'));
$permissions = module_invoke_all('permission');
@@ -385,7 +412,7 @@ class AdminMenuLinkTypesTestCase extends AdminMenuWebTestCase {
/**
* Tests appearance of different router item link types.
*/
- function testLinkTypes() {
+ public function testLinkTypes() {
// Verify that MENU_NORMAL_ITEMs appear.
$this->assertLinkTrailByTitle(array(
t('Configuration'),
@@ -420,12 +447,17 @@ class AdminMenuLinkTypesTestCase extends AdminMenuWebTestCase {
':title' => t('Index'),
), "Icon » Index link found.");
}
+
}
/**
* Tests customized menu links.
*/
class AdminMenuCustomizedTestCase extends AdminMenuWebTestCase {
+
+ /**
+ *
+ */
public static function getInfo() {
return array(
'name' => 'Customized links',
@@ -434,7 +466,10 @@ class AdminMenuCustomizedTestCase extends AdminMenuWebTestCase {
);
}
- function setUp() {
+ /**
+ *
+ */
+ public function setUp() {
parent::setUp(array('menu'));
$this->admin_user = $this->drupalCreateUser($this->basePermissions + array(
@@ -446,7 +481,7 @@ class AdminMenuCustomizedTestCase extends AdminMenuWebTestCase {
/**
* Test disabled custom links.
*/
- function testCustomDisabled() {
+ public function testCustomDisabled() {
$type = $this->drupalCreateContentType();
$node = $this->drupalCreateNode(array('type' => $type->type));
$text = $this->randomName();
@@ -488,7 +523,7 @@ class AdminMenuCustomizedTestCase extends AdminMenuWebTestCase {
/**
* Tests external links.
*/
- function testCustomExternal() {
+ public function testCustomExternal() {
// Add a custom link to the node to the menu.
$edit = array(
'link_path' => 'http://example.com',
@@ -516,5 +551,5 @@ class AdminMenuCustomizedTestCase extends AdminMenuWebTestCase {
':path' => $path,
))->fetchField();
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/admin_theme/LICENSE.txt b/sites/all/modules/contrib/admin/admin_theme/LICENSE.txt
index 2c095c8..d159169 100644
--- a/sites/all/modules/contrib/admin/admin_theme/LICENSE.txt
+++ b/sites/all/modules/contrib/admin/admin_theme/LICENSE.txt
@@ -1,274 +1,339 @@
-GNU GENERAL PUBLIC LICENSE
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
- Version 2, June 1991
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
-Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
-Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
-verbatim copies of this license document, but changing it is not allowed.
+ Preamble
- Preamble
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
-The licenses for most software are designed to take away your freedom to
-share and change it. By contrast, the GNU General Public License is
-intended to guarantee your freedom to share and change free software--to
-make sure the software is free for all its users. This General Public License
-applies to most of the Free Software Foundation's software and to any other
-program whose authors commit to using it. (Some other Free Software
-Foundation software is covered by the GNU Library General Public License
-instead.) You can apply it to your programs, too.
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
-When we speak of free software, we are referring to freedom, not price. Our
-General Public Licenses are designed to make sure that you have the
-freedom to distribute copies of free software (and charge for this service if
-you wish), that you receive source code or can get it if you want it, that you
-can change the software or use pieces of it in new free programs; and that
-you know you can do these things.
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
-To protect your rights, we need to make restrictions that forbid anyone to
-deny you these rights or to ask you to surrender the rights. These restrictions
-translate to certain responsibilities for you if you distribute copies of the
-software, or if you modify it.
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
-For example, if you distribute copies of such a program, whether gratis or for
-a fee, you must give the recipients all the rights that you have. You must make
-sure that they, too, receive or can get the source code. And you must show
-them these terms so they know their rights.
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
-We protect your rights with two steps: (1) copyright the software, and (2)
-offer you this license which gives you legal permission to copy, distribute
-and/or modify the software.
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
-Also, for each author's protection and ours, we want to make certain that
-everyone understands that there is no warranty for this free software. If the
-software is modified by someone else and passed on, we want its recipients
-to know that what they have is not the original, so that any problems
-introduced by others will not reflect on the original authors' reputations.
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
-Finally, any free program is threatened constantly by software patents. We
-wish to avoid the danger that redistributors of a free program will individually
-obtain patent licenses, in effect making the program proprietary. To prevent
-this, we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
+ The precise terms and conditions for copying, distribution and
+modification follow.
-The precise terms and conditions for copying, distribution and modification
-follow.
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
- MODIFICATION
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
-0. This License applies to any program or other work which contains a notice
-placed by the copyright holder saying it may be distributed under the terms
-of this General Public License. The "Program", below, refers to any such
-program or work, and a "work based on the Program" means either the
-Program or any derivative work under copyright law: that is to say, a work
-containing the Program or a portion of it, either verbatim or with
-modifications and/or translated into another language. (Hereinafter, translation
-is included without limitation in the term "modification".) Each licensee is
-addressed as "you".
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
-Activities other than copying, distribution and modification are not covered
-by this License; they are outside its scope. The act of running the Program is
-not restricted, and the output from the Program is covered only if its contents
-constitute a work based on the Program (independent of having been made
-by running the Program). Whether that is true depends on what the Program
-does.
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
-1. You may copy and distribute verbatim copies of the Program's source
-code as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice and
-disclaimer of warranty; keep intact all the notices that refer to this License
-and to the absence of any warranty; and give any other recipients of the
-Program a copy of this License along with the Program.
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
-You may charge a fee for the physical act of transferring a copy, and you
-may at your option offer warranty protection in exchange for a fee.
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
-2. You may modify your copy or copies of the Program or any portion of it,
-thus forming a work based on the Program, and copy and distribute such
-modifications or work under the terms of Section 1 above, provided that you
-also meet all of these conditions:
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
-a) You must cause the modified files to carry prominent notices stating that
-you changed the files and the date of any change.
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
-b) You must cause any work that you distribute or publish, that in whole or in
-part contains or is derived from the Program or any part thereof, to be
-licensed as a whole at no charge to all third parties under the terms of this
-License.
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
-c) If the modified program normally reads commands interactively when run,
-you must cause it, when started running for such interactive use in the most
-ordinary way, to print or display an announcement including an appropriate
-copyright notice and a notice that there is no warranty (or else, saying that
-you provide a warranty) and that users may redistribute the program under
-these conditions, and telling the user how to view a copy of this License.
-(Exception: if the Program itself is interactive but does not normally print such
-an announcement, your work based on the Program is not required to print
-an announcement.)
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
-These requirements apply to the modified work as a whole. If identifiable
-sections of that work are not derived from the Program, and can be
-reasonably considered independent and separate works in themselves, then
-this License, and its terms, do not apply to those sections when you distribute
-them as separate works. But when you distribute the same sections as part
-of a whole which is a work based on the Program, the distribution of the
-whole must be on the terms of this License, whose permissions for other
-licensees extend to the entire whole, and thus to each and every part
-regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest your rights to
-work written entirely by you; rather, the intent is to exercise the right to
-control the distribution of derivative or collective works based on the
-Program.
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of a
-storage or distribution medium does not bring the other work under the scope
-of this License.
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
-3. You may copy and distribute the Program (or a work based on it, under
-Section 2) in object code or executable form under the terms of Sections 1
-and 2 above provided that you also do one of the following:
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
-a) Accompany it with the complete corresponding machine-readable source
-code, which must be distributed under the terms of Sections 1 and 2 above
-on a medium customarily used for software interchange; or,
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
-b) Accompany it with a written offer, valid for at least three years, to give
-any third party, for a charge no more than your cost of physically performing
-source distribution, a complete machine-readable copy of the corresponding
-source code, to be distributed under the terms of Sections 1 and 2 above on
-a medium customarily used for software interchange; or,
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
-c) Accompany it with the information you received as to the offer to distribute
-corresponding source code. (This alternative is allowed only for
-noncommercial distribution and only if you received the program in object
-code or executable form with such an offer, in accord with Subsection b
-above.)
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source code
-means all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation and
-installation of the executable. However, as a special exception, the source
-code distributed need not include anything that is normally distributed (in
-either source or binary form) with the major components (compiler, kernel,
-and so on) of the operating system on which the executable runs, unless that
-component itself accompanies the executable.
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
-If distribution of executable or object code is made by offering access to
-copy from a designated place, then offering equivalent access to copy the
-source code from the same place counts as distribution of the source code,
-even though third parties are not compelled to copy the source along with the
-object code.
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
-4. You may not copy, modify, sublicense, or distribute the Program except as
-expressly provided under this License. Any attempt otherwise to copy,
-modify, sublicense or distribute the Program is void, and will automatically
-terminate your rights under this License. However, parties who have received
-copies, or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
-5. You are not required to accept this License, since you have not signed it.
-However, nothing else grants you permission to modify or distribute the
-Program or its derivative works. These actions are prohibited by law if you
-do not accept this License. Therefore, by modifying or distributing the
-Program (or any work based on the Program), you indicate your acceptance
-of this License to do so, and all its terms and conditions for copying,
-distributing or modifying the Program or works based on it.
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
-6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these terms and
-conditions. You may not impose any further restrictions on the recipients'
-exercise of the rights granted herein. You are not responsible for enforcing
-compliance by third parties to this License.
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
-7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues), conditions
-are imposed on you (whether by court order, agreement or otherwise) that
-contradict the conditions of this License, they do not excuse you from the
-conditions of this License. If you cannot distribute so as to satisfy
-simultaneously your obligations under this License and any other pertinent
-obligations, then as a consequence you may not distribute the Program at all.
-For example, if a patent license would not permit royalty-free redistribution
-of the Program by all those who receive copies directly or indirectly through
-you, then the only way you could satisfy both it and this License would be to
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply and
-the section as a whole is intended to apply in other circumstances.
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
-It is not the purpose of this section to induce you to infringe any patents or
-other property right claims or to contest validity of any such claims; this
-section has the sole purpose of protecting the integrity of the free software
-distribution system, which is implemented by public license practices. Many
-people have made generous contributions to the wide range of software
-distributed through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing to
-distribute software through any other system and a licensee cannot impose
-that choice.
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
-This section is intended to make thoroughly clear what is believed to be a
-consequence of the rest of this License.
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
-8. If the distribution and/or use of the Program is restricted in certain
-countries either by patents or by copyrighted interfaces, the original copyright
-holder who places the Program under this License may add an explicit
-geographical distribution limitation excluding those countries, so that
-distribution is permitted only in or among countries not thus excluded. In such
-case, this License incorporates the limitation as if written in the body of this
-License.
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
-9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will be
-similar in spirit to the present version, but may differ in detail to address new
-problems or concerns.
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
-Each version is given a distinguishing version number. If the Program specifies
-a version number of this License which applies to it and "any later version",
-you have the option of following the terms and conditions either of that
-version or of any later version published by the Free Software Foundation. If
-the Program does not specify a version number of this License, you may
-choose any version ever published by the Free Software Foundation.
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
-10. If you wish to incorporate parts of the Program into other free programs
-whose distribution conditions are different, write to the author to ask for
-permission. For software which is copyrighted by the Free Software
-Foundation, write to the Free Software Foundation; we sometimes make
-exceptions for this. Our decision will be guided by the two goals of
-preserving the free status of all derivatives of our free software and of
-promoting the sharing and reuse of software generally.
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
- NO WARRANTY
+ NO WARRANTY
-11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
-THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
-PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
-STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
-WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
-PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
-NECESSARY SERVICING, REPAIR OR CORRECTION.
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
-12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
-AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
-ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
-LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
-SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
-ARISING OUT OF THE USE OR INABILITY TO USE THE
-PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
-OR DATA BEING RENDERED INACCURATE OR LOSSES
-SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
-PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
-IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
- END OF TERMS AND CONDITIONS
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/sites/all/modules/contrib/admin/admin_theme/README.txt b/sites/all/modules/contrib/admin/admin_theme/README.txt
index 783bbda..e8acffe 100644
--- a/sites/all/modules/contrib/admin/admin_theme/README.txt
+++ b/sites/all/modules/contrib/admin/admin_theme/README.txt
@@ -1,18 +1,23 @@
-/* $Id: README.txt,v 1.1.2.2.2.1 2008/12/13 09:22:36 davyvandenbremt Exp $ */
Description
-----------
-Drupal allows you to define a different theme for administration pages (Administer -> Site configuration -> Administration theme). By default this only applies to pages with a path starting with 'admin' and content editing pages.
+Drupal allows you to define a different theme for administration pages
+(Administer -> Site configuration -> Administration theme).
+By default this only applies to pages with a path starting with 'admin'
+and content editing pages.
-The Administration theme module adds a few more option to the default configuration page like :
+The Administration theme module adds a few more option to
+the default configuration page like :
- Use administration theme for batch processing
- Use administration theme for code reviews
- ...
-Some of these pages will only appear if they apply to your installation, i.e. you have the module installed which generates these pages.
+Some of these pages will only appear if they apply to your installation,
+i.e. you have the module installed which generates these pages.
-You also have the option to define a custom set of Drupal paths or aliases to apply the administration theme for.
+You also have the option to define a custom set of Drupal paths
+or aliases to apply the administration theme for.
Requirements
@@ -41,12 +46,19 @@ Administration theme can be configured at :
Developers
----------
-You can add define extra pages where the administration theme should be applied to by implementing the hook_admin_theme_info and hook_admin_theme_check hooks in your modules.
-The first one gets all "options" and the second one checks if each of those options should should be applied to a path. Check out admin_theme_admin_theme_info and admin-theme_admin_theme_check for an example implementation.
+You can add define extra pages where the administration theme
+should be applied to by implementing the hook_admin_theme_info
+and hook_admin_theme_check hooks in your modules.
+The first one gets all "options" and the second one checks
+if each of those options should should be applied to a path.
+Check out admin_theme_admin_theme_info and admin-theme_admin_theme_check
+for an example implementation.
-Author
+Authors
------
Davy Van Den Bremt
-http://www.davyvandenbremt.be
\ No newline at end of file
+http://www.davyvandenbremt.be
+
+Joozer Tohfafarosh
\ No newline at end of file
diff --git a/sites/all/modules/contrib/admin/admin_theme/admin_theme.api.php b/sites/all/modules/contrib/admin/admin_theme/admin_theme.api.php
index 12d1280..f209a4f 100644
--- a/sites/all/modules/contrib/admin/admin_theme/admin_theme.api.php
+++ b/sites/all/modules/contrib/admin/admin_theme/admin_theme.api.php
@@ -1,23 +1,17 @@
l(t('Administer > Appearance > Administration theme'), 'admin/appearance'));
@@ -16,13 +16,14 @@ function admin_theme_install() {
* Implementation of hook_uninstall().
*/
function admin_theme_uninstall() {
- // cleaning up general admin theme variables
+ // Cleaning up general admin theme variables.
variable_del('admin_theme_path');
variable_del('admin_theme_path_disallow');
-
- // cleaning up module defined admin theme variables
-
- // we need to add admin theme's explicitly because it's not in the list of modules anymore
+
+ // Cleaning up module defined admin theme variables.
+ // We need to add admin theme's explicitly,
+ // because it's not in the list of modules anymore.
+ drupal_load('module', 'admin_theme');
$admin_theme_options = admin_theme_admin_theme_info();
$options = array();
foreach ($admin_theme_options as $option => $info) {
@@ -30,14 +31,14 @@ function admin_theme_uninstall() {
$info['module'] = 'admin_theme';
$options[] = $info;
}
-
- // mergin admin theme's options with other module options
- // @fixme does this work if other modules are also uninstalled at the same time?
+
+ // Merging admin theme's options with other module options.
+ // @fixme Does this work if other modules are also uninstalled simultaneously?
$list = array_merge(admin_theme_list(), $options);
-
- // deleting the module defined variables
+
+ // Deleting the module defined variables.
foreach ($list as $info) {
$var = admin_theme_variable_name($info['module'], $info['option']);
variable_del($var);
}
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/admin/admin_theme/admin_theme.module b/sites/all/modules/contrib/admin/admin_theme/admin_theme.module
index 3991ed5..051c36b 100644
--- a/sites/all/modules/contrib/admin/admin_theme/admin_theme.module
+++ b/sites/all/modules/contrib/admin/admin_theme/admin_theme.module
@@ -1,13 +1,13 @@
0) {
+ if ($module_options && count($module_options) > 0) {
foreach ($module_options as $option => $info) {
$info['option'] = $option;
$info['module'] = $module;
@@ -54,23 +55,23 @@ function admin_theme_list() {
}
/**
- * Implementation of hook_form_alter().
+ * Implements hook_form_alter().
*/
function admin_theme_form_system_themes_admin_form_alter(&$form, $form_state) {
- // define a fieldset for the page selection
+ // Define a fieldset for the page selection.
$form['admin_theme']['pages'] = array(
'#type' => 'fieldset',
'#title' => t('Pages'),
'#collapsible' => TRUE,
- '#description' => t('Choose which pages should be displayed with the administration theme.')
+ '#description' => t('Choose which pages should be displayed with the administration theme.'),
);
-
- // add the content editing option to the pages fieldset and change the title
+
+ // Add the content editing option to the pages fieldset and change the title.
$form['admin_theme']['pages']['node_admin_theme'] = $form['admin_theme']['node_admin_theme'];
$form['admin_theme']['pages']['node_admin_theme']['#title'] = t('Content editing');
unset($form['admin_theme']['node_admin_theme']);
- // add all options as checkboxes to the admin theme settings form
+ // Add all options as checkboxes to the admin theme settings form.
$list = admin_theme_list();
foreach ($list as $info) {
$var = admin_theme_variable_name($info['module'], $info['option']);
@@ -82,7 +83,8 @@ function admin_theme_form_system_themes_admin_form_alter(&$form, $form_state) {
);
}
- // allow the user to define a set of pages where the admin theme should or should not be applied to
+ // Allow the user to define a set of pages where the admin theme should,
+ // or should not be applied to.
$form['admin_theme']['pages']['custom'] = array(
'#type' => 'fieldset',
'#title' => t('Custom'),
@@ -112,7 +114,7 @@ function admin_theme_form_system_themes_admin_form_alter(&$form, $form_state) {
* Process system_themes_form additions submissions.
*/
function admin_theme_form_system_themes_form_alter_submit($form, &$form_state) {
- // module options
+ // Module options.
$list = admin_theme_list();
foreach ($list as $info) {
$var = admin_theme_variable_name($info['module'], $info['option']);
@@ -121,36 +123,37 @@ function admin_theme_form_system_themes_form_alter_submit($form, &$form_state) {
}
}
- // custom page options
+ // Custom page options.
variable_set('admin_theme_path', $form_state['values']['admin_theme_path']);
variable_set('admin_theme_path_disallow', $form_state['values']['admin_theme_path_disallow']);
}
/**
- * Implementation of hook_custom_theme().
+ * Implements hook_custom_theme().
*/
function admin_theme_custom_theme() {
$admin_theme_disallow = FALSE;
$admin_theme = FALSE;
- // check if some paths are disallow to get the theme
+ // Check if some paths are disallow to get the theme.
if (trim(variable_get('admin_theme_path_disallow', '')) != '') {
- // pages that are defined by their normal path
+ // Pages that are defined by their normal path.
$admin_theme_disallow = drupal_match_path($_GET['q'], variable_get('admin_theme_path_disallow', ''));
- // pages that are defined with their alias
+ // Pages that are defined with their alias.
$alias = drupal_get_path_alias($_GET['q']);
if ($alias != $_GET['q']) {
$admin_theme_disallow = $admin_theme || drupal_match_path($alias, variable_get('admin_theme_path_disallow', ''));
}
}
- // we should not show the admin theme if the user has no access or the path is in the disallow list
+ // We should not show the admin theme if the user has no access,
+ // or the path is in the disallow list.
if (!user_access('access admin theme') || $admin_theme_disallow) {
return;
}
- // check if an option is enabled and if it results to TRUE
+ // Check if an option is enabled and if it results to TRUE.
$list = admin_theme_list();
foreach ($list as $info) {
$var = admin_theme_variable_name($info['module'], $info['option']);
@@ -159,12 +162,12 @@ function admin_theme_custom_theme() {
}
}
- // some custom defined pages should get admin theme
+ // Some custom defined pages should get admin theme.
if (trim(variable_get('admin_theme_path', '')) != '') {
- // pages that are defined by their normal path
+ // Pages that are defined by their normal path.
$admin_theme = $admin_theme || drupal_match_path($_GET['q'], variable_get('admin_theme_path', ''));
-
- // pages that are defined with their alias
+
+ // Pages that are defined with their alias.
$alias = drupal_get_path_alias($_GET['q']);
if ($alias != $_GET['q']) {
$admin_theme = $admin_theme || drupal_match_path($alias, variable_get('admin_theme_path', ''));
@@ -179,14 +182,14 @@ function admin_theme_custom_theme() {
}
/**
- * Implementation of hook_admin_theme_info().
+ * Implements hook_admin_theme_info().
*/
function admin_theme_admin_theme_info() {
$options = array();
$options['batch'] = array(
'title' => t('Batch processing'),
'description' => t('Use the administration theme when executing batch operations.'),
- );
+ );
if (module_exists('img_assist')) {
$options['img_assist'] = array(
'title' => t('Image assist'),
@@ -227,23 +230,29 @@ function admin_theme_admin_theme_info() {
}
/**
- * Implementation of hook_admin_theme_check().
+ * Implements hook_admin_theme_check().
*/
function admin_theme_admin_theme_check($option = NULL) {
switch ($option) {
case 'img_assist':
return arg(0) == 'img_assist';
+
case 'coder':
return arg(0) == 'coder';
+
case 'devel':
return arg(0) == 'devel' || (arg(0) == 'node' && arg(2) == 'devel');
+
case 'batch':
return arg(0) == 'batch';
+
case 'service_attachments':
return arg(0) == 'node' && arg(2) == 'service_attachments';
+
case 'webform_results':
return arg(0) == 'node' && arg(2) == 'webform-results';
+
case 'statistics':
return (arg(0) == 'node' || arg(0) == 'user') && arg(2) == 'track';
}
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/admin/admin_theme/translations/admin_theme.pot b/sites/all/modules/contrib/admin/admin_theme/translations/admin_theme.pot
deleted file mode 100644
index ff3f8ad..0000000
--- a/sites/all/modules/contrib/admin/admin_theme/translations/admin_theme.pot
+++ /dev/null
@@ -1,122 +0,0 @@
-# $Id: admin_theme.pot,v 1.1.4.2 2008/12/15 16:08:50 davyvandenbremt Exp $
-#
-# LANGUAGE translation of Drupal (general)
-# Copyright YEAR NAME
-# Generated from files:
-# admin_theme.module,v 1.1.2.9 2008/12/13 09:17:01 davyvandenbremt
-# admin_theme.install,v 1.1.2.2 2008/12/08 18:37:44 davyvandenbremt
-# admin_theme.info,v 1.1 2008/11/14 21:34:23 davyvandenbremt
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"POT-Creation-Date: 2008-12-15 16:59+0100\n"
-"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
-"Last-Translator: NAME \n"
-"Language-Team: LANGUAGE \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
-
-#: admin_theme.module:61
-msgid "Theme"
-msgstr ""
-
-#: admin_theme.module:74
-msgid "Pages"
-msgstr ""
-
-#: admin_theme.module:76
-msgid "Choose which pages should be displayed with the administration theme."
-msgstr ""
-
-#: admin_theme.module:81
-msgid "Content editing"
-msgstr ""
-
-#: admin_theme.module:99
-msgid "Custom"
-msgstr ""
-
-#: admin_theme.module:100
-msgid "Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page."
-msgstr ""
-
-#: admin_theme.module:107
-msgid "Use administration theme on the following pages."
-msgstr ""
-
-#: admin_theme.module:112
-msgid "Do not use administration theme on the following pages."
-msgstr ""
-
-#: admin_theme.module:113
-msgid "If a path appears here, the administration theme is not shown even if all above options apply."
-msgstr ""
-
-#: admin_theme.module:186
-msgid "Batch processing"
-msgstr ""
-
-#: admin_theme.module:187
-msgid "Use the administration theme when executing batch operations."
-msgstr ""
-
-#: admin_theme.module:191
-msgid "Code reviews"
-msgstr ""
-
-#: admin_theme.module:192
-msgid "Use the administration theme when viewing Coder code reviews."
-msgstr ""
-
-#: admin_theme.module:197
-msgid "Service attachments form on nodes."
-msgstr ""
-
-#: admin_theme.module:198
-msgid "Use the administration theme when viewing service attachments on nodes."
-msgstr ""
-
-#: admin_theme.module:203
-msgid "Webform submissions."
-msgstr ""
-
-#: admin_theme.module:204
-msgid "Use the administration theme when viewing webform submissions."
-msgstr ""
-
-#: admin_theme.module:209
-msgid "Pages defined by the statistics module."
-msgstr ""
-
-#: admin_theme.module:210
-msgid "Use the administration theme when viewing pages of the statistics module."
-msgstr ""
-
-#: admin_theme.module:13
-msgid "access admin theme"
-msgstr ""
-
-#: admin_theme.module:0
-msgid "admin_theme"
-msgstr ""
-
-#: admin_theme.install:8
-msgid "Administer > Site configuration > Administration theme"
-msgstr ""
-
-#: admin_theme.install:9
-msgid "Administration theme module settings are available under !link"
-msgstr ""
-
-#: admin_theme.info:0
-msgid "Administration theme"
-msgstr ""
-
-#: admin_theme.info:0
-msgid "Enable the administration theme on more pages then possible with Drupal's default administration page."
-msgstr ""
-
diff --git a/sites/all/modules/contrib/admin/admin_theme/translations/nl.po b/sites/all/modules/contrib/admin/admin_theme/translations/nl.po
deleted file mode 100644
index 0ee3aae..0000000
--- a/sites/all/modules/contrib/admin/admin_theme/translations/nl.po
+++ /dev/null
@@ -1,122 +0,0 @@
-# $Id: nl.po,v 1.2.2.2.4.1 2008/12/15 16:08:50 davyvandenbremt Exp $
-#
-# Dutch translation of Drupal (general)
-# Copyright YEAR NAME
-# Generated from files:
-# admin_theme.module,v 1.1.2.9 2008/12/13 09:17:01 davyvandenbremt
-# admin_theme.install,v 1.1.2.2 2008/12/08 18:37:44 davyvandenbremt
-# admin_theme.info,v 1.1 2008/11/14 21:34:23 davyvandenbremt
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: Administration Theme\n"
-"POT-Creation-Date: 2008-11-29 10:18+0100\n"
-"PO-Revision-Date: 2008-11-29 10:27+0100\n"
-"Last-Translator: Davy Van Den Bremt \n"
-"Language-Team: Davy Van Den Bremt \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Poedit-Language: Dutch\n"
-
-#: admin_theme.module:61
-msgid "Theme"
-msgstr "Template"
-
-#: admin_theme.module:74
-msgid "Pages"
-msgstr "Pagina's"
-
-#: admin_theme.module:76
-msgid "Choose which pages should be displayed with the administration theme."
-msgstr "Kies welke pagina's met de beheertemplate getoond moeten worden."
-
-#: admin_theme.module:81
-msgid "Content editing"
-msgstr "Bewerken van inhoud"
-
-#: admin_theme.module:99
-msgid "Custom"
-msgstr "Specifiek"
-
-#: admin_theme.module:100
-msgid "Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page."
-msgstr "Geef één pagina per regel op, als Drupal-paden. Het '*'-teken is een jokerteken. Voorbeeldpaden zijn '%blog' voor de blog-pagina en '%blog-wildcard' voor elke persoonlijke blog. '%front' is de voorpagina."
-
-#: admin_theme.module:107
-msgid "Use administration theme on the following pages."
-msgstr "Gebruik de beheertemplate voor de volgende pagina's."
-
-#: admin_theme.module:112
-msgid "Do not use administration theme on the following pages."
-msgstr "Gebruik de beheertemplate niet voor de volgende pagina's."
-
-#: admin_theme.module:113
-msgid "If a path appears here, the administration theme is not shown even if all above options apply."
-msgstr "Wanneer een pad hier vermeld wordt, word de beheertemplate niet getoond, zelfs als bovenstaande opties van toepassing zijn."
-
-#: admin_theme.module:186
-msgid "Batch processing"
-msgstr "Batch verwerking"
-
-#: admin_theme.module:187
-msgid "Use the administration theme when executing batch operations."
-msgstr "Gebruik de beheertemplate tijdens het verwerken van batch handelingen."
-
-#: admin_theme.module:191
-msgid "Code reviews"
-msgstr "Code revisies"
-
-#: admin_theme.module:192
-msgid "Use the administration theme when viewing Coder code reviews."
-msgstr "Gebruik de beheertemplate tijdens het bekijken van Coder's code revisies."
-
-#: admin_theme.module:197
-msgid "Service attachments form on nodes."
-msgstr "Service attachments formulier bij nodes."
-
-#: admin_theme.module:198
-msgid "Use the administration theme when viewing service attachments on nodes."
-msgstr "Gebruik de beheertemplate tijdens het bekijken van het service attachments formulier bij nodes."
-
-#: admin_theme.module:203
-msgid "Webform submissions."
-msgstr "Webformulier inzendingen."
-
-#: admin_theme.module:204
-msgid "Use the administration theme when viewing webform submissions."
-msgstr "Gebruik de beheertemplate tijdens het bekijken van webformulier inzendingen."
-
-#: admin_theme.module:209
-msgid "Pages defined by the statistics module."
-msgstr "Pagina's van de statistics module"
-
-#: admin_theme.module:210
-msgid "Use the administration theme when viewing pages of the statistics module."
-msgstr "Gebruik de beheertemplate tijdens het bekijken van pagina's van de statistics module."
-
-#: admin_theme.module:13
-msgid "access admin theme"
-msgstr "toegang tot beheertemplate"
-
-#: admin_theme.module:0
-msgid "admin_theme"
-msgstr "admin_theme"
-
-#: admin_theme.install:8
-msgid "Administer > Site configuration > Administration theme"
-msgstr "Beheren > Site-instellingen > Beheertemplate"
-
-#: admin_theme.install:9
-msgid "Administration theme module settings are available under !link"
-msgstr "Instellingen voor de Administration theme module zijn beschikbaar onder !link"
-
-#: admin_theme.info:0
-msgid "Administration theme"
-msgstr "Beheertemplate"
-
-#: admin_theme.info:0
-msgid "Enable the administration theme on more pages then possible with Drupal's default administration page."
-msgstr "Gebruik de beheertemplate op meer pagina's dan instelbaar met Drupal's standaard beheer pagina."
-
diff --git a/sites/all/modules/contrib/admin/backup_migrate/CHANGELOG.txt b/sites/all/modules/contrib/admin/backup_migrate/CHANGELOG.txt
new file mode 100644
index 0000000..0bf88c7
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/CHANGELOG.txt
@@ -0,0 +1,310 @@
+Backup and Migrate 7.x-3.9, 2020-07-15
+--------------------------------------
+#3158379 by DamienMcKenna, monnerat: Fixed compatibility with PHP 5.4.
+
+
+Backup and Migrate 7.x-3.8, 2020-07-10
+--------------------------------------
+#3119038 by solideogloria, gisle: Spelling typo in update scripts.
+#3143362 by DamienMcKenna, solideogloria: Undefined variable $machine_name in
+ install file.
+#3143250 by DamienMcKenna: Use utf8mb4 for MySQL files.
+#3154166 by DamienMcKenna: Remove use of backup_migrate_include() entirely.
+#3129399 by solideogloria, DamienMcKenna: Missing ctools_export_form parameter.
+#3158378 by DamienMcKenna, ron_s: Adjust default performance settings.
+#3158379 by DamienMcKenna: Coding standards improvements.
+
+
+Backup and Migrate 7.x-3.7, 2020-02-28
+--------------------------------------
+#3032453 by DamienMcKenna: Ignore Advanced Aggregator CSS & JS directories.
+#3026187 by DamienMcKenna: Configurations don't load correctly when upgrading
+ from 7.x-2.x to 3.x, clear caches.
+#2606586 by Darren Oh, dmargetts, joelpittet, DamienMcKenna, solideogloria: Fix
+ smart delete not saving files for all periods.
+#3026186 by DamienMcKenna: Menus not rebuilt after upgrading from 7.x-2.x.
+#2507495 by brankoc, DamienMcKenna, nicorac, lorisbel, crantok, jakeru,
+ NickWilde, DD 85, rothlive, Oleg Ko, mgstables, szczesuil, Web.Pergamonteam,
+ Lemontonix, Tranko, aotus, knalstaaf, drugan, lesliewagner1165, Pascal.s,
+ HansKuiters, mato, lgough, Frosty29, sdowney2002, dhalbert, toomanypets, ckng,
+ havanablackcu1, myDrupal2014_846824658246, felixmf: Warning: mail(): Multiple
+ or malformed newlines found in additional_header in mime_mail->send().
+#2135813 by RickJ, rlhawk: Support for the Encrypt module.
+#3033583 by BrankoC: Add CTools as a test dependency.
+#2946311 by DamienMcKenna, k.elizabeth, couturier, jackalope, nelslynn,
+ rrirower, bmango, Cyberflyer, sharonknieper: Too many connections in
+ backup_migrate_source_db->_get_db_connection().
+#3023804 by DamienMcKenna, solideogloria, adam1, jazzitup, MaxMendez, jprj,
+ Louis Delacretaz, eloiv, oliverpolden, drupal_jon, mato, VirtualMitra: Error:
+ Call to undefined function _backup_migrate_temp_files_delete().
+#2663066 by BrankoC, DamienMcKenna, bsains, izmeez: Profile Filter field -
+ hitting 64Kb limit.
+#3023414 by BrankoC, DamienMcKenna, wylbur: Provide settings page for the hidden
+ variables.
+#1042672 by fietserwin, BrankoC: hook_help: do not translate texts if not
+ necessary.
+#3060997 by solideogloria, BrankoC: Improve Performance of Schedule Calculation.
+#3064783 by BrankoC, DamienMcKenna: Uninstalling this module leaves variable
+ backup_migrate_schedule_last_run_* intact.
+#3051821 by DamienMcKenna, BrankoC, solideogloria, wylbur: Remove NodeSquirrel
+ integration.
+#3033583 by BrankoC, DamienMcKenna, m.stenta, RickJ, wylbur: CTools exportables
+ code no longer loading.
+#2507495 by BrankoC, DamienMcKenna: Update script to disable destinations
+ affected by the email delivery change.
+#3046235 by joelpittet: Slow query 'show table status' on menu rebuild.
+#3102427 by izmeez: Readme.txt minor typo and formatting fixes.
+#3102506 by DamienMcKenna, BrankoC: Verify destinations work before listing them
+ in the Quick Backup form; save the file system form before beginning backup
+ tests to ensure the private file system is configured correctly.
+#3102218 by DamienMcKenna, BrankoC, jacob.embree, izmeez, devad, joelpittet,
+ fietserwin, wylbur: Update 7310 Disable e-mail destinations. Emits syntax
+ error for MySQL and MariaDB.
+#3027709 by BrankoC, DamienMcKenna, ultrabob: "A non-numeric value encountered"
+ in backup_migrate_to_bytes().
+#3116733 by DamienMcKenna, fietserwin: PDOException: SQLSTATE[42S02]: Base table
+ or view not found: 1146 Table 'variable' doesn't exist.
+#2885094 by pdcarto, avergara, couturier: CLI option dumps the ENTIRE database,
+ ignores 'nodata_tables' setting.
+
+
+Backup and Migrate 7.x-3.6, 2018-12-15
+--------------------------------------
+#2293601 by KimNyholm, fastturtle: Errors shown because directory handles are
+ not closed when no longer needed.
+#2937023 by DamienMcKenna: Add a test for the basic UI functionality.
+#2945704 by DamienMcKenna: Write tests for each backup filename option.
+#2939277 by DamienMcKenna, baronmunchowsen: File mode change on
+ sources.archivesource.inc.
+#2935403 by DamienMcKenna, jacob.embree: Improve coding standards compliance.
+#2962822 by laryn: Spelling mistake: "frequecy".
+#2917959 by DamienMcKenna: Updated backup_migrate_update_7305() to fix schema
+ problems.
+#2996191 by mwnciau, DamienMcKenna: Special characters in database password
+ causes PHP notifications.
+#2949211 by gturnbull, DamienMcKenna, Alex Bukach, Eli.Stone, joelpittet:
+ Optional memory limit setting to work around out-of-memory errors during
+ backups.
+#2494757 by pbuyle, DamienMcKenna, Ives, Calystod: Allow running a scheduled
+ backup with Drush.
+#2404113 by DamienMcKenna, John Cook, danharper, salmino: Different host for
+ AWS type server.
+#2829492 by axel.rutz, RickJ, DamienMcKenna, devad, Kris77, pietrocap,
+ couturier: Big file backup breaks with "MySQL server has gone away".
+#3001702 by DamienMcKenna: Code cleanup on 7.x-3.x branch.
+#2831470 by snehal.addweb, bfodeke, jigish.addweb: Delete query in
+ hook_uninstall() can potentially remove unintended variables.
+#3004759 by Manthan.addweb, echoz: Notice: Undefined index: exclude_filepaths...
+ visiting Advanced Backup tab.
+#3013355 by jacob.embree: Syntax error in backup_migrate.js.
+#2415421 by ron_s, coredumperror, blake.thompson, John Bickar: Backup and
+ Migrate module and private file system.
+#3002975 by DamienMcKenna: Improve logging around the cron and backup processes.
+#2747197 by RickJ: Network errors writing to Nodesquirrel handled badly.
+#3014594 by DamienMcKenna: backup_migrate_uninstall() doesn't delete all.
+ variables; renamed "backup_migrate_backup_memory_limit" variable to
+ "backup_migrate_memory_limit".
+#3014601 by DamienMcKenna: Re-enable all tests.
+#3014143 by DamienMcKenna: Add master switch to turn off hook_cron.
+#3014603 by DamienMcKenna: Add a CHANGELOG.txt file.
+#3014596 by DamienMcKenna: Require PHP 5.4.
+#2943719 by DamienMcKenna: Reduce memory usage during MySQL database generation.
+#2338841 by catch, dasha_v, DamienMcKenna: Incorrect translated string +
+ menu_rebuild() performance issue.
+#1104012 by DamienMcKenna, axel.rutz, EmanueleQuinto, gisle, jacob.embree, Pere
+ Orga, frenkx: On restore, provide option to drop all tables.
+#2891272 by DamienMcKenna, webservant316: phpsnif 7.1 says Method name
+ \backup_migrate_destination_nodesquirrel::__xmlrpc\" is discouraged; PHP has
+ reserved all method names with a double underscore prefix for future use.
+#3014597 by DamienMcKenna: Document the advanced backup options.
+#2382541 by sano, DamienMcKenna, couturier, dman, modulist: Updated
+ instructions for installing the S3 library.
+#3016278 by DamienMcKenna: Some debug messages aren't hidden behind
+ backup_migrate_verbose.
+#3016282 by DamienMcKenna: "Cannot add field
+ backup_migrate_profiles.machine_name: field already exists" error.
+#3017042 by DamienMcKenna, freelylw, gisle: Settings form field dependency
+ broken.
+#3018002 by DamienMcKenna: Improve the module's documentation.
+By DamienMcKenna: "server" not "sever" :-)
+#3018853 by RickJ: Temporary files not deleted.
+#2735337 by RickJ: Settings objects only offer Revert, not Delete.
+
+
+Backup and Migrate 7.x-3.5, 2018-02-05
+--------------------------------------
+#2941981 by DamienMcKenna, Rick J, camhoward: Backup files being overwritten
+ because of a change to the append_timestamp setting.
+#2940451 by Darren Oh: Unlimited max_execution_time treated as 0 seconds.
+
+
+Backup and Migrate 7.x-3.4, 2018-01-24
+--------------------------------------
+By DamienMcKenna, pere-orga, ikit-claw, cashwilliams: Make all permissions
+ restricted.
+#1058820 by kbasarab, sobi3ch, gbirch, avatxus: Add option to overwrite file.
+#2498191 by DamienMcKenna: Unable to backup to NodeSquirrel using PHP 5.6.9
+ (on Windows) due to changes in SSL validation rules.
+#2742855 by hanoii: Caching profile objects led to unwanted behaviors because of
+ stale data.
+#2703351 by DamienMcKenna, ultrabob: Redundant methods in
+ backup_migrate_location_remote.
+#2728345 by Rick J: Nodesquirrel destination class doesn't return its name.
+#2728331 by Rick J: Incorrect paging count in saved backup list.
+#2498179 by junaidpv: Use drupal_mail() for system notifications.
+#2920311 by DamienMcKenna: Check backup directory permissions / web
+ accessibility.
+#2912459 by DamienMcKenna: Add an initial test.
+#2880434 by DamienMcKenna, benqwerty: Minor changes to drush help output.
+#2914644 by DamienMcKenna, jacob.embree: List all files which contain classes in
+ the info file so other modules can use the classes.
+#2663928 by DamienMcKenna, fietserwin: public://languages should also be
+ excluded by default.
+#2388347 by DamienMcKenna: Nodequirrel destination class doesn't define $errno,
+ $errstr but assumes they're available.
+#2899586 by juankvillegas, DamienMcKenna: Ensure the page variable is numeric in
+ backup_migrate_nodesquirrel_status_form().
+
+
+Backup and Migrate 7.x-3.3, 2017-10-18
+--------------------------------------
+#2290707 by DamienMcKenna, mitsuroseba, Darren Oh: Exclude the data from the
+ following tables - does not work.
+#2830554 by axel.rutz: Support Ultimate Cron.
+#2728349 by Rick J: Disabled schedules still run under Elysia cron.
+
+
+Backup and Migrate 7.x-3.2, 2017-09-27
+--------------------------------------
+#2702229 by DamienMcKenna: Automatically add all cache tables to the 'nodata'
+ list, exclude simpletest tables.
+#2618516 by rocketeerbkw: Fatal error when restoring "Entire Site".
+#2839264 by wizonesolutions: Error: [] operator not supported for strings in
+ backup_migrate_crud_ui_list_all().
+#2633304 by adamelleston: 'clone' is a reserved keyword introduced in PHP
+ version 5.0 and cannot be invoked as a function.
+#2547065 by snehi: Description for filesource location is inaccurate.
+#2672478 by serverofworld, lklimek: Wrong destination when running multiple
+ schedules using the same profile.
+#1542274 by dale42, LGLC, AjitS: Restore fails with foreign key constraint error
+ (due to incorrect comment detection).
+#2623598 by SylvainM, joelstein: Deprecated: Methods with the same name as their
+ class will not be constructors in a future version of PHP.
+#2513720 by rrfegade: Code Spell errors.
+By ronan: Cleaned up use of manage url generator.
+#2495681 by DamienMcKenna: Secure all endpoint connections to NodeSquirrel
+ destination service.
+#2495677 by DamienMcKenna: Inconsistent use of https for manage.nodesquirrel.com
+ hostname.
+#2277383 by hswong3i: Fix schema mismatch after upgrade 7.x-3.x.
+
+
+Backup and Migrate 7.x-3.1, 2015-05-11
+--------------------------------------
+By ronan: Added pantheon notice and free notice to NodeSquirrel page.
+#2347637: Add a Note to Backup doesn't work with Jquery > 1.7.
+By ronan: Set Nodesquirrel schedule to use smart delete by default.
+#2477503: Error returned, but exit status is 0.
+#2369461: Scheduled Backups stopped working after 7.x-3.0?.
+#2390057: Site doesn't come out of maintenance mode when backing up entire site.
+#2455265: Update Version Number in README.TXT.
+By ronan: Updated NS messaging slightly.
+#2393615: Compression not running (only when backing up entire site).
+#2324949: Update #7303 Failing.
+#2421183: Stream URI - Not ignored (Recognized?) during backups.
+#2378739: "Exclude the data from the following tables" not respected when "Use
+ cli commands" is checked.
+#2307655 Fixed adding of full system path to site archive.
+#2290707 by marvoey Advanced Backup link on quick backup page goes to wrong
+ place.
+#2290707 Exclude the data from the following tables - does not work.
+By ronan: Moved run time check before scheduled backup attempt to fix too-
+ frequent schedule issue.
+#2280743: Files restore duplicating directory structure
+ (sites/default/files/sites/default/files).
+#2276663 Permissions - Access backup files.
+#2283701 by alarcombe. Restore not possible from archive.
+#2286835 by Fernando Vesga. Advanced backup page link error.
+#2287157 by topsitemakers. Links to "Create new destination" and "Create new
+ schedule" are invalid.
+#2287239 by topsitemakers. Minor typo in an error message.
+#2278865 by topsitemakers Undefined index: files in
+ theme_backup_migrate_file_list.
+
+
+Backup and Migrate 7.x-3.0, 2014-05-27
+--------------------------------------
+By ronan: Fixed comment on install hook.
+#2266381 Warning: Invalid argument supplied for foreach() in
+ backup_migrate_schedules_cron() on line 48.
+#1001654 Fixed ctools exportables.
+By ronan: Added nodesquirrel scheduling back. Fixed issue with restore from
+ previous radios. Added function to retrieve the most recent backup from the
+ given destination. This may be used in a drush command.
+By ronan: Removed link to help text when help module is off.
+By ronan: Removed confusing 'Quick Schedule' tab.
+#2225335 Drush commands not working.
+By ronan: Increased machine_name length in ui for compatibility with migrated
+ items.
+By ronan: Fixed a couple of php errors.
+By ronan: Minor wording tweaks.
+By ronan: Added better status for NodeSquirrel.
+By ronan: Removed dpm.
+By ronan: Added dependency to offline message on restore.
+By ronan: Removed stray console.log from the js.
+By ronan: Added most recent saved backups to the restore tab.
+By ronan: Ported MySQL views support.
+By ronan: Fixed some issues saving profiles.
+By ronan: Added a @TODO to remind me to fix saving on the advance backup page.
+#1974740 allow backup of codebase & files to skip unreadable files.
+By ronan: Merge branch 'refs/heads/NodeSquirrel-Language' into 7.x-3.x.
+By ronan: Fixed up some language and links to NodeSquirrel.
+By ronan: Cleaned up directory handling to support more directory structures.
+By ronan: Added some description language for NodeSquirrel.
+#2166813 Files backup fails when PEAR is not installed.
+#2155381 by JulienD Remove useless files[] directive from .info files.
+#1947206 by Les Lim. "No data" tables are exported even when they're in the
+ "Exclude the following tables altogether" list.
+#2031393 A debugging function call left behind.
+#2031777 Wrong function signature on form callback.
+#2065573 wrong default file token.
+#2039951 settings page gone for schedules.
+#2009392 Settings don't save for file or entire site sources.
+#1998788 missing i in NodeSquirrel.
+By ronan: Moved NodeSquirrel tab to match the 2.x branch.
+By ronan: Some d7 style cleanup.
+By ronan: Fixed nodesquirrel destination with new id structure.
+By ronan: Added checkplain to description on listing.
+By ronan: Fixed an issue with multiselect js invading other pages.
+#1564408 Gzip backups are compressed twice when downloaded.
+#1991686 thx morningtime. Undefined property: backup_migrate_schedule::$last_run
+By ronan: Switch to hourly default to align with smart delete default.
+#839254 Switched to using drupal_reapath to allow for stream wrapper schemas.
+#839254 Checking absolute paths within the docroot.
+#839254 check for access restriction ignores custom destination path.
+#1503202 Suhosin refuses sending mail because of to many new lines in mail
+ header (possible attacker).
+#1529174 Fatal Error when database name is longer than 21 characters.
+By ronan: Fixed 'Restore again' link.
+#1974720 error message on attempting to restore manual backup.
+#1974744 warning on creation of new settings profile.
+By ronan: Fixed inconsistent use of 'source' and 'destination'.
+By ronan: Changed destination_id to machine_name to fix issue with default file
+ destinations.
+By ronan: Fixed error noise caused by ftp not connecting.
+By ronan: Fixed error on file delete form.
+By ronan: Fixed fatal error in metadata util when a backup fails.
+#1968210 error message on attempting backup of entire site.
+By ronan: Improved error reporting when a non-existant file (such as a broken
+ symlink) cannot be backed up.
+#1968196 Error message on install in php 5.4.
+By ronan: Fixed checkboxes.
+By ronan: Fixed fatal error with token replace.
+By ronan: Created full upgrade path from 2.x. Fixed source settings.
+By ronan: Fixed db scheme issue. Fixed file source realpath issue.
+By ronan: Switched type to subtype for ctools compatibility.
+By ronan: Added machine_name js and ctools exportables.
+By ronan: Fixed source specific settings in backup.
+By ronan: Fixed issue with edit screen for source settings in profiles.
+By ronan: Fixed export.
+By ronan: Cleaned up more fatal errors. Better handling of translatable titles.
diff --git a/sites/all/modules/contrib/admin/backup_migrate/README.txt b/sites/all/modules/contrib/admin/backup_migrate/README.txt
index 7ecc15d..f908f37 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/README.txt
+++ b/sites/all/modules/contrib/admin/backup_migrate/README.txt
@@ -1,94 +1,216 @@
+Backup and Migrate
+------------------
+This module makes the task of backing up a site's Drupal database, code and
+all uploaded files and of migrating data from one Drupal install to another
+easier.
+Database backup files are a list of SQL statements which can be executed with a
+tool such as phpMyAdmin or the command-line mysql client. File and code backup
+files are tarballs which can be restored by extracting them to the desired
+directory.
+
+
+Installation
-------------------------------------------------------------------------------
-Backup and Migrate 2 for Drupal 7.x
- by Ronan Dowling, Gorton Studios - ronan (at) gortonstudios (dot) com
--------------------------------------------------------------------------------
-
-DESCRIPTION:
-This module makes the task of backing up your Drupal database and migrating data
-from one Drupal install to another easier. It provides a function to backup the
-entire database to file or download, and to restore from a previous backup. You
-can also schedule the backup operation. Compression of backup files is also
-supported.
-
-There are options to exclude the data from certain tables (such as cache or
-search index tables) to increase efficiency by ignoring data that does not need
-to be backed up or migrated.
-
-The backup files are a list of SQL statements which can be executed with a tool
-such as phpMyAdmin or the command-line mysql client.
-
--------------------------------------------------------------------------------
-
-INSTALLATION:
-* Put the module in your Drupal modules directory and enable it in
- admin/modules.
-* Go to admin/people/permissions and grant permission to any roles that need to be
- able to backup or restore the database.
-* Configure and use the module at admin/config/system/backup_migrate
+* Put the module in the Drupal modules directory and enable it via
+ admin/modules.
+* Go to admin/people/permissions and grant permission to any roles that need to
+ be able to backup or restore the database.
+* Configure and use the module at admin/config/system/backup_migrate.
OPTIONAL:
+* To drop all tables before import, expand "Advanced options" panel under the
+ "Restore" and "Saved backups" tabs and tick the option.
* Enable token.module to allow token replacement in backup file names.
* To Backup to Amazon S3:
- - Download the S3 library from http://undesigned.org.za/2007/10/22/amazon-s3-php-class
- and place the file 'S3.php' in the includes directory in this module.
- The stable version (0.4.0 – 20th Jul 2009) works best with Backup and Migrate.
+ - Download the most recent version from:
+ https://github.com/tpyo/amazon-s3-php-class
+ - Or clone it with command:
+ git clone https://github.com/tpyo/amazon-s3-php-class.git s3-php5-curl
+ - Rename the unzipped folder to s3-php5-curl
-LIGHTTPD USERS:
-Add the following code to your lighttp.conf to secure your backup directories:
+The most recent version of the library known to work is 0.5.1.
+
+
+Advanced settings
+-------------------------------------------------------------------------------
+Several advanced options are available from the Advanced Settings page:
+* admin/config/system/backup_migrate/settings-advanced
+
+These settings should be handled with care, it is recommended to leave them at
+their defaults unless there is a specific need to modify them.
+
+
+Additional requirements for LigHTTPd
+-------------------------------------------------------------------------------
+Add the following code to the lighttp.conf to secure the backup directories:
$HTTP["url"] =~ "^/sites/default/files/backup_migrate/" {
- url.access-deny = ( "" )
+ url.access-deny = ( "" )
}
-You may need to adjust the path to reflect the actual path to the files.
+It may be necessary to adjust the path to reflect the actual path to the files.
-IIS 7 USERS:
-Add the following code to your web.config code to secure your backup directories:
+
+Additional requirements for IIS 7
+-------------------------------------------------------------------------------
+Add the following code to the web.config code to secure the backup
+directories:
-You may need to adjust the path to reflect the actual path to the files.
+It may also be necessary to adjust the path to reflect the actual path to the
+files.
+
+VERY IMPORTANT SECURITY NOTE
-------------------------------------------------------------------------------
-
-VERY IMPORTANT SECURITY NOTE:
-Backup files may contain sensitive data and by default, are saved to your web
+Backup files may contain sensitive data and, by default, are saved to the web
server in a directory normally accessible by the public. This could lead to a
very serious security vulnerability. Backup and Migrate attempts to protect
backup files using a .htaccess file, but this is not guaranteed to work on all
-environments (and is guaranteed to fail on web servers that are not apache). You
-should test to see if your backup files are publicly accessible, and if in doubt
-do not save backups to the server, or use the destinations feature to save to a
-folder outside of your webroot.
+environments (and is guaranteed to fail on web servers that are not Apache). It
+is imperative to test to see if the site's backup files are publicly
+accessible, and if in doubt do not save backups to the server, or use the
+destinations feature to save to a folder outside of the site's webroot.
-OTHER WARNINGS:
-A failed restore can destroy your database and therefore your entire Drupal
+
+Other warnings
+-------------------------------------------------------------------------------
+A failed restore can destroy the database and therefore the entire Drupal
installation. ALWAYS TEST BACKUP FILES ON A TEST ENVIRONMENT FIRST. If in doubt
do not use this module.
-This module has only been tested with MySQL and does not work with any other dbms.
-If you have experiences with Postgres or any other dbms and are willing to help
-test and modify the module to work with it, please contact the developer at
-ronan (at) gortonstudios (dot) com.
+This module has only been tested with MySQL and does not work with any other
+dbms. Assistance in adding support for other database systems would be
+appreciated, see the issue queue for further details.
-Make sure your php timeout is set high enough to complete a backup or restore
+Make sure the PHP timeout is set high enough to complete a backup or restore
operation. Larger databases require more time. Also, while the module attempts
to keep memory needs to a minimum, a backup or restore will require
-significantly more memory then most Drupal operations.
+significantly more memory than most Drupal operations.
-If your backup file contains the 'sessions' table all other users will be logged
-out after you run a restore. To avoid this, exclude the sessions table when
-creating your backups. Be aware though that you will need to recreate the
-sessions table if you use this backup on an empty database.
+If the backup file contains the 'sessions' table all other users will be logged
+out after running a restore. To avoid this, exclude the sessions table when
+creating the backups. Be aware though that this table is still required to run
+Drupal, so it will need to be recreated if the backup is restored onto an empty
+database.
Do not change the file extension of backup files or the restore function will be
-unable to determine the compression type the file and will not function
+unable to determine the compression type of the file and will not function
correctly.
-IF A RESTORE FAILS:
-Don't panic, the restore file should work with phpMyAdmin's import function, or
-with the mysql command line tool. If it does not, then it is likely corrupt; you
-may panic now. MAKE SURE THAT THIS MODULE IS NOT YOUR ONLY FORM OF BACKUP.
+The module's permissions should only be given to trusted users due to the
+inherent security vulnerabilities in allowing people access to a site's database
+and/or files backups.
+
+If a restore fails
-------------------------------------------------------------------------------
+Don't panic!
+The restore file should still work with phpMyAdmin's import function or with
+the mysql command line tool.
+
+If the backup does not restore using either a graphical tool or the command line
+tools, then it is likely corrupt; you may panic now.
+
+MAKE SURE THAT THIS MODULE IS NOT THE ONLY FORM OF BACKUP.
+
+
+Known problems and workarounds
+-------------------------------------------------------------------------------
+* If backups fail due to an out-of-memory, try adjusting the memory limit using
+ the "backup_migrate_memory_limit" variable by adding one of these lines
+ to the site's settings.php file:
+
+ // Backup & Migrate: Use 512MB when generating backups.
+ $conf['backup_migrate_memory_limit'] = '512M';
+
+ // Backup & Migrate: Use 1GB when generating backups.
+ $conf['backup_migrate_memory_limit'] = '1G';
+
+* If backups fail due to a PHP timeout error, especially an error saying "MySQL
+ server has gone away", use the "backup_migrate_backup_max_time" variable to
+ adjust the timeout. Before doing this, check to see what PHP's
+ "max_execution_time" is set to, then set the "backup_migrate_backup_max_time"
+ variable to a higher number, e.g. if max_execution_time is 180 (seconds) try
+ setting backup_migrate_backup_max_time to 240 seconds / 4 minutes, or 300
+ seconds / 5 minutes
+
+ // Backup & Migrate: Adjust the PHP timeout to 5 minutes / 300 seconds.
+ $conf['backup_migrate_backup_max_time'] = 300;
+
+* A variable has been added which may help with problems. Setting the variable
+ 'backup_migrate_verbose' to TRUE will make the module log additional messages
+ to watchdog as the module performs certain actions.
+
+ // Backup & Migrate: Log extra messages as the module is working.
+ $conf['backup_migrate_verbose'] = TRUE;
+
+* It can be frustrating working from a production database backup on non-prod
+ servers as schduled backups will automatically run via cron the same as they
+ run on production. The custom cron tasks may be disabled using the
+ "backup_migrate_disable_cron" variable. Note: this doesn't prevent people
+ from manually running backups via the UI or from the Drush commands, so it is
+ safe to hardcode to TRUE on all site instances and then hardcode to FALSE on
+ production environments.
+
+ // Backup & Migrate: Don't run backups via cron.
+ $conf['backup_migrate_disable_cron'] = TRUE;
+
+* There are three different variables that control how MySQL data is processed.
+ Should a site have problems with memory limits, it is worth testing these to
+ see which ones work the best.
+
+ - backup_migrate_data_rows_per_query
+ Controls how many records are loaded from the database at once. Defaults to
+ "1000", i.e. 1,000 rows. Note that setting this to a high number can cause
+ problems when exporting large data sets, e.g. cache tables can have huge
+ volumes of data per record.
+
+ // Backup & Migrate: Load 10,000 rows at once.
+ $conf['backup_migrate_data_rows_per_query'] = 10000;
+
+ - backup_migrate_data_rows_per_line
+ Controls how many records are included in a single INSERT statement.
+ Defaults to "30", i.e. 30 records.
+
+ // Backup & Migrate: Combine no more than five records in a single row.
+ $conf['backup_migrate_data_rows_per_line'] = 5;
+
+ - backup_migrate_data_bytes_per_line
+ Controls how much data will be inserted at once using a single INSERT
+ statement. This works with the "backup_migrate_data_rows_per_line" variable
+ to ensure that each INSERT statement doesn't end up being too large.
+ Defaults to "2000", i.e. 2,000 bytes.
+
+ // Backup & Migrate: Limit the output to 1000 bytes at a time.
+ $conf['backup_migrate_data_bytes_per_line'] = 1000;
+
+
+Development notes
+--------------------------------------------------------------------------------
+It is worth noting that some of the tests will fail when ran against nginx,
+which is the default web server for some local development systems. As a result,
+it is recommended to run tests on a server that uses Apache HTTPd Server instead
+of nginx.
+
+
+Credits / contact
+--------------------------------------------------------------------------------
+Currently maintained by Alex Andrascu [1], Damien McKenna [2] and
+Daniel Pickering [3]. All original development up through 2015 was by
+Ronan Dowling [4] with help by Drew Gorton [5].
+
+The best way to contact the authors is to submit an issue, be it a support
+request, a feature request or a bug report, in the project issue queue:
+ https://www.drupal.org/project/issues/backup_migrate
+
+
+References
+--------------------------------------------------------------------------------
+1: https://www.drupal.org/u/alex-andrascu
+2: https://www.drupal.org/u/damienmckenna
+3: https://www.drupal.org/u/ikit-claw
+4: https://www.drupal.org/u/ronan
+5: https://www.drupal.org/u/dgorton
diff --git a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.advanced_settings.inc b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.advanced_settings.inc
new file mode 100644
index 0000000..8bf6b56
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.advanced_settings.inc
@@ -0,0 +1,188 @@
+ t('These settings should be handled with care, it is recommended to leave them at their defaults unless there is a specific need to modify them.'),
+ '#prefix' => '
',
+ '#suffix' => '
',
+ );
+ $form['backup_migrate_memory_limit'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Memory Limit'),
+ '#default_value' => variable_get('backup_migrate_memory_limit', BACKUP_MIGRATE_MEMORY_LIMIT),
+ '#description' => t('If backups fail due to an out-of-memory, try adjusting the memory limit using a php.ini style value, for example 512M for 512 megabytes or 1G for 1 gigabyte. Default: !default.', array('!default' => '' . check_plain(BACKUP_MIGRATE_MEMORY_LIMIT) . '')),
+ '#required' => FALSE,
+ '#element_validate' => array('backup_migrate_memory_limit_validate'),
+ );
+ $form['backup_migrate_backup_max_time'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Time Limit'),
+ '#default_value' => variable_get('backup_migrate_backup_max_time', BACKUP_MIGRATE_BACKUP_MAX_TIME),
+ '#description' => t('If backups fail due to a PHP timeout error, especially an error saying "MySQL server has gone away", increase this setting. Before doing this, check to see what PHP\'s "max_execution_time" is set to, then set this field to a higher number, e.g. if max_execution_time is 180 (seconds) try setting Time Limit to 240 seconds (4 minutes), or 300 seconds (5 minutes). Default: !default.', array('!default' => '' . check_plain(BACKUP_MIGRATE_BACKUP_MAX_TIME) . '')),
+ '#required' => FALSE,
+ '#element_validate' => array('element_validate_integer_positive'),
+ );
+ $form['backup_migrate_verbose'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Verbose Output'),
+ '#default_value' => variable_get('backup_migrate_verbose', BACKUP_MIGRATE_VERBOSE),
+ '#description' => t('Enable this to make the module log additional messages to watchdog as the module performs certain actions. Default: !default.', array('!default' => (BACKUP_MIGRATE_VERBOSE ? 'on' : 'off'))),
+ '#required' => FALSE,
+ );
+ $form['backup_migrate_disable_cron'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Disable Cron'),
+ '#default_value' => variable_get('backup_migrate_disable_cron', BACKUP_MIGRATE_DISABLE_CRON),
+ '#description' => t('It can be frustrating working from a production database backup on non-prod servers as schduled backups will automatically run via cron the same as they run on production. The custom cron tasks may be disabled using this checkbox. Note: this doesn\'t prevent people from manually running backups via the UI or from the Drush commands, so it is safe to enable on all site instances and then disable on production environments. Default: !default.', array('!default' => (BACKUP_MIGRATE_DISABLE_CRON ? 'on' : 'off'))),
+ '#required' => FALSE,
+ );
+ $form['backup_migrate_data_rows_per_query'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Rows Per Query'),
+ '#default_value' => variable_get('backup_migrate_data_rows_per_query', BACKUP_MIGRATE_DATA_ROWS_PER_QUERY),
+ '#description' => t('Controls how many records are loaded from the database at once. Defaults to "!default", i.e. !default rows. Note that setting this to a high number can cause problems when exporting large data sets, e.g. cache tables can have huge volumes of data per record.', array('!default' => '' . check_plain(BACKUP_MIGRATE_DATA_ROWS_PER_QUERY) . '')),
+ '#required' => FALSE,
+ '#element_validate' => array('element_validate_integer_positive'),
+ );
+ $form['backup_migrate_data_rows_per_line'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Rows Per Line'),
+ '#default_value' => variable_get('backup_migrate_data_rows_per_line', BACKUP_MIGRATE_DATA_ROWS_PER_LINE),
+ '#description' => t('Controls how many records are included in a single INSERT statement. Defaults to "!default", i.e. !default records.', array('!default' => '' . check_plain(BACKUP_MIGRATE_DATA_ROWS_PER_LINE) . '')),
+ '#required' => FALSE,
+ '#element_validate' => array('element_validate_integer_positive'),
+ );
+ $form['backup_migrate_data_bytes_per_line'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Data Bytes Per Line'),
+ '#default_value' => variable_get('backup_migrate_data_bytes_per_line', BACKUP_MIGRATE_DATA_BYTES_PER_LINE),
+ '#description' => t('Controls how much data will be inserted at once using a single INSERT statement. This works with the "backup_migrate_data_rows_per_line" variable to ensure that each INSERT statement doesn\'t end up being too large. Defaults to "!default", i.e. !default bytes.', array('!default' => '' . check_plain(BACKUP_MIGRATE_DATA_BYTES_PER_LINE) . '')),
+ '#required' => FALSE,
+ '#element_validate' => array('element_validate_integer_positive'),
+ );
+ $form['backup_migrate_max_email_size'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Maximum E-mail Size'),
+ '#default_value' => variable_get('backup_migrate_max_email_size', BACKUP_MIGRATE_MAX_EMAIL_SIZE),
+ '#description' => t('In bytes. Limits the size of e-mails with attached back-ups that can be sent. Default: !default.', array('!default' => '' . check_plain(BACKUP_MIGRATE_MAX_EMAIL_SIZE) . '')),
+ '#required' => FALSE,
+ '#element_validate' => array('backup_migrate_unsigned_integer_validate'),
+ );
+ $form['backup_migrate_cleanup_temp_files'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Clean up Temporary Files'),
+ '#default_value' => variable_get('backup_migrate_cleanup_temp_files', BACKUP_MIGRATE_CLEANUP_TEMP_FILES),
+ '#description' => t('Should temporary files be deleted during the current back-up run? Default: !default.', array('!default' => (BACKUP_MIGRATE_CLEANUP_TEMP_FILES ? 'on' : 'off'))),
+ '#required' => FALSE,
+ );
+ $form['backup_migrate_cleanup_time'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Clean-up Time'),
+ '#default_value' => variable_get('backup_migrate_cleanup_time', BACKUP_MIGRATE_CLEANUP_TIME),
+ '#description' => t('Delete temporary files belonging to this modules that are older than the expire time. In seconds. 21600 seconds is 6 hours. Default: !default.', array('!default' => '' . check_plain(BACKUP_MIGRATE_CLEANUP_TIME) . '')),
+ '#required' => FALSE,
+ '#element_validate' => array('element_validate_integer'),
+ );
+ $form['backup_migrate_schedule_buffer'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Schedule buffer'),
+ '#default_value' => variable_get('backup_migrate_schedule_buffer', BACKUP_MIGRATE_SCHEDULE_BUFFER),
+ '#description' => t('Add a small negative buffer (for example 1% of the entire period) to the time to account for slight difference in cron run length. Format: percentage of the period as a decimal fraction between 0 and 1. Default: !default.', array('!default' => '' . check_plain(BACKUP_MIGRATE_SCHEDULE_BUFFER) . '')),
+ '#required' => FALSE,
+ '#element_validate' => array('backup_migrate_fraction_validate'),
+ );
+
+ // Check for overrides and report them to the user.
+ $keys = array_keys($form);
+ $query = db_query('SELECT name, value FROM {variable} WHERE name IN (:keys)', array(':keys' => $keys));
+ $result = $query->fetchAllKeyed();
+ foreach ($form as $key => $field) {
+ if (isset($result[$key])) {
+ // Compare the value with what we have in the database.
+ $db_value = unserialize($result[$key]);
+ if ($field['#default_value'] != $db_value) {
+ $form[$key]['#description'] .= ' Overridden in settings.php: ' . check_plain($field['#default_value']) . '.';
+ }
+ }
+ }
+
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save configuration'),
+ );
+
+ return $form;
+}
+
+/**
+ * The advanced settings form.
+ */
+function backup_migrate_ui_advanced_settings_form_submit($form, &$form_state) {
+ $variables = array(
+ 'backup_migrate_backup_max_time' => BACKUP_MIGRATE_BACKUP_MAX_TIME,
+ 'backup_migrate_cleanup_temp_files' => BACKUP_MIGRATE_CLEANUP_TEMP_FILES,
+ 'backup_migrate_cleanup_time' => BACKUP_MIGRATE_CLEANUP_TIME,
+ 'backup_migrate_data_bytes_per_line' => BACKUP_MIGRATE_DATA_BYTES_PER_LINE,
+ 'backup_migrate_data_rows_per_line' => BACKUP_MIGRATE_DATA_ROWS_PER_LINE,
+ 'backup_migrate_data_rows_per_query' => BACKUP_MIGRATE_DATA_ROWS_PER_QUERY,
+ 'backup_migrate_disable_cron' => BACKUP_MIGRATE_DISABLE_CRON,
+ 'backup_migrate_max_email_size' => BACKUP_MIGRATE_MAX_EMAIL_SIZE,
+ 'backup_migrate_memory_limit' => BACKUP_MIGRATE_MEMORY_LIMIT,
+ 'backup_migrate_schedule_buffer' => BACKUP_MIGRATE_SCHEDULE_BUFFER,
+ 'backup_migrate_verbose' => BACKUP_MIGRATE_VERBOSE,
+ );
+ foreach ($variables as $var_name => $var_default) {
+ if (isset($form_state['values'][$var_name])) {
+ // There's no need to save the variable if it's just the default.
+ if ($form_state['values'][$var_name] == $var_default) {
+ variable_del($var_name);
+ }
+ // The variable is not the default, so save it.
+ else {
+ variable_set($var_name, $form_state['values'][$var_name]);
+ }
+ }
+ }
+}
+
+/**
+ * Validate fields that require a PHP.ini-like memory_limit value.
+ */
+function backup_migrate_memory_limit_validate($element, &$form_state, $form) {
+ if (!_backup_migrate_is_valid_memory_limit($element['#value'])) {
+ form_error($element, t('%name must be a valid memory limit setting.', array('%name' => $element['#title'])));
+ }
+}
+
+/**
+ * Validate fields that require zero or a positive integer.
+ */
+function backup_migrate_unsigned_integer_validate($element, &$form_state, $form) {
+ $value = $element['#value'];
+ $test = preg_match('/^[0-9]+$/', $value);
+ if ($test !== 1) {
+ form_error($element, t('%name must be zero or a positive integer.', array('%name' => $element['#title'])));
+ }
+}
+
+/**
+ * Validate fields that require a decimal between 0 and 1.
+ *
+ * @todo Better name.
+ */
+function backup_migrate_fraction_validate($element, &$form_state, $form) {
+ $value = $element['#value'];
+ $test = preg_match('/^(0|1|0?\.[0-9]+)$/', $value);
+ if ($test !== 1) {
+ form_error($element, t('%name must be a decimal between 0 and 1.', array('%name' => $element['#title'])));
+ }
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.css b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.css
index 27250bc..46c5795 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.css
+++ b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.css
@@ -1,5 +1,10 @@
+/**
+ * @file
+ * Custom CSS for the Backup Migrate module.
+ */
+
.schedule-list-disabled {
- filter:alpha(opacity=50);
+ filter: alpha(opacity=50);
-moz-opacity: .50;
opacity: .50;
}
@@ -8,7 +13,7 @@
font-size: 0.85em;
}
-.backup-migrate-tables-checkboxes .form-item label {
+.backup-migrate-tables-checkboxes .form-item {
width: 15em;
float: left;
overflow: hidden;
@@ -16,24 +21,50 @@
height: 1.75em;
margin: .25em .25em 0 0;
}
-.backup-migrate-tables-checkboxes .form-item label.checked {
- background-color: #eee;
-}
.backup-migrate-tables-checkboxes .form-item label input {
- margin-right: .25em;
+ margin-right: .5em;
}
div.backup-migrate-tables-checkboxes {
- max-height: 40em;
+ height: 20em;
overflow: auto;
}
-div.backup-migrate-description {
+div.backup-migrate-tags,
+div.backup-migrate-description,
+div.backup-migrate-date {
font-size: smaller;
}
-
+span.backup-migrate-label {
+ font-weight: bold;
+}
+table.backup-migrate-listing td {
+ vertical-align: top;
+}
div.row-error {
- color: #FF0000;
+ color: #ff0000;
font-weight: bold;
}
+.backup-migrate-listing {
+ margin-bottom: 2em;
+}
+.backup-migrate-actions {
+ text-align: right;
+}
+
+html.js #backup-migrate-ui-manual-quick-backup-form fieldset.collapsed,
+.backup-migrate-inline {
+ margin-bottom: 1em;
+}
+
+.backup-migrate-form-dependent {
+ padding-left: 2em;
+ padding-bottom: 1em;
+}
+.backup-migrate-form-dependent .form-item {
+ margin-top: 0;
+}
+.backup-migrate-footer-message {
+ margin-bottom: 1em;
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.info b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.info
index 02c716f..a7d0183 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.info
+++ b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.info
@@ -1,17 +1,52 @@
name = Backup and Migrate
-description = "Backup or migrate the Drupal Database quickly and without unnecessary data."
+description = "Backup the Drupal database and files or migrate them to another environment."
core = 7.x
+configure = admin/config/system/backup_migrate
-files[] = backup_migrate.module
-files[] = backup_migrate.install
+; Require PHP 5.4 so that some slightly more advanced PHP logic can be used.
+; This is for future usage; removing this will allow the module to continue
+; working fine for now.
+php = 5.4
+
+; All of the class files used within the module.
+files[] = includes/crud.inc
files[] = includes/destinations.inc
+files[] = includes/destinations.browser.inc
+files[] = includes/destinations.db.inc
+files[] = includes/destinations.db.mysql.inc
+files[] = includes/destinations.email.inc
+files[] = includes/destinations.file.inc
+files[] = includes/destinations.ftp.inc
+files[] = includes/destinations.s3.inc
+files[] = includes/files.inc
+files[] = includes/filters.inc
+files[] = includes/filters.backup_restore.inc
+files[] = includes/filters.compression.inc
+files[] = includes/filters.encryption.inc
+files[] = includes/filters.statusnotify.inc
+files[] = includes/filters.utils.inc
+files[] = includes/locations.inc
files[] = includes/profiles.inc
files[] = includes/schedules.inc
+files[] = includes/sources.inc
+files[] = includes/sources.archivesource.inc
+files[] = includes/sources.db.inc
+files[] = includes/sources.db.mysql.inc
+files[] = includes/sources.filesource.inc
-configure = admin/config/system/backup_migrate
-; Information added by drupal.org packaging script on 2013-04-10
-version = "7.x-2.5"
+; Test dependencies.
+test_dependencies[] = ctools
+
+; Test suite.
+files[] = tests/BmTestBase.test
+files[] = tests/BmTestBasics.test
+files[] = tests/BmTestProfiles.test
+files[] = tests/BmTestEmail.test
+files[] = tests/BmTestCtools.test
+files[] = tests/BmTestUpdate7310.test
+
+; Information added by Drupal.org packaging script on 2020-07-15
+version = "7.x-3.9"
core = "7.x"
project = "backup_migrate"
-datestamp = "1365564017"
-
+datestamp = "1594807678"
diff --git a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.install b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.install
index 0e5647b..0d550fc 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.install
+++ b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.install
@@ -1,29 +1,171 @@
$destination) {
+ if (method_exists($destination, 'get_display_location')) {
+ $dest_path = $destination->get_display_location();
+ if (!empty($dest_path) && file_valid_uri($dest_path)) {
+ $scheme = file_uri_scheme($dest_path);
+ // Support public and private storage and raw server paths.
+ if ($scheme === 'private' || $scheme === 'public' || substr($dest_path, 0, 1) == '/') {
+ // Check if the path exists.
+ $path_exists = file_prepare_directory($dest_path, FILE_CREATE_DIRECTORY);
+ if ($path_exists) {
+ $real_path = drupal_realpath($dest_path);
+ // See if the private path is somewhere inside the main Drupal
+ // directory structure.
+ if (strpos($real_path, DRUPAL_ROOT) === 0) {
+ // Extract the relative path from the Drupal root path, and
+ // then add the base URL, theoretically creating a fully
+ // qualified URL to the storage directory.
+ $url = substr($real_path, strlen(DRUPAL_ROOT) + 1);
+ $url = url($url, array('absolute' => TRUE));
+ $result = drupal_http_request($url);
+
+ // If the HTTP request comes back as a status 200 that means
+ // there is a directory listing of some sort; directory paths
+ // should return a 503 error.
+ if (!empty($result->code) && $result->code == 200) {
+ // Get the human readable information for this destination.
+ $dest_spec = $destination->get_list_row();
+
+ // Display a warning message.
+ $requirements['bmdest_' . $dest_name] = array(
+ 'severity' => REQUIREMENT_ERROR,
+ 'title' => 'Backup Migrate',
+ 'value' => $t('Backup destination "%dest" is publicly accessible!', array('%dest' => $dest_spec['name'])),
+ 'description' => $t('The backup destination, "%dest", stores its files in the "%path" directory. This directory is publicly available from the web server and urgently needs to be secured! Please see the Drupal manual on configuring the private directory path on how to fix this problem.',
+ array(
+ '%dest' => $dest_spec['name'],
+ '%path' => $real_path,
+ '@manual' => 'https://www.drupal.org/docs/7/core/modules/file/overview',
+ )),
+ );
+ }
+
+ // Check an individual file.
+ else {
+ $files = scandir($real_path);
+ if (!empty($files)) {
+ foreach ($files as $file) {
+ // Skip the base field pointers.
+ if ($file == '.' || $file == '..') {
+ continue;
+ }
+
+ $result = drupal_http_request($url . '/' . $file);
+
+ // If the HTTP request comes back as a status 200 that
+ // means the file is accessible.
+ if (!empty($result->code) && $result->code == 200) {
+ // Get the human readable information for this
+ // destination.
+ $dest_spec = $destination->get_list_row();
+
+ // Display a warning message.
+ $requirements['bmdest_' . $dest_name] = array(
+ 'severity' => REQUIREMENT_ERROR,
+ 'title' => 'Backup Migrate',
+ 'value' => $t('Files in "%dest" are publicly accessible!', array('%dest' => $dest_spec['name'])),
+ 'description' => $t('The backup destination, "%dest", stores its files in the "%path" directory. These file(s) are publicly available from the web server and urgently need to be secured! Please see the Drupal manual on configuring the private directory path on how to fix this problem.',
+ array(
+ '%dest' => $dest_spec['name'],
+ '%path' => $real_path,
+ '@manual' => 'https://www.drupal.org/docs/7/core/modules/file/overview',
+ )),
+ );
+ }
+
+ // Only need to check one file.
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ // Leave a note if there were no problems.
+ // @todo No point in displaying this until the API has been expanded.
+ // @code
+ // if (empty($requirements)) {
+ // $requirements['bmdest_' . $dest_name] = array(
+ // 'severity' => REQUIREMENT_INFO,
+ // 'title' => 'Backup Migrate',
+ // 'value' => $t('Backup destinations are safe'),
+ // 'description' => $t('The backup destinations were all checked and none of them were exposing files to the public. This is a good thing.'),
+ // );
+ // }
+ // @endcode
+
+ if (variable_get('backup_migrate_disable_cron', FALSE)) {
+ $requirements['bm_disable_cron'] = array(
+ 'severity' => REQUIREMENT_INFO,
+ 'title' => 'Backup Migrate',
+ 'value' => $t('Cron tasks are disabled'),
+ 'description' => $t('The cron tasks have been disabled, so scheduled backups will not run. See the Backup & Migrate module\'s README.txt file for further details.'),
+ );
+ }
+ }
+
return $requirements;
}
/**
- * Implementation of hook_schema().
+ * Implements hook_schema().
*/
function backup_migrate_schema() {
$schema['backup_migrate_profiles'] = array(
+ 'export' => array(
+ 'key' => 'machine_name',
+ 'key name' => 'Profile ID',
+ 'admin_title' => 'name',
+ 'primary key' => 'profile_id',
+ // Exports will be defined as $preset.
+ 'identifier' => 'item',
+ // Function hook name.
+ 'default hook' => 'exportables_backup_migrate_profiles',
+ 'api' => array(
+ 'owner' => 'backup_migrate',
+ // Base name for api include files.
+ 'api' => 'backup_migrate_exportables',
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
'fields' => array(
'profile_id' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ // Do not export database-only keys.
+ 'no export' => TRUE,
+ ),
+ 'machine_name' => array(
'type' => 'varchar',
- 'length' => 32,
+ 'length' => 255,
'not null' => TRUE,
'default' => '0',
'description' => 'The primary identifier for a profile.',
@@ -32,13 +174,13 @@ function backup_migrate_schema() {
'description' => 'The name of the profile.',
'type' => 'varchar',
'length' => 255,
- 'not null' => TRUE
+ 'not null' => TRUE,
),
'filename' => array(
'description' => 'The name of the profile.',
'type' => 'varchar',
'length' => 255,
- 'not null' => TRUE
+ 'not null' => TRUE,
),
'append_timestamp' => array(
'description' => 'Append a timestamp to the filename.',
@@ -46,17 +188,18 @@ function backup_migrate_schema() {
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
- 'default' => 0
+ 'default' => 0,
),
'timestamp_format' => array(
'description' => 'The format of the timestamp.',
'type' => 'varchar',
'length' => 14,
- 'not null' => TRUE
+ 'not null' => TRUE,
),
'filters' => array(
'description' => 'The filter settings for the profile.',
'type' => 'text',
+ 'size' => 'medium',
'not null' => TRUE,
'serialize' => TRUE,
'serialized default' => 'a:0:{}',
@@ -65,11 +208,159 @@ function backup_migrate_schema() {
'primary key' => array('profile_id'),
);
$schema['backup_migrate_destinations'] = array(
+ 'export' => array(
+ 'key' => 'machine_name',
+ 'key name' => 'Destination ID',
+ 'admin_title' => 'name',
+ 'primary key' => 'destination_id',
+ // Exports will be defined as $preset.
+ 'identifier' => 'item',
+ // Function hook name.
+ 'default hook' => 'exportables_backup_migrate_destinations',
+ 'api' => array(
+ 'owner' => 'backup_migrate',
+ // Base name for api include files.
+ 'api' => 'backup_migrate_exportables',
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
'fields' => array(
'destination_id' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ // Do not export database-only keys.
+ 'no export' => TRUE,
+ ),
+ 'machine_name' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'The primary identifier for a destination.',
+ ),
+ 'name' => array(
+ 'description' => 'The name of the destination.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ ),
+ 'subtype' => array(
+ 'description' => 'The type of the destination.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
+ ),
+ 'location' => array(
+ 'description' => 'The the location string of the destination.',
+ 'type' => 'text',
+ 'not null' => TRUE,
+ ),
+ 'settings' => array(
+ 'description' => 'Other settings for the destination.',
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'serialize' => TRUE,
+ 'serialized default' => 'a:0:{}',
+ ),
+ ),
+ 'primary key' => array('destination_id'),
+ );
+ $schema['backup_migrate_sources'] = array(
+ 'export' => array(
+ 'key' => 'machine_name',
+ 'key name' => 'Source ID',
+ 'admin_title' => 'name',
+ 'primary key' => 'source_id',
+ // Exports will be defined as $preset.
+ 'identifier' => 'item',
+ // Function hook name.
+ 'default hook' => 'exportables_backup_migrate_sources',
+ 'api' => array(
+ 'owner' => 'backup_migrate',
+ // Base name for api include files.
+ 'api' => 'backup_migrate_exportables',
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
+ 'fields' => array(
+ 'source_id' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ // Do not export database-only keys.
+ 'no export' => TRUE,
+ ),
+ 'machine_name' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'The primary identifier for a source.',
+ ),
+ 'name' => array(
+ 'description' => 'The name of the source.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ ),
+ 'subtype' => array(
+ 'description' => 'The type of the source.',
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ ),
+ 'location' => array(
+ 'description' => 'The the location string of the source.',
+ 'type' => 'text',
+ 'not null' => TRUE,
+ ),
+ 'settings' => array(
+ 'description' => 'Other settings for the source.',
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'serialize' => TRUE,
+ 'serialized default' => 'a:0:{}',
+ ),
+ ),
+ 'primary key' => array('source_id'),
+ );
+
+ $schema['backup_migrate_schedules'] = array(
+ 'export' => array(
+ 'key' => 'machine_name',
+ 'key name' => 'Source ID',
+ 'admin_title' => 'name',
+ 'primary key' => 'schedule_id',
+ // Exports will be defined as $preset.
+ 'identifier' => 'item',
+ // Function hook name.
+ 'default hook' => 'exportables_backup_migrate_schedules',
+ 'api' => array(
+ 'owner' => 'backup_migrate',
+ // Base name for api include files.
+ 'api' => 'backup_migrate_exportables',
+ 'minimum_version' => 1,
+ 'current_version' => 1,
+ ),
+ ),
+ 'fields' => array(
+ 'schedule_id' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ // Do not export database-only keys.
+ 'no export' => TRUE,
+ ),
+ 'machine_name' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
'default' => '0',
'description' => 'The primary identifier for a profile.',
),
@@ -77,63 +368,34 @@ function backup_migrate_schema() {
'description' => 'The name of the profile.',
'type' => 'varchar',
'length' => 255,
- 'not null' => TRUE
- ),
- 'type' => array(
- 'description' => 'The type of the destination.',
- 'type' => 'varchar',
- 'length' => 32,
- 'not null' => TRUE
- ),
- 'location' => array(
- 'description' => 'The the location string of the destination.',
- 'type' => 'text',
- 'not null' => TRUE
- ),
- 'settings' => array(
- 'description' => 'Other settings for the destination.',
- 'type' => 'text',
'not null' => TRUE,
- 'serialize' => TRUE,
- 'serialized default' => 'a:0:{}',
- ),
- ),
- 'primary key' => array('destination_id'),
- );
- $schema['backup_migrate_schedules'] = array(
- 'fields' => array(
- 'schedule_id' => array(
- 'type' => 'varchar',
- 'length' => 32,
- 'not null' => TRUE,
- 'default' => '0',
- 'description' => 'The primary identifier for a profile.',
- ),
- 'name' => array(
- 'description' => 'The name of the profile.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE
),
'source_id' => array(
'description' => 'The {backup_migrate_destination}.destination_id of the source to backup from.',
'type' => 'varchar',
- 'length' => 32,
+ 'length' => 255,
'default' => 'db',
- 'not null' => TRUE
+ 'not null' => TRUE,
),
'destination_id' => array(
'type' => 'varchar',
- 'length' => 32,
+ 'length' => 255,
'not null' => TRUE,
'default' => '0',
'description' => 'The {backup_migrate_destination}.destination_id of the destination to back up to.',
),
- 'profile_id' => array(
+ 'copy_destination_id' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '0',
+ 'description' => 'A second {backup_migrate_destination}.destination_id of the destination to copy the backup to.',
+ ),
+ 'profile_id' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
'description' => 'The primary identifier for a profile.',
),
'keep' => array(
@@ -154,15 +416,21 @@ function backup_migrate_schema() {
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
- 'default' => 0
+ 'default' => 0,
),
'cron' => array(
'description' => 'Whether the schedule should be run during cron.',
- 'type' => 'int',
- 'size' => 'tiny',
- 'unsigned' => TRUE,
+ 'type' => 'varchar',
+ 'length' => 32,
'not null' => TRUE,
- 'default' => 0
+ 'default' => 'builtin',
+ ),
+ 'cron_schedule' => array(
+ 'description' => 'The cron schedule to run on.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0 4 * * *',
),
),
'primary key' => array('schedule_id'),
@@ -172,58 +440,41 @@ function backup_migrate_schema() {
}
/**
- * Implementation of hook_install().
- */
-function backup_migrate_install() {
- _backup_migrate_setup_database_defaults();
-}
-
-function _backup_migrate_setup_database_defaults() {
- if (variable_get("backup_migrate_file_name", NULL)) {
- require_once DRUPAL_ROOT . '/'. drupal_get_path('module', 'backup_migrate') .'/includes/crud.inc';
- require_once DRUPAL_ROOT . '/'. drupal_get_path('module', 'backup_migrate') .'/backup_migrate.module';
- require_once DRUPAL_ROOT . '/'. drupal_get_path('module', 'backup_migrate') .'/includes/profiles.inc';
- require_once DRUPAL_ROOT . '/'. drupal_get_path('module', 'backup_migrate') .'/includes/files.inc';
-
- $settings = array(
- 'profile_id' => 'default',
- 'filename' => variable_get("backup_migrate_file_name", _backup_migrate_default_filename()),
- 'append_timestamp' => variable_get("backup_migrate_append_timestamp", FALSE) ? 1 : 0,
- 'timestamp_format' => variable_get("backup_migrate_timestamp_format", 'Y-m-d\TH-i-s'),
- 'filters' => array(
- 'compression' => variable_get("backup_migrate_compression", "none"),
- 'exclude_tables' => variable_get("backup_migrate_exclude_tables", array()),
- 'nodata_tables' => variable_get("backup_migrate_nodata_tables", array()),
- ),
- 'name' => t('Default Settings'),
- );
- $profile = backup_migrate_crud_create_item('profile', $settings);
- $profile->save();
- variable_set("backup_migrate_profile_id", 'default');
-
- // Set up the default schedules.
- if (variable_get("backup_migrate_schedule_backup_period", 0)) {
- require_once DRUPAL_ROOT . '/'. drupal_get_path('module', 'backup_migrate') .'/includes/schedules.inc';
- $schedule = array(
- 'name' => t('Default Schedule'),
- 'profile_id' => $profile->get_id(),
- 'enabled' => 1,
- 'destination_id' => 'scheduled',
- 'period' => array('number' => variable_get("backup_migrate_schedule_backup_period", 0), 'type' => 'hours'),
- 'keep' => variable_get("backup_migrate_schedule_backup_keep", 0),
- );
- $schedule = backup_migrate_crud_create_item('schedule', $schedule);
- $schedule->save();
- }
- }
-}
-
-/**
- * Remove variables on uninstall.
+ * Implements hook_uninstall().
*/
function backup_migrate_uninstall() {
- db_query("DELETE FROM {variable} WHERE name LIKE 'backup_migrate_%'");
- cache_clear_all('variables', 'cache');
+ variable_del('backup_migrate_backup_max_time');
+ variable_del('backup_migrate_cleanup_temp_files');
+ variable_del('backup_migrate_cleanup_time');
+ variable_del('backup_migrate_copy_destination_id');
+ variable_del('backup_migrate_data_bytes_per_line');
+ variable_del('backup_migrate_data_rows_per_line');
+ variable_del('backup_migrate_data_rows_per_query');
+ variable_del('backup_migrate_destination_id');
+ variable_del('backup_migrate_disable_cron');
+ variable_del('backup_migrate_max_email_size');
+ variable_del('backup_migrate_memory_limit');
+ variable_del('backup_migrate_profile_id');
+ variable_del('backup_migrate_schedule_buffer');
+ variable_del('backup_migrate_schedule_last_run_');
+ variable_del('backup_migrate_source_id');
+ variable_del('backup_migrate_timeout_buffer');
+ variable_del('backup_migrate_verbose');
+ variable_del('nodesquirrel_endpoint_urls');
+ variable_del('nodesquirrel_schedule');
+ variable_del('nodesquirrel_schedule_enabled');
+ variable_del('nodesquirrel_schedule_source_id');
+ variable_del('nodesquirrel_secret_key');
+
+ // Remove the dynamic generated 'last run' variables.
+ $last_ran_schedules = db_select('variable', 'var')
+ ->fields('var', array('name'))
+ ->condition('name', 'backup\_migrate\_schedule\_last\_run\_%', 'LIKE')
+ ->execute()
+ ->fetchAllAssoc('name', PDO::FETCH_ASSOC);
+ foreach ($last_ran_schedules as $key => $schedule) {
+ variable_del($key);
+ }
}
/**
@@ -235,7 +486,7 @@ function backup_migrate_update_2000() {
}
/**
- * Adding filter field for dev release of 2009-01-28
+ * Adding filter field for dev release of 2009-01-28.
*/
function backup_migrate_update_2001() {
$ret = array();
@@ -243,11 +494,21 @@ function backup_migrate_update_2001() {
// Add the filters field to the db.
if (!db_field_exists('backup_migrate_profiles', 'filters')) {
- db_add_field('backup_migrate_profiles', 'filters', array('description' => t('The filter settings for the profile.'),'type' => 'text', 'not null' => TRUE));
+ db_add_field('backup_migrate_profiles', 'filters', array(
+ 'description' => t('The filter settings for the profile.'),
+ 'type' => 'text',
+ 'not null' => TRUE,
+ ));
}
- // Add the source field
+ // Add the source field.
if (!db_field_exists('backup_migrate_profiles', 'source_id')) {
- db_add_field('backup_migrate_profiles', 'source_id', array('description' => t('The {backup_migrate_destination}.destination_id of the source to backup from.'), 'type' => 'varchar', 'length' => 32, 'default' => 'db', 'not null' => TRUE));
+ db_add_field('backup_migrate_profiles', 'source_id', array(
+ 'description' => t('The {backup_migrate_destination}.destination_id of the source to backup from.'),
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'default' => 'db',
+ 'not null' => TRUE,
+ ));
}
// Remove the compression field.
if (db_field_exists('backup_migrate_profiles', 'compression')) {
@@ -257,7 +518,7 @@ function backup_migrate_update_2001() {
}
/**
- * Clearing the cache because there was a menu structure change in the dev of 2009-05-31
+ * Clear the cache because there was a menu structure change.
*/
function backup_migrate_update_2002() {
// Cache should clear automatically. Nothing to do here.
@@ -265,13 +526,13 @@ function backup_migrate_update_2002() {
}
/**
- * Allowing non-int profile ids in schedules 2009-05-31
+ * Allowing non-int profile ids in schedules 2009-05-31.
*/
function backup_migrate_update_2003() {
$ret = array();
$spec = array(
'type' => 'varchar',
- 'length' => 32,
+ 'length' => 255,
'not null' => TRUE,
'default' => '0',
'description' => 'The primary identifier for a profile.',
@@ -282,13 +543,13 @@ function backup_migrate_update_2003() {
}
/**
- * Allowing non-int profile ids 2009-07-01
+ * Allowing non-int profile ids 2009-07-01.
*/
function backup_migrate_update_2004() {
$ret = array();
$spec = array(
'type' => 'varchar',
- 'length' => 32,
+ 'length' => 255,
'not null' => TRUE,
'default' => '0',
);
@@ -314,16 +575,16 @@ function backup_migrate_update_2004() {
}
/**
- * Change the default database id to something friendlier 2009-08-08
+ * Change the default database id to something friendlier 2009-08-08.
*/
function backup_migrate_update_2005() {
- require_once './'. drupal_get_path('module', 'backup_migrate') .'/includes/crud.inc';
- require_once './'. drupal_get_path('module', 'backup_migrate') .'/includes/profiles.inc';
+ require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/crud.inc';
+ require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/profiles.inc';
$ret = array();
- // Change the destination ids of the defined database sources mostly to make using them with drush friendlier.
-
- // Change the db_url:default id to simply 'db'
+ // Change the destination ids of the defined database sources mostly to make
+ // using them with drush friendlier.
+ // Change the db_url:default id to simply 'db'.
$ret[] = db_query("UPDATE {backup_migrate_profiles} SET source_id = 'db' WHERE source_id = 'db_url:default'");
$ret[] = db_query("UPDATE {backup_migrate_schedules} SET destination_id = 'db' WHERE destination_id = 'db_url:default'");
@@ -331,9 +592,15 @@ function backup_migrate_update_2005() {
$ret[] = db_query("UPDATE {backup_migrate_profiles} SET source_id = REPLACE(source_id, 'db_url:', 'db:')");
$ret[] = db_query("UPDATE {backup_migrate_schedules} SET destination_id = REPLACE(destination_id, 'db_url:', 'db:')");
- // Add the source field to the schedule
+ // Add the source field to the schedule.
if (!db_field_exists('backup_migrate_schedules', 'source_id')) {
- db_add_field('backup_migrate_schedules', 'source_id', array('description' => t('The db source to backup from.'), 'type' => 'varchar', 'length' => 32, 'default' => 'db', 'not null' => TRUE));
+ db_add_field('backup_migrate_schedules', 'source_id', array(
+ 'description' => t('The db source to backup from.'),
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'default' => 'db',
+ 'not null' => TRUE,
+ ));
}
// Copy source data from profiles to schedules.
@@ -342,7 +609,7 @@ function backup_migrate_update_2005() {
if (!$schedule['source_id']) {
$schedule['source_id'] = 'db';
}
- $ret[] = db_query("UPDATE {backup_migrate_schedules} SET source_id = '". $schedule['source_id'] ."' WHERE schedule_id = '". $schedule['profile_id'] ."'");
+ $ret[] = db_query("UPDATE {backup_migrate_schedules} SET source_id = '" . $schedule['source_id'] . "' WHERE schedule_id = '" . $schedule['profile_id'] . "'");
}
if (db_field_exists('backup_migrate_profiles', 'source_id')) {
@@ -382,19 +649,21 @@ function backup_migrate_update_7200() {
}
}
-
/**
* Change the filename field to support 255 characters.
*/
function backup_migrate_update_7202() {
$ret = array();
- db_change_field('backup_migrate_profiles', 'filename', 'filename', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
+ db_change_field('backup_migrate_profiles', 'filename', 'filename', array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ ));
return $ret;
}
-
/**
- * Update the schedule last run times to use variables instead of saving with the schedule.
+ * Schedule last run times to use variables instead of saving with the schedule.
*/
function backup_migrate_update_7203() {
$result = db_query('SELECT * FROM {backup_migrate_schedules}', array(), array('fetch' => PDO::FETCH_ASSOC));
@@ -407,3 +676,393 @@ function backup_migrate_update_7203() {
db_drop_field('backup_migrate_schedules', 'last_run');
}
}
+
+/**
+ * Upgrade from Backup & Migrate 7.x-2.x.
+ *
+ * - Uninstall the Backup Migrate Files module if it's installed.
+ * - Uninstall the NodeSquirrel module if it's installed.
+ * - Upgrade the configurations.
+ */
+function backup_migrate_update_7300() {
+ if (module_exists('backup_migrate_files')) {
+ module_disable(array('backup_migrate_files'));
+ $ret[] = array(
+ 'success' => TRUE,
+ 'query' => 'Disabled the Backup and Migrate Files module',
+ );
+ }
+ if (module_exists('nodesquirrel')) {
+ module_disable(array('nodesquirrel'));
+ $ret[] = array(
+ 'success' => TRUE,
+ 'query' => 'Disabled the NodeSquirrel module',
+ );
+ }
+
+ // Add sources to the schema.
+ $schema['backup_migrate_sources'] = array(
+ 'fields' => array(
+ 'source_id' => array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => t('The primary identifier for a source.'),
+ ),
+ 'name' => array(
+ 'description' => t('The name of the source.'),
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ ),
+ 'type' => array(
+ 'description' => t('The type of the source.'),
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ ),
+ 'location' => array(
+ 'description' => t('The the location string of the source.'),
+ 'type' => 'text',
+ 'not null' => TRUE,
+ ),
+ 'settings' => array(
+ 'description' => t('Other settings for the source.'),
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'serialize' => TRUE,
+ 'serialized default' => 'a:0:{}',
+ ),
+ ),
+ 'primary key' => array('source_id'),
+ );
+
+ if (!db_table_exists('backup_migrate_sources')) {
+ db_create_table('backup_migrate_sources', $schema['backup_migrate_sources']);
+ }
+
+ // Move custom destinations to sources.
+ $result = db_query("SELECT * FROM {backup_migrate_destinations} WHERE type in ('filesource', 'db')", array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $item) {
+ $item['source_id'] = $item['destination_id'];
+ drupal_write_record('backup_migrate_source', $item);
+ }
+
+ // Change 'destination' settings to 'source' settings.
+ $result = db_query('SELECT * FROM {backup_migrate_profiles}', array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $item) {
+ $item['filters'] = unserialize($item['filters']);
+ $item['filters']['sources'] = $item['filters']['destinations'];
+ unset($item['filters']['destinations']);
+ drupal_write_record('backup_migrate_profiles', $item, array('profile_id'));
+ }
+
+ // Clear the plugins caches.
+ cache_clear_all('*', 'cache', TRUE);
+
+ // Rebuild the menus.
+ variable_set('menu_rebuild_needed', TRUE);
+}
+
+/**
+ * Switch the cron switch to text.
+ */
+function backup_migrate_update_7301() {
+ db_change_field('backup_migrate_schedules', 'cron', 'cron', array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => 'builtin',
+ ));
+ db_add_field('backup_migrate_schedules', 'cron_schedule', array(
+ 'description' => 'The cron schedule to run on.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'default' => '0 4 * * *',
+ 'not null' => TRUE,
+ ));
+}
+
+/**
+ * Add a second destination to schedules.
+ */
+function backup_migrate_update_7302() {
+ db_add_field('backup_migrate_schedules', 'copy_destination_id',
+ array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'A second {backup_migrate_destination}.destination_id of the destination to copy the backup to.',
+ )
+ );
+}
+
+/**
+ * Add a serial id field to all tables to allow them to be ctools exportable.
+ */
+function backup_migrate_update_7303() {
+ foreach (array(
+ 'backup_migrate_sources' => 'source_id',
+ 'backup_migrate_destinations' => 'destination_id',
+ 'backup_migrate_schedules' => 'schedule_id',
+ 'backup_migrate_profiles' => 'profile_id',
+ ) as $table => $id) {
+ // Take the primary key status from the machine name so it can be renamed
+ // A serial field must be defined as a key, so make a temporary index.
+ // See: https://www.drupal.org/node/190027
+ db_add_index($table, 'temp', array($id));
+ db_drop_primary_key($table);
+ // Drop our temporary index.
+ db_drop_index($table, 'temp');
+
+ // Switch the name of the id to 'machine_name' to be more ctools standard.
+ db_change_field($table, $id, 'machine_name', array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ ));
+
+ // Add a serial ID.
+ db_add_field($table, $id,
+ array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
+ // Do not export database-only keys.
+ 'no export' => TRUE,
+ ),
+ array('primary key' => array($id))
+ );
+ }
+ foreach (array('backup_migrate_sources', 'backup_migrate_destinations') as $table) {
+ db_change_field($table, 'type', 'subtype', array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ ));
+ }
+}
+
+/**
+ * Update all schedules to use the built in cron if none is specified.
+ */
+function backup_migrate_update_7304() {
+ db_query("UPDATE {backup_migrate_schedules} SET cron = 'builtin' WHERE cron = '0'");
+}
+
+/**
+ * Fix schema mismatch after upgrade.
+ */
+function backup_migrate_update_7305() {
+ // Fix the 'machine_name' table fields.
+ $field_spec = array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '0',
+ );
+ foreach (array(
+ 'backup_migrate_profiles',
+ 'backup_migrate_destinations',
+ 'backup_migrate_sources',
+ 'backup_migrate_schedules',
+ ) as $table) {
+ if (!db_field_exists($table, 'machine_name')) {
+ try {
+ db_add_field($table, 'machine_name', $field_spec);
+ }
+ catch (\Exception $e) {
+ db_change_field($table, 'machine_name', 'machine_name', $field_spec);
+ }
+ }
+ else {
+ db_change_field($table, 'machine_name', 'machine_name', $field_spec);
+ }
+ }
+
+ // Fix the 'cron' table field.
+ $field_spec = array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => 'builtin',
+ );
+ if (!db_field_exists('backup_migrate_schedules', 'cron')) {
+ try {
+ db_add_field('backup_migrate_schedules', 'cron', $field_spec);
+ }
+ catch (\Exception $e) {
+ db_change_field('backup_migrate_schedules', 'cron', 'cron', $field_spec);
+ }
+ }
+ else {
+ db_change_field('backup_migrate_schedules', 'cron', 'cron', $field_spec);
+ }
+}
+
+/**
+ * Leave a message to explain the mixup over the backup option.
+ */
+function backup_migrate_update_7306() {
+ drupal_set_message(t('Please note that release 7.x-3.4 had a bug which caused all backups to be overwritten instead of having a timestamp added. Please review all backup settings to ensure they work as intended.'), 'warning');
+}
+
+/**
+ * - 'backup_migrate_backup_memory_limit' vs 'backup_migrate_memory_limit'.
+ */
+function backup_migrate_update_7307() {
+ $limit = variable_get('backup_migrate_backup_memory_limit');
+ if (!empty($limit)) {
+ variable_set('backup_migrate_memory_limit', $limit);
+ variable_del('backup_migrate_backup_memory_limit');
+ }
+}
+
+/**
+ * Update profiles table filter field to accommodate larger serialized strings.
+ */
+function backup_migrate_update_7308() {
+ db_change_field('backup_migrate_profiles', 'filters', 'filters', array(
+ 'description' => 'The filter settings for the profile.',
+ 'type' => 'text',
+ 'size' => 'medium',
+ 'not null' => TRUE,
+ 'serialize' => TRUE,
+ 'serialized default' => 'a:0:{}',
+ ));
+}
+
+/**
+ * NodeSquirrel support has been removed.
+ */
+function backup_migrate_update_7309() {
+ require_once dirname(__FILE__) . '/includes/destinations.inc';
+ require_once dirname(__FILE__) . '/includes/schedules.inc';
+
+ foreach (backup_migrate_get_schedules() as $schedule) {
+ // Look for backups which use NodeSquirrel as its destination.
+ if ($schedule->destination_id == 'nodesquirrel') {
+ $name = $schedule->name;
+
+ // If this schedule had a second destination, swap the destinations.
+ if (!empty($schedule->copy_destination_id)) {
+ $destination = backup_migrate_get_destination($schedule->copy_destination_id);
+ $schedule->destination_id = $schedule->copy_destination_id;
+ $schedule->copy_destination_id = '';
+ $schedule->name = $destination->name;
+ $schedule->save();
+ drupal_set_message(t('The backup schedule named "%backup" was renamed and now just backups to %destination.', array('%backup' => $name, '%destination' => $destination->name)));
+ }
+
+ // Just delete it.
+ else {
+ $schedule->delete();
+ drupal_set_message(t('The backup schedule named "%backup" as been deleted.', array('%backup' => $name)));
+ }
+ }
+
+ // Backups which used NodeSquirrel as the second destination will have the
+ // second destination disabled.
+ elseif ($schedule->copy_destination_id == 'nodesquirrel') {
+ $schedule->copy_destination_id = '';
+ $schedule->save();
+ drupal_set_message(t('The backup schedule named "%backup" no longer keeps a second backup on NodeSquirrel.', array('%backup' => $schedule->name)));
+ }
+ }
+
+ // Clear the cache so that the NodeSquirrel plugin is no longer loaded.
+ cache_clear_all('*', 'cache', TRUE);
+
+ // Rebuild the menus so that the NodeSquirrel menu item is removed.
+ variable_set('menu_rebuild_needed', TRUE);
+
+ // @todo Remove the configuration later.
+ drupal_set_message(t('NodeSquirrel stopped being usable as a backup destination on October 1st, 2019 and ceased operations entirely on November 1st, 2019. Because of this, the NodeSquirrel functionality has been disabled. Please switch to an alternate destination if necessary. Please note that the NodeSquirrel configuration itself has not been removed.', array('!url' => 'https://pantheon.io/nodesquirrel-service-end-life')));
+}
+
+/**
+ * Disable e-mail destinations.
+ */
+function backup_migrate_update_7310() {
+ $out = '';
+
+ // Disable scheduled e-mail back-ups to allow users to review their
+ // destinations first.
+ //
+ // Which e-mail destinations exist?
+ $destinations = db_select('backup_migrate_destinations', 'bmd')
+ ->fields('bmd', array('machine_name'))
+ ->condition('subtype', 'email', '=')
+ ->execute()
+ ->fetchAllAssoc('machine_name', PDO::FETCH_ASSOC);
+ $destinations = array_keys($destinations);
+
+ if (!empty($destinations)) {
+ // Which schedules contain enabled e-mail destinations?
+ $or = db_or();
+ $or->condition('destination_id', $destinations, 'IN');
+ $or->condition('copy_destination_id', $destinations, 'IN');
+ $schedules_query = db_select('backup_migrate_schedules', 'bms')
+ ->fields('bms', array('schedule_id', 'name'))
+ ->condition($or)
+ ->condition('enabled', 1, '=');
+ $schedules = $schedules_query->execute()->fetchAllAssoc('schedule_id', PDO::FETCH_ASSOC);
+
+ // Disable the relevant schedules.
+ if (count($schedules) > 0) {
+ $email_schedules = array_keys($schedules);
+ $names = array_column($schedules, 'name');
+ $replacements = array('@schedules' => '
' . implode('
', $names) . '
');
+ db_update('backup_migrate_schedules')
+ ->fields(['enabled' => '0'])
+ ->condition('schedule_id', $email_schedules, 'IN')
+ ->execute();
+ $out .= t('Schedules that back up to e-mail destinations have been disabled. Check that you are using the correct e-mail addresses, then re-enable manually. The following schedules have been disabled: @schedules', $replacements);
+ }
+ }
+
+ if (!empty($out)) {
+ return $out;
+ }
+ else {
+ return t('No destinations were affected by this change.');
+ }
+}
+
+/**
+ * Adjust the default performance settings.
+ */
+function backup_migrate_update_7311() {
+ $settings = array(
+ 'backup_migrate_data_rows_per_query' => array(
+ 'old' => 1000,
+ 'new' => 50000,
+ ),
+ 'backup_migrate_data_rows_per_line' => array(
+ 'old' => 30,
+ 'new' => 10,
+ ),
+ 'backup_migrate_data_bytes_per_line' => array(
+ 'old' => 2000,
+ 'new' => 2 * 1024,
+ ),
+ );
+ foreach ($settings as $var_name => $data) {
+ $stored = variable_get($var_name);
+
+ // Nothing was stored in the database.
+ if (empty($stored)) {
+ // Don't do anything, the new default will be picked up automatically.
+ }
+ // The old value was smaller than or equal to the new value, or was the
+ // same as the old default, delete it so that the new default can be picked
+ // up.
+ elseif (intval($stored) <= $data['new'] || $stored == $data['old']) {
+ variable_del($var_name);
+ drupal_set_message(t('!var setting reset to the new default of !val.', array('!var' => $var_name, '!val' => $data['new'])));
+ }
+ }
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.js b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.js
index fa5a498..9d7c171 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.js
+++ b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.js
@@ -1,59 +1,126 @@
+/**
+ * @file
+ * Custom JS for the Backup and Migrate module.
+ */
(function ($) {
-Drupal.backup_migrate = {
- callbackURL : "",
- autoAttach : function() {
- if (Drupal.settings.backup_migrate !== undefined) {
- if ($("#edit-save-settings").length && !$("#edit-save-settings").attr("checked")) {
- // Disable input and hide its description.
- // Set display none instead of using hide(), because hide() doesn't work when parent is hidden.
- $('div.backup-migrate-save-options').css('display', 'none');
- }
-
- $("#edit-save-settings").bind("click", function() {
- if (!$("#edit-save-settings").attr("checked")) {
- $("div.backup-migrate-save-options").slideUp('slow');
- }
- else {
- // Save unchecked; enable input.
- $("div.backup-migrate-save-options").slideDown('slow');
- }
- });
+ 'use strict';
- $('select[multiple]').each(function() {
- $(this).after(
- $('').append(
- $('').text(Drupal.settings.backup_migrate.checkboxLinkText).click(function() {
- Drupal.backup_migrate.selectToCheckboxes($(this).parents('.form-item').find('select'));
+ Drupal.behaviors.backupMigrate = {
+ attach: function (context, settings) {
+ if (Drupal.settings.backup_migrate !== undefined) {
+ if (Drupal.settings.backup_migrate.dependents !== undefined) {
+ var key;
+ for (key in Drupal.settings.backup_migrate.dependents) {
+ info = Drupal.settings.backup_migrate.dependents[key];
+ var dependent = $('#edit-' + info['dependent']);
+ for (key in info['dependencies']) {
+ $('[name="' + key + '"]').each(function () {
+ var dependentval = info['dependencies'][key];
+ var dependency = $(this);
+ (function (dependent, dependency) {
+ var checkval = function (inval) {
+ // Do loose comparisons to support things like "true", "1",
+ // etc.
+ if (dependency.attr('type') === 'radio') {
+ var val = $('[name="' + dependency.attr('name') + '"]:checked').val();
+ return val == inval;
+ }
+ else if (dependency.attr('type') === 'checkbox') {
+ return dependency.is(':checked') && inval == dependency.val();
+ }
+ else {
+ return dependency.val() == inval;
+ }
+ return false;
+ };
+ if (!checkval(dependentval)) {
+ // Hide doesn't work inside collapsed fieldsets.
+ dependent.css('display', 'none');
+ }
+ dependency.bind('load change click keypress focus', function () {
+ if (checkval(dependentval)) {
+ dependent.slideDown();
+ }
+ else {
+ dependent.slideUp();
+ }
+ }).load();
+ })(dependent, dependency);
+ });
+ }
+ }
+ for (key in Drupal.settings.backup_migrate.destination_selectors) {
+ var info = Drupal.settings.backup_migrate.destination_selectors[key];
+ (function (info) {
+ var selector = $('#' + info['destination_selector']);
+ var copy = $('#' + info['copy'])
+ var copy_selector = $('#' + info['copy_destination_selector']);
+ var copy_selector_options = {};
+
+ // Store a copy of the secondary selector options.
+ copy_selector.find('optgroup').each(function () {
+ var label = $(this).attr('label');
+ copy_selector_options[label] = [];
+ $(this).find('option').each(function () {
+ copy_selector_options[label].push(this);
+ });
+ $(this).remove();
})
- )
- );
+
+ // Assign an action to the main selector to modify the secondary
+ // selector.
+ selector.each(function () {
+ $(this).bind('load change click keypress focus', function () {
+ var group = $(this).find('option[value=' + $(this).val() + ']').parents('optgroup').attr('label');
+ if (group) {
+ copy.parent().find('.backup-migrate-destination-copy-label').text(info['labels'][group]);
+ copy_selector.empty();
+ for (var key in copy_selector_options) {
+ if (key != group) {
+ copy_selector.append(copy_selector_options[key]);
+ }
+ }
+ }
+ }).load();
+ });
+ })(info);
+ }
+
+ // Add the convert to checkboxes functionality to all multiselects.
+ $('#backup-migrate-ui-manual-backup-form select[multiple], #backup-migrate-crud-edit-form select[multiple]').each(function () {
+ var self = this;
+ $(self).after(
+ $('').append(
+ $('' + Drupal.settings.backup_migrate.checkboxLinkText + '').click(function () {
+ var $select = $(self);
+ var $checkboxes = $('').addClass('backup-migrate-tables-checkboxes');
+ $('option', $select).each(function (i) {
+ $checkboxes.append(
+ $('').append(
+ $('').prepend(
+ $('')
+ .bind('click change load', function () {
+ if (this.checked) {
+ $(this).parent().addClass('checked');
+ }
+ else {
+ $(this).parent().removeClass('checked');
+ }
+ }).load()
+ )
+ )
+ );
+ });
+ $select.parent().find('.backup-migrate-checkbox-link').remove();
+ $select.before($checkboxes);
+ $select.hide();
+ })
+ )
+ );
+ });
}
- );
+ }
}
- },
-
- selectToCheckboxes : function($select) {
- var field_id = $select.attr('id');
- var $checkboxes = $('').addClass('backup-migrate-tables-checkboxes');
- $('option', $select).each(function(i) {
- var self = this;
- $box = $('').bind('change click', function() {
- $select.find('option[value="'+self.value+'"]').attr('selected', this.checked);
- if (this.checked) {
- $(this).parent().addClass('checked');
- }
- else {
- $(this).parent().removeClass('checked');
- }
- }).attr('checked', this.selected ? 'checked' : '');
- $checkboxes.append($('').append($('').prepend($box)));
- });
- $select.parent().find('.backup-migrate-checkbox-link').remove();
- $select.before($checkboxes);
- $select.hide();
}
-}
-
-$(document).ready(Drupal.backup_migrate.autoAttach);
})(jQuery);
diff --git a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.module b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.module
index 5e10a56..b50ef05 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.module
+++ b/sites/all/modules/contrib/admin/backup_migrate/backup_migrate.module
@@ -1,110 +1,138 @@
- t('Backup and Migrate makes the task of backing up your Drupal database and migrating data from one Drupal install to another easier. It provides a function to backup the entire database to file or download, and to restore from a previous backup. You can also schedule the backup operation. Compression of backup files is also supported. The database backup files created with this module can be imported into this or any other Drupal installation with the !restorelink, or you can use a database tool such as phpMyAdmin or the mysql command line command.',
- array(
- '!restorelink' => user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature'),
- '!phpmyadminurl' => 'http://www.phpmyadmin.net'
- )
- )
- ),
- BACKUP_MIGRATE_MENU_PATH => array(
- 'title' => t('Quick Backup Tab'),
- 'body' => t('Use this form to run simple manual backups of your database. Visit the !helppage for more help using this module',
- array('!helppage' => l(t('help page'), 'admin/help/backup_migrate'))),
- 'access arguments' => array('perform backup'),
- ),
- BACKUP_MIGRATE_MENU_PATH . '/export/advanced' => array(
- 'title' => t('Advanced Backup Tab'),
- 'body' => t('Use this form to run manual backups of your database with more advanced options. If you have any !profilelink saved you can load those settings. You can save any of the changes you make to these settings as a new settings profile.',
- array("!profilelink" => user_access('administer backup and migrate') ? l(t('settings profiles'), BACKUP_MIGRATE_MENU_PATH . '/profile') : t('settings profiles'), '!restorelink' => user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature'), '!phpmyadminurl' => 'http://www.phpmyadmin.net')),
- 'access arguments' => array('perform backup'),
- ),
- BACKUP_MIGRATE_MENU_PATH . '/restore' => array(
- 'title' => t('Restore Tab'),
- 'body' => t('Upload a backup and migrate backup file. The restore function will not work with database dumps from other sources such as phpMyAdmin.'),
- 'access arguments' => array('restore from backup'),
- ),
- BACKUP_MIGRATE_MENU_PATH . '/destination' => array(
- 'title' => t('Destinations'),
- 'body' => t('Destinations are the places you can save your backup files to or them load from.'),
- 'more' => t('Files can be saved to a directory on your web server, downloaded to your desktop or emailed to a specified email account. From the Destinations tab you can create, delete and edit destinations or list the files which have already been backed up to the available destinations.'),
- 'access arguments' => array('administer backup and migrate'),
- ),
- BACKUP_MIGRATE_MENU_PATH . '/profile' => array(
- 'title' => t('Profiles'),
- 'body' => t('Profiles are saved backup settings. Profiles store your table exclusion settings as well as your backup file name, compression and timestamp settings. You can use profiles in !schedulelink and for !manuallink.',
- array('!schedulelink' => user_access('administer backup and migrate') ? l(t('schedules'), BACKUP_MIGRATE_MENU_PATH . '/schedule') : t('settings profiles'), '!manuallink' => user_access('perform backups') ? l(t('manual backups'), BACKUP_MIGRATE_MENU_PATH) : t('manual backups'))),
- 'more' => t('You can create new profiles using the add profiles tab or by checking the "Save these settings" button on the advanced backup page.'),
- 'access arguments' => array('administer backup and migrate'),
- ),
- BACKUP_MIGRATE_MENU_PATH . '/schedule' => array(
- 'title' => t('Scheduling'),
- 'body' => t('Automatically backup up your database on a regular schedule using cron.',
- array('!cronurl' => 'http://drupal.org/cron')),
- 'more' => t('Each schedule will run a maximum of once per cron run, so they will not run more frequently than your cron is configured to run. If you specify a number of backups to keep for a schedule, old backups will be deleted as new ones created. If specifiy a number of files to keep other backup files in that schedule\'s destination will get deleted.'),
- 'access arguments' => array('administer backup and migrate'),
- ),
- );
+ $help = NULL;
+ switch ($section) {
+ case BACKUP_MIGRATE_MENU_PATH:
+ $help = t('Use this form to run simple manual backups of your database and files.');
+ break;
- if (isset($help[$section])) {
- return $help[$section]['body'];
+ case BACKUP_MIGRATE_MENU_PATH . '/export/advanced':
+ $help = t('Use this form to run manual backups of your database and files with more advanced options. If you have any !profilelink saved you can load those settings. You can save any of the changes you make to these settings as a new settings profile.', array(
+ "!profilelink" => user_access('administer backup and migrate') ? l(t('settings profiles'), BACKUP_MIGRATE_MENU_PATH . '/profile') : t('settings profiles'),
+ '!restorelink' => user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature'),
+ '!phpmyadminurl' => 'http://www.phpmyadmin.net',
+ ));
+ break;
+
+ case BACKUP_MIGRATE_MENU_PATH . '/restore':
+ $help = t('Upload a backup and migrate backup file. The restore function will not work with database dumps from other sources such as phpMyAdmin.');
+ break;
+
+ case BACKUP_MIGRATE_MENU_PATH . '/settings/destination':
+ $help = t('Destinations are the places you can save your backup files to or them load from.');
+ break;
+
+ case BACKUP_MIGRATE_MENU_PATH . '/settings/source':
+ $help = t('Sources are the things that can be backed up such as database or file directories.');
+ break;
+
+ case BACKUP_MIGRATE_MENU_PATH . '/settings/profile':
+ $help = t('Profiles are saved backup settings. Profiles store your table exclusion settings as well as your backup file name, compression and timestamp settings. You can use profiles in !schedulelink and for !manuallink.', array(
+ '!schedulelink' => user_access('administer backup and migrate') ? l(t('schedules'), BACKUP_MIGRATE_MENU_PATH . '/schedule') : t('settings profiles'),
+ '!manuallink' => user_access('perform backups') ? l(t('manual backups'), BACKUP_MIGRATE_MENU_PATH) : t('manual backups'),
+ ));
+ break;
+
+ case BACKUP_MIGRATE_MENU_PATH . '/schedule':
+ $help = t('Automatically backup up your database and files on a regular schedule using cron.', array(
+ '!cronurl' => 'http://drupal.org/cron',
+ ));
+ break;
+
+ case BACKUP_MIGRATE_MENU_PATH . '/settings/import':
+ $help = t('Import a settings profile, backup schedule, source or destination by pasting the export code into the textarea.', array(
+ '!cronurl' => 'http://drupal.org/cron',
+ ));
+ break;
+
+ case 'admin/advanced_help':
+ // Help link on module list page (admin/modules/list) or advanced help
+ // module (admin/advanced_help/backup_migrate), use $arg to see if it
+ // is for this module.
+ if ($arg[2] != 'backup_migrate') {
+ break;
+ }
+ // Explicit fall-through.
+ case 'admin/help#backup_migrate':
+ // Assemble help page based on all strings above plus more.
+ $help = t('Backup and Migrate makes the task of backing up your Drupal database and migrating data from one Drupal install to another easier. It provides a function to backup the entire database to file or download, and to restore from a previous backup. You can also schedule the backup operation. Compression of backup files is also supported. The database backup files created with this module can be imported into this or any other Drupal installation with the !restorelink, or you can use a database tool such as phpMyAdmin or the mysql command line command.', array(
+ '!restorelink' => user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature'),
+ '!phpmyadminurl' => 'http://www.phpmyadmin.net',
+ ));
+ $help = '
' . $help . '
';
+ $help .= backup_migrate_help_section(t('Quick Backup Tab'), BACKUP_MIGRATE_MENU_PATH, NULL, array('perform backup'));
+ $help .= backup_migrate_help_section(t('Advanced Backup Tab'), BACKUP_MIGRATE_MENU_PATH . '/export/advanced', NULL, array('perform backup'));
+ $help .= backup_migrate_help_section(t('Restore Tab'), BACKUP_MIGRATE_MENU_PATH . '/restore', NULL, array('restore from backup'));
+ $help .= backup_migrate_help_section(t('Destinations'), BACKUP_MIGRATE_MENU_PATH . '/settings/destination', t('Files can be saved to a directory on your web server, downloaded to your desktop or emailed to a specified email account. From the Destinations tab you can create, delete and edit destinations or list the files which have already been backed up to the available destinations.'), array('administer backup and migrate'));
+ $help .= backup_migrate_help_section(t('Sources'), BACKUP_MIGRATE_MENU_PATH . '/settings/source', NULL, array('administer backup and migrate'));
+ $help .= backup_migrate_help_section(t('Profiles'), BACKUP_MIGRATE_MENU_PATH . '/settings/profile', t('You can create new profiles using the add profiles tab or by checking the "Save these settings" button on the advanced backup page.'), array('administer backup and migrate'));
+ $help .= backup_migrate_help_section(t('Scheduling'), BACKUP_MIGRATE_MENU_PATH . '/schedule', t("Each schedule will run a maximum of once per cron run, so they will not run more frequently than your cron is configured to run. If you specify a number of backups to keep for a schedule, old backups will be deleted as new ones created. If specifiy a number of files to keep other backup files in that schedule's destination will get deleted."), array('administer backup and migrate'));
+ $help .= backup_migrate_help_section(t('Importing Settings'), BACKUP_MIGRATE_MENU_PATH . '/settings/import', NULL, array());
+ break;
}
- if ($section == 'admin/help#backup_migrate') {
- $out = "";
- foreach ($help as $key => $section) {
- if (isset($section['access arguments'])) {
- foreach($section['access arguments'] as $access) {
- if (!user_access($access)) {
- continue 2;
- }
- }
- }
- if (@$section['title']) {
- if (!is_numeric($key)) {
- $section['title'] = l($section['title'], $key);
- }
- $out .= "
". $section['title'] ."
";
- }
- $out .= "
". $section['body'] ."
";
- if (!empty($section['more'])) {
- $out .= "
". $section['more'] ."
";
- }
- }
- return $out;
- }
+ return $help;
}
/**
- * Implementation of hook_menu().
+ * Helper function for HOOK_help() to create parts of the help page.
+ */
+function backup_migrate_help_section($title, $section, $more = NULL, $access_arguments = array()) {
+ $show_this = TRUE;
+ $help = '';
+
+ foreach ($access_arguments as $access) {
+ $show_this = $show_this && user_access($access);
+ }
+
+ if ($show_this) {
+ $help = '';
+ $help .= '
';
+ return $output;
+}
+
/**
* The backup/export form.
*/
function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) {
- drupal_add_js(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.js', array('type' => 'module', 'scope' => 'footer'));
+ drupal_add_js(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.js', array('type' => 'module', 'scope' => 'footer'));
$form = array();
$form += _backup_migrate_get_source_form('db');
- $form += _backup_migrate_ui_backup_settings_form($profile);
- $form['profile_id'] = array(
+ $form_state['profile'] = $profile;
+
+ $form['machine_name'] = array(
"#type" => "value",
'#default_value' => $profile->get_id(),
);
+
$form['storage'] = array(
"#type" => "value",
'#default_value' => $profile->storage,
@@ -463,18 +1093,25 @@ function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) {
"#collapsed" => FALSE,
"#tree" => FALSE,
"#description" => t("Choose where the backup file will be saved. Backup files contain sensitive data, so be careful where you save them. Select 'Download' to download the file to your desktop."),
- '#weight' => 70,
+ // '#weight' => 70,
);
- $form['destination']['destination_id'] = array(
- "#type" => "select",
- "#title" => t("Destination"),
- "#options" => _backup_migrate_get_destination_form_item_options('manual backup'),
- "#default_value" => variable_get("backup_migrate_destination_id", "download"),
- );
- if (user_access('administer backup and migrate')) {
- $form['destination']['destination_id']['#description'] = l(t("Create new destination"), BACKUP_MIGRATE_MENU_PATH . "/destination/add");
- }
+ $form['destination']['destination'] = _backup_migrate_get_destination_pulldown('manual backup', variable_get('backup_migrate_destination_id', 'download'));
+ $form += _backup_migrate_ui_backup_settings_form($profile);
+
+ // Make the source settings dependent on the source selected. Except don't
+ // because it looks super weird.
+ // @code
+ // foreach (element_children($form['sources']) as $source) {
+ // $form['sources'][$source] = array(
+ // '#type' => 'backup_migrate_dependent',
+ // '#dependencies' => array(
+ // 'source_id' => $source,
+ // ),
+ // 'settings' => $form['sources'][$source]
+ // );
+ // }
+ // @endcode
if (user_access('administer backup and migrate')) {
$form['save_settings'] = array(
"#type" => "checkbox",
@@ -483,8 +1120,10 @@ function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) {
'#weight' => 80,
);
$form['save_options'] = array(
- '#prefix' => '
',
- '#suffix' => '
',
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'save_settings' => TRUE,
+ ),
'#weight' => 90,
);
$name = array(
@@ -521,24 +1160,23 @@ function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) {
$form['#validate'][] = 'backup_migrate_ui_manual_quick_backup_form_validate';
$form['#submit'][] = 'backup_migrate_ui_manual_backup_form_submit';
- $form[] = array(
+ $form['submit'] = array(
'#type' => 'submit',
'#value' => t('Backup now'),
'#weight' => 100,
);
- return $form;
+ return _backup_migrate_ui_action_form($form, $form_state, 'backup');
}
-
/**
- * Submit the form. Save the values as defaults if desired and output the backup file.
+ * Submits the form.
+ *
+ * Save the values as defaults if desired and output the backup file.
*/
function backup_migrate_ui_manual_backup_form_submit($form, &$form_state) {
- // Save the settings profile if the save box is checked.
-// $form_state['values']['nodata_tables'] = array_filter((array)$form_state['values']['nodata_tables']);
-// $form_state['values']['exclude_tables'] = array_filter((array)$form_state['values']['exclude_tables']);
-
- $profile = backup_migrate_crud_create_item('profile', $form_state['values']);
+ // Create a profile with the given settings.
+ $profile = $form_state['profile'];
+ $profile->from_array($form_state['values']);
// Save the settings profile if the save box is checked.
if ($form_state['values']['save_settings'] && user_access('administer backup and migrate')) {
@@ -553,16 +1191,111 @@ function backup_migrate_ui_manual_backup_form_submit($form, &$form_state) {
}
// Perform the actual backup if that is what was selected.
- if ($form_state['values']['op'] == t('Backup now') && user_access('perform backup')) {
+ if ($form_state['values']['op'] !== t('Save Without Backing Up') && user_access('perform backup')) {
backup_migrate_ui_manual_backup_perform($profile);
}
$form_state['redirect'] = BACKUP_MIGRATE_MENU_PATH . "/export/advanced";
}
+/**
+ * Alters a B&M action (backup/restore) form to allow for filters to add steps.
+ */
+function _backup_migrate_ui_action_form($form, &$form_state, $op = 'backup') {
+ $form['operation'] = array('#type' => 'value', '#value' => $op);
+
+ // If the form has been submitted at least once then see if there are
+ // additional form elements to add.
+ if (!empty($form_state['storage']['values']) && !empty($form_state['values']['settings'])) {
+ $page = _backup_migrate_filter_before_action_form($form_state['values']['settings'], $op);
+ if (!empty($page)) {
+ $page['#validate'] = $form['#validate'];
+ $page['#submit'] = $form['#submit'];
+ $page['submit'] = array(
+ '#type' => 'submit',
+ '#value' => isset($form_state['values']['op']) ? check_plain($form_state['values']['op']) : t('Continue'),
+ '#weight' => 1,
+ );
+ $form = $page;
+ }
+ }
+
+ // Add some pre and post processing functions to validate and submit.
+ array_unshift($form['#validate'], 'backup_migrate_ui_action_form_pre_validate');
+ array_push($form['#validate'], 'backup_migrate_ui_action_form_post_validate');
+
+ array_unshift($form['#submit'], 'backup_migrate_ui_action_form_pre_submit');
+
+ return $form;
+}
+
+/**
+ * Allows filters, sources and destinations to present additional form elements.
+ *
+ * The additional form elements will be shown to the user before an action is
+ * submitted.
+ */
+function backup_migrate_ui_action_form_pre_validate($form, &$form_state) {
+ if (!empty($form_state['storage']['values'])) {
+ $form_state['values'] += $form_state['storage']['values'];
+ }
+}
+
+/**
+ * Allows filters, sources and destinations to present additional form elements.
+ *
+ * The additional form elements will be shown to the user before an action is
+ * submitted.
+ */
+function backup_migrate_ui_action_form_post_validate($form, &$form_state) {
+ require_once dirname(__FILE__) . '/includes/filters.inc';
+
+ if (!empty($form_state['values']['settings'])) {
+ // See if there are extra form items to be processed.
+ $form = _backup_migrate_filter_before_action_form($form_state['values']['settings'], $form_state['values']['operation']);
+ if ($form) {
+ // First time through the form simply rebuild the form to show the
+ // additional fields.
+ if (empty($form_state['storage']['values'])) {
+ $form_state['storage']['values'] = $form_state['values'];
+ $form_state['rebuild'] = TRUE;
+ }
+ else {
+ backup_migrate_filters_before_action_form_validate($form_state['values']['settings'], $form_state['values']['operation'], $form, $form_state);
+ }
+ }
+ }
+}
+
+/**
+ * Allows filters, sources and destinations to present additional form elements.
+ *
+ * The additional form elements will be shown to the user before an action is
+ * submitted.
+ */
+function backup_migrate_ui_action_form_pre_submit($form, &$form_state) {
+ if (!empty($form_state['storage']['values']) && !empty($form_state['values']['settings'])) {
+ // Check if there are any form elements to submit.
+ backup_migrate_filters_before_action_form_submit($form_state['values']['settings'], $form_state['values']['operation'], $form, $form_state);
+ // Clear the storage so the form can continue as normal.
+ unset($form_state['storage']);
+ }
+}
+
+/**
+ * Retrieves form items to be filled out before an action can continue.
+ *
+ * @return array
+ * An array of form items.
+ */
+function _backup_migrate_filter_before_action_form($settings, $op) {
+ $form = array();
+ $form = backup_migrate_filters_before_action_form($settings, $op);
+ return $form;
+}
+
/**
* Perform an actual manual backup and tell the user of the progress.
*/
-
function backup_migrate_ui_manual_backup_perform($settings) {
// Peform the actual backup.
backup_migrate_perform_backup($settings);
@@ -579,17 +1312,73 @@ function backup_migrate_ui_manual_restore() {
* The restore/import upload form.
*/
function backup_migrate_ui_manual_restore_form() {
- backup_migrate_include('filters', 'destinations');
+ require_once dirname(__FILE__) . '/includes/destinations.inc';
+ require_once dirname(__FILE__) . '/includes/filters.inc';
+ require_once dirname(__FILE__) . '/includes/sources.inc';
+
+ drupal_set_message(t('Restoring will delete some or all of your data and cannot be undone. Always test your backups on a non-production server!'), 'warning', FALSE);
$form = array();
- $sources = _backup_migrate_get_destination_form_item_options('source');
+ $from_default = (isset($_GET['page']) || isset($_GET['sort'])) ? 'saved' : 'upload';
+ $form['backup_migrate_restore_from_upload'] = array(
+ "#type" => "radio",
+ "#title" => t('Restore from an uploaded file'),
+ '#return_value' => 'upload',
+ '#parents' => array('from'),
+ '#default_value' => $from_default,
+ );
+
+ $form['backup_migrate_restore_upload'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'from' => 'upload',
+ ),
+ );
+
+ $form['backup_migrate_restore_upload']['backup_migrate_restore_upload'] = array(
+ '#title' => t('Upload a Backup File'),
+ '#type' => 'file',
+ '#description' => t("Upload a backup file created by Backup and Migrate. For other database or file backups please use another tool for import. Max file size: %size", array("%size" => format_size(file_upload_max_size()))),
+ );
+
+ $form['backup_migrate_restore_from_saved'] = array(
+ "#type" => "radio",
+ "#title" => t('Restore from a saved backup'),
+ '#return_value' => 'saved',
+ '#parents' => array('from'),
+ '#default_value' => $from_default,
+ );
+
+ $form['backup_migrate_restore_saved'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'from' => 'saved',
+ ),
+ );
+
+ list($files, $fetch_time, $remote) = backup_migrate_get_saved_backups();
+ $keys = array_keys($files);
+ $default = reset($keys);
+ $form['backup_migrate_restore_saved']['file'] = array(
+ '#type' => 'backup_migrate_file_list',
+ '#display_options' => array(
+ 'limit' => 5,
+ 'pager' => FALSE,
+ 'more' => BACKUP_MIGRATE_MENU_PATH . '/backups',
+ 'operations' => FALSE,
+ ),
+ '#default_value' => $default,
+ '#files' => $files,
+ );
+
+ $sources = _backup_migrate_get_source_form_item_options();
if (count($sources) > 1) {
$form['source_id'] = array(
"#type" => "select",
"#title" => t("Restore to"),
- "#options" => _backup_migrate_get_destination_form_item_options('source'),
- "#description" => t("Choose the database to restore to. Any database destinations you have created and any databases specified in your settings.php can be restored to."),
+ "#options" => $sources,
+ "#description" => t("Choose where to restore to. Any database destinations you have created and any databases specified in your settings.php can be restored to."),
"#default_value" => 'db',
);
}
@@ -600,20 +1389,13 @@ function backup_migrate_ui_manual_restore_form() {
);
}
- $form['backup_migrate_restore_upload'] = array(
- '#title' => t('Upload a Backup File'),
- '#type' => 'file',
- '#description' => t("Upload a backup file created by this version of this module. For other database backups please use another tool for import. Max file size: %size", array("%size" => format_size(file_upload_max_size()))),
- );
- drupal_set_message(t('Restoring will delete some or all of your data and cannot be undone. Always test your backups on a non-production server!'), 'warning', FALSE);
-
$form = array_merge_recursive($form, backup_migrate_filters_settings_form(backup_migrate_filters_settings_default('restore'), 'restore'));
// Add the advanced fieldset if there are any fields in it.
- if (@$form['advanced']) {
+ if (isset($form['advanced'])) {
$form['advanced']['#type'] = 'fieldset';
$form['advanced']['#title'] = t('Advanced Options');
- $form['advanced']['#collapsed'] = true;
- $form['advanced']['#collapsible'] = true;
+ $form['advanced']['#collapsed'] = TRUE;
+ $form['advanced']['#collapsible'] = TRUE;
}
$form['submit'] = array(
@@ -623,7 +1405,7 @@ function backup_migrate_ui_manual_restore_form() {
if (user_access('access backup files')) {
$form[] = array(
'#type' => 'markup',
- '#markup' => t('
';
+ }
+
+ // Render the list.
+ $out .= $fetch;
+ $out .= _backup_migrate_ui_destination_display_file_list($files, array('limit' => 20, 'pager' => TRUE));
+ $out .= $fetch;
+
+ // Add a remote backups warning if there are no remote backups.
+ if (!$remote && user_access('administer backup and migrate')) {
+ drupal_set_message(
+ t('You do not have any offsite backups. For the highest level of protection, create an offsite destination to save your backups to.',
+ array(
+ '!addurl' => url(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add'),
+ )), 'warning', FALSE);
+ }
+
+ return $out;
+}
+
+/**
+ * List the previously created backups from across multiple destinations.
+ */
+function backup_migrate_get_saved_backups($refresh = FALSE) {
+ require_once dirname(__FILE__) . '/includes/destinations.inc';
+ require_once dirname(__FILE__) . '/includes/profiles.inc';
+ require_once dirname(__FILE__) . '/includes/sources.inc';
+
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
+
+ $remote = FALSE;
+ $now = $fetch_time = time();
+ $out = '';
+ $files = $sort = array();
+ foreach (backup_migrate_get_destinations('list files') as $destination) {
+ $dest_id = $destination->get_id();
+ $dest_files = $destination->list_files();
+ if ($dest_files) {
+ $location = l($destination->get_name(), BACKUP_MIGRATE_MENU_PATH . '/settings/destination/list/files/' . $dest_id);
+ if ($destination->get('remote')) {
+ $location .= $destination->get('remote') ? ' (' . t('offsite') . ')' : '';
+ $remote = TRUE;
+ }
+
+ // Refresh the destination.
+ if ($refresh) {
+ $destination->file_cache_clear();
+ }
+
+ // Get the file fetch time.
+ if ($destination->cache_files && $destination->fetch_time) {
+ $fetch_time = min($destination->fetch_time, $fetch_time);
+ }
+
+ // Add the files from this destination to the full list.
+ foreach ($dest_files as $id => $file) {
+ $dest_files[$id]->file_info['bam_other_safe'][t('Location:')] = $location;
+ $sort[$dest_id . '/' . $id] = $file->info('filetime');
+ $files[$dest_id . '/' . $id] = $file;
+ }
+ }
+ }
+ array_multisort($sort, SORT_DESC, $files);
+
+ return array($files, $fetch_time, $remote);
+}
+
+/**
+ * Helper function for byte conversion.
+ *
+ * @see README.txt
+ * @see http://php.net/manual/en/ini.core.php#ini.memory-limit
+ */
+function backup_migrate_to_bytes($from) {
+ $passes_sanity_check = preg_match('/^(-1|[0-9]+|[0-9]*(\.[0-9]+)?[mg])$/i', $from);
+ if (!$passes_sanity_check) {
+ return 0;
+ }
+
+ if ($from === '-1') {
+ return -1;
+ }
+
+ $number = substr($from, 0, -1);
+ $unit = strtoupper(substr($from, -1));
+ switch ($unit) {
+ case "M":
+ return $number * pow(1024, 2);
+
+ break;
+
+ case "G":
+ return $number * pow(1024, 3);
+
+ break;
+
+ default:
+ return $number * pow(1024, 2);
+ }
+}
+
/**
* Perform a backup with the given settings.
*/
function backup_migrate_perform_backup(&$settings) {
- backup_migrate_include('destinations', 'files', 'filters');
+ require_once dirname(__FILE__) . '/includes/destinations.inc';
+ require_once dirname(__FILE__) . '/includes/files.inc';
+ require_once dirname(__FILE__) . '/includes/filters.inc';
+
timer_start('backup_migrate_backup');
- // If not in 'safe mode', increase the maximum execution time:
- if (!ini_get('safe_mode') && strpos(ini_get('disable_functions'), 'set_time_limit') === FALSE && ini_get('max_execution_time') < 1200) {
- set_time_limit(variable_get('backup_migrate_backup_max_time', 1200));
+ _backup_migrate_set_timeout();
+
+ // Conditionally increase the memory limit.
+ // Get the current php memory limit.
+ $php_memory_limit = ini_get('memory_limit');
+
+ // If the memory limit is set to -1, there's no need to do anything.
+ if ($php_memory_limit !== -1) {
+ // Convert the php memory limit to bytes.
+ $php_memory_limit_bytes = backup_migrate_to_bytes($php_memory_limit);
+
+ // Get the current Backup Migrate memory limit.
+ // Hint: To further increase the memory limit used by Backup Migrate add one
+ // of the following line to the settings.php file:
+ // * $conf['backup_migrate_memory_limit'] = '512M';
+ // * $conf['backup_migrate_memory_limit'] = '1G';.
+ $backup_migrate_memory_limit = variable_get('backup_migrate_memory_limit', BACKUP_MIGRATE_MEMORY_LIMIT);
+
+ // Convert the Backup Migrate memory limit to bytes.
+ $backup_migrate_memory_limit_bytes = backup_migrate_to_bytes($backup_migrate_memory_limit);
+
+ // If not in 'safe mode', increase the memory limit.
+ if (!ini_get('safe_mode') && $php_memory_limit_bytes < $backup_migrate_memory_limit_bytes) {
+ // Ensure ini_set() is not disabled.
+ if (!strpos(ini_get('disable_functions'), 'ini_set')) {
+ // Convert bytes to megabytes, add the 'M' unit.
+ $backup_migrate_memory_limit = round($backup_migrate_memory_limit_bytes / 1024 / 1024) . 'M';
+
+ // Update the php memory limit.
+ ini_set('memory_limit', $backup_migrate_memory_limit);
+ }
+ }
}
- $timestamp = '';
- if ($settings->append_timestamp && $settings->timestamp_format) {
- $timestamp = format_date(time(), 'custom', $settings->timestamp_format);
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message("Memory limit: %limit", array('%limit' => ini_get('memory_limit')), 'success');
}
- $filename = _backup_migrate_construct_filename($settings->filename, $timestamp);
+ // Confirm the destinations are valid.
+ $valid = backup_migrate_destination_confirm_destination($settings);
+ if (!$valid) {
+ backup_migrate_backup_fail("Could not run backup because a there was no valid destination to save to.", array(), $settings);
+ return FALSE;
+ }
+
+ // Create the temporary file object to be backed up into.
+ $filename = _backup_migrate_construct_filename($settings);
$file = new backup_file(array('filename' => $filename));
if (!$file) {
backup_migrate_backup_fail("Could not run backup because a temporary file could not be created.", array(), $settings);
@@ -681,6 +1644,9 @@ function backup_migrate_perform_backup(&$settings) {
// Register shutdown callback to deal with timeouts.
register_shutdown_function('backup_migrate_shutdown', $settings);
+ if (variable_get('backup_migrate_verbose')) {
+ watchdog('backup_migrate', "Starting backup: %file", array('%file' => $file->filename()));
+ }
$file = backup_migrate_filters_backup($file, $settings);
if (!$file) {
if (_backup_migrate_check_timeout()) {
@@ -692,20 +1658,27 @@ function backup_migrate_perform_backup(&$settings) {
return FALSE;
}
+ if (variable_get('backup_migrate_verbose')) {
+ watchdog('backup_migrate', "Preparing to save backup: %file", array('%file' => $file->filename()));
+ }
$file = backup_migrate_destination_save_file($file, $settings);
if (!$file) {
backup_migrate_backup_fail("Could not run backup because the file could not be saved to the destination.", array(), $settings);
return FALSE;
}
+ if (variable_get('backup_migrate_verbose')) {
+ watchdog('backup_migrate', "Backup succeeded: %file", array('%file' => $file->filename()));
+ }
- // Backup succeeded,
+ // Backup succeeded.
$time = timer_stop('backup_migrate_backup');
- $message = '%source backed up successfully to %file in destination %dest in !time ms. !action';
+ $message = '%source backed up successfully to %file (%size) in destination %dest in !time. !action';
$params = array(
'%file' => $filename,
'%dest' => $settings->get_destination_name(),
'%source' => $settings->get_source_name(),
- '!time' => $time['time'],
+ '%size' => format_size($file->filesize()),
+ '!time' => backup_migrate_format_elapsed_time($time['time']),
'!action' => !empty($settings->performed_action) ? $settings->performed_action : '',
);
if (($destination = $settings->get_destination()) && ($links = $destination->get_file_links($file->file_id()))) {
@@ -716,17 +1689,27 @@ function backup_migrate_perform_backup(&$settings) {
return $file;
}
+/**
+ * Formats an elapsed time given in milleseconds.
+ */
+function backup_migrate_format_elapsed_time($time) {
+ $ms = t('!time ms', array('!time' => $time));
+ if ($time < 1000) {
+ return $ms;
+ }
+ return '' . format_interval($time / 1000) . '';
+}
+
/**
* Restore from a file in the given destination.
*/
function backup_migrate_perform_restore($destination_id, $file, $settings = array()) {
- backup_migrate_include('files', 'filters');
+ require_once dirname(__FILE__) . '/includes/files.inc';
+ require_once dirname(__FILE__) . '/includes/filters.inc';
+
timer_start('backup_migrate_restore');
- // If not in 'safe mode', increase the maximum execution time:
- if (!ini_get('safe_mode') && strpos(ini_get('disable_functions'), 'set_time_limit') === FALSE && ini_get('max_execution_time') < variable_get('backup_migrate_backup_max_time', 1200)) {
- set_time_limit(variable_get('backup_migrate_restore_max_time', 1200));
- }
+ _backup_migrate_set_timeout();
// Make the settings into a default profile.
if (!is_object($settings)) {
@@ -746,7 +1729,6 @@ function backup_migrate_perform_restore($destination_id, $file, $settings = arra
return FALSE;
}
}
- $file_id = $file->file_id();
// Filter the file and perform the restore.
$file = backup_migrate_filters_restore($file, $settings);
@@ -764,16 +1746,17 @@ function backup_migrate_perform_restore($destination_id, $file, $settings = arra
$time = timer_stop('backup_migrate_restore');
if ($file) {
$destination = backup_migrate_get_destination($destination_id);
- $message = '%source restored from %dest file %file in !time ms. !action';
+ $message = '%source restored from %dest file %file in !time. !action';
$params = array(
'%file' => $file->filename(),
'%source' => $settings->get_source_name(),
'%dest' => $destination->get_name(),
- '!time' => $time['time'],
+ '!time' => backup_migrate_format_elapsed_time($time['time']),
'!action' => !empty($settings->performed_action) ? $settings->performed_action : '',
);
if ($destination && $destination->op('list files')) {
- $params['!links'] = t('Restore again', array('!restoreurl' => url(BACKUP_MIGRATE_MENU_PATH . '/destination/restorefile/'. $destination_id ."/". $file_id)));
+ $path = $destination->get_settings_path();
+ $params['!links'] = t('Restore again', array('!restoreurl' => url($path . '/list/restorefile/' . $destination->get_id() . '/' . $file->file_id())));
}
backup_migrate_restore_succeed($message, $params, $settings);
}
@@ -788,7 +1771,8 @@ function backup_migrate_perform_restore($destination_id, $file, $settings = arra
* Clean up when a backup operation fails.
*/
function backup_migrate_backup_fail($message, $params, $settings) {
- backup_migrate_include('files', 'filters');
+ require_once dirname(__FILE__) . '/includes/files.inc';
+ require_once dirname(__FILE__) . '/includes/filters.inc';
_backup_migrate_message($message, $params, 'error');
backup_migrate_cleanup();
@@ -797,10 +1781,12 @@ function backup_migrate_backup_fail($message, $params, $settings) {
}
/**
- * Clean up when a backup operation suceeds.
+ * Clean up when a backup operation succeeds.
*/
function backup_migrate_backup_succeed($message, $params, $settings) {
- backup_migrate_include('filters', 'files');
+ require_once dirname(__FILE__) . '/includes/files.inc';
+ require_once dirname(__FILE__) . '/includes/filters.inc';
+
_backup_migrate_message($message, $params, 'success');
backup_migrate_cleanup();
backup_migrate_filters_invoke_all('backup_succeed', $settings, $message, $params);
@@ -811,7 +1797,9 @@ function backup_migrate_backup_succeed($message, $params, $settings) {
* Clean up when a restore operation fails.
*/
function backup_migrate_restore_fail($message, $params, $settings) {
- backup_migrate_include('files', 'filters');
+ require_once dirname(__FILE__) . '/includes/files.inc';
+ require_once dirname(__FILE__) . '/includes/filters.inc';
+
_backup_migrate_message($message, $params, 'error');
backup_migrate_cleanup();
backup_migrate_filters_invoke_all('restore_fail', $settings, $message, $params);
@@ -819,108 +1807,103 @@ function backup_migrate_restore_fail($message, $params, $settings) {
}
/**
- * Clean up when a restore operation suceeds.
+ * Clean up when a restore operation succeeds.
*/
function backup_migrate_restore_succeed($message, $params, $settings) {
- backup_migrate_include('filters', 'files');
+ require_once dirname(__FILE__) . '/includes/files.inc';
+ require_once dirname(__FILE__) . '/includes/filters.inc';
+
_backup_migrate_message($message, $params, 'success');
backup_migrate_cleanup();
backup_migrate_filters_invoke_all('restore_succeed', $settings, $message, $params);
return FALSE;
}
-
/**
- * Cleanup after a success or failure.
+ * Cleans up after a success or failure.
*/
function backup_migrate_cleanup() {
- // Check that the cleanup function exists. If it doesn't then we probably didn't create any files to be cleaned up.
+ // Check that the cleanup function exists. If it doesn't then we probably
+ // didn't create any files to be cleaned up.
if (function_exists('_backup_migrate_temp_files_delete')) {
_backup_migrate_temp_files_delete();
}
}
-
/**
- * Shutdown callback. Called when the script terminates even if the script timed out.
+ * Shutdown callback.
+ *
+ * Called when the script terminates even if the script timed out.
*/
function backup_migrate_shutdown($settings) {
- // If we ran out of time, set an error so the user knows what happened
+ // If we ran out of time, set an error so the user knows what happened.
if (_backup_migrate_check_timeout()) {
backup_migrate_cleanup();
backup_migrate_backup_fail('The operation timed out. Try increasing your PHP max_execution_time setting.', array('!url' => 'http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time'), $settings);
- // The session will have already been written and closed, so we need to write any changes directly.
+ // The session will have already been written and closed, so we need to
+ // write any changes directly.
_drupal_session_write(session_id(), session_encode());
// Add a redirect or we'll just get whitescreened.
drupal_goto(BACKUP_MIGRATE_MENU_PATH);
}
}
-
-
-/* Actions/Workflow integration */
+/**
+ * Action to backup the drupal site.
+ *
+ * Requires actions.module.
+ *
+ * function action_backup_migrate_backup($op, $edit = array()) {
+ * switch ($op) {
+ * case 'do':
+ * _backup_migrate_backup_with_defaults();
+ * watchdog('action', 'Backed up database');
+ * break;.
+ * * Case 'metadata':
+ * return array(
+ * 'description' => t('Backup the database with the default settings'),
+ * 'type' => t('Backup and Migrate'),
+ * 'batchable' => TRUE,
+ * 'configurable' => FALSE,
+ * );
+ * * // Return an HTML config form for the action.
+ * * case 'form':
+ * return '';
+ * * // Validate the HTML form.
+ * * case 'validate':
+ * return TRUE;
+ * * // Process the HTML form to store configuration.
+ * * case 'submit':
+ * return '';
+ * }
+ * }.
+ */
/**
- * Action to backup the drupal site. Requires actions.module.
-function action_backup_migrate_backup($op, $edit = array()) {
- switch ($op) {
- case 'do':
- _backup_migrate_backup_with_defaults();
- watchdog('action', 'Backed up database');
- break;
-
- case 'metadata':
- return array(
- 'description' => t('Backup the database with the default settings'),
- 'type' => t('Backup and Migrate'),
- 'batchable' => TRUE,
- 'configurable' => FALSE,
- );
-
- // Return an HTML config form for the action.
-
- case 'form':
- return '';
-
- // Validate the HTML form.
-
- case 'validate':
- return TRUE;
-
- // Process the HTML form to store configuration.
-
- case 'submit':
- return '';
- }
-}
+ * Implements hook_action_info().
*/
+// Function backup_migrate_action_info() {
+// return array(
+// 'backup_migrate_action_backup' => array(
+// 'label' => t('Backup the database'),
+// 'description' => t('Backup the database with the default settings.'),
+// ),
+// );
+// }.
-/*
- * Implementation of hook_action_info().
-function backup_migrate_action_info() {
- return array(
- 'backup_migrate_action_backup' => array(
- 'label' => t('Backup the database'),
- 'description' => t('Backup the database with the default settings.'),
- ),
- );
-}
- */
-
-/*
+/**
* Action callback.
*/
function backup_migrate_action_backup() {
_backup_migrate_backup_with_defaults();
}
-/* Utilities */
-
/**
* Backup the database with the default settings.
*/
function _backup_migrate_backup_with_defaults($destination_id = "manual") {
- backup_migrate_include('files', 'profiles');
+ require_once dirname(__FILE__) . '/includes/files.inc';
+ require_once dirname(__FILE__) . '/includes/profiles.inc';
$settings = _backup_migrate_profile_saved_default_profile();
$settings->destination_id = $destination_id;
@@ -929,7 +1912,9 @@ function _backup_migrate_backup_with_defaults($destination_id = "manual") {
}
/**
- * Helper function to set a drupal message and watchdog message depending on whether the module is being run interactively.
+ * Helper function to set a Drupal message and watchdog message.
+ *
+ * Depends on whether the module is being run interactively.
*/
function _backup_migrate_message($message, $replace = array(), $type = 'status') {
// Only set a message if there is a callback handler to handle the message.
@@ -937,23 +1922,32 @@ function _backup_migrate_message($message, $replace = array(), $type = 'status')
$callback($message, $replace, $type);
}
- // Store the message in case it's needed (for the status notification filter for example).
+ // Store the message in case it's needed (for the status notification filter
+ // for example).
_backup_migrate_messages($message, $replace, $type);
}
/**
- * Helper function to set a drupal message and watchdog message depending on whether the module is being run interactively.
+ * Helper function to set a Drupal message and watchdog message.
+ *
+ * Depends on whether the module is being run interactively.
*/
function _backup_migrate_messages($message = NULL, $replace = array(), $type = 'status') {
static $messages = array();
if ($message) {
- $messages[] = array('message' => $message, 'replace' => $replace, 'type' => 'status');
+ $messages[] = array(
+ 'message' => $message,
+ 'replace' => $replace,
+ 'type' => $type,
+ );
}
return $messages;
}
/**
- * Send a message to the browser. The normal type of message handling for interactive use.
+ * Sends a message to the browser.
+ *
+ * The normal type of message handling for interactive use.
*/
function _backup_migrate_message_browser($message, $replace, $type) {
// Log the message as well for admins.
@@ -968,7 +1962,7 @@ function _backup_migrate_message_browser($message, $replace, $type) {
}
/**
- * Log message if we are in a non-interactive mode such as a cron run.
+ * Logs a message if we are in a non-interactive mode such as a cron run.
*/
function _backup_migrate_message_log($message, $replace, $type) {
// We only want to log the errors or successful completions.
@@ -978,7 +1972,7 @@ function _backup_migrate_message_log($message, $replace, $type) {
}
/**
- * Set or retrieve a message handler.
+ * Sets or retrieves a message handler.
*/
function _backup_migrate_message_callback($callback = NULL) {
static $current_callback = '_backup_migrate_message_log';
@@ -988,48 +1982,77 @@ function _backup_migrate_message_callback($callback = NULL) {
return $current_callback;
}
+/**
+ * Increase the execution timeout, and also the database connection timeout.
+ */
+function _backup_migrate_set_timeout() {
+ // If not in 'safe mode', increase the maximum execution time:
+ $backup_max_time = variable_get('backup_migrate_backup_max_time', BACKUP_MIGRATE_BACKUP_MAX_TIME);
+ if (!ini_get('safe_mode') && ini_get('max_execution_time') < $backup_max_time) {
+ drupal_set_time_limit($backup_max_time);
+ }
+
+ // Also increase the time mysql keeps the connection open.
+ if (Database::getConnection() instanceof DatabaseConnection_mysql) {
+ $mysql_wait_timeout = db_query('SELECT @@session.wait_timeout')->fetchField();
+ if ($mysql_wait_timeout < $backup_max_time) {
+ // This does not work with placeholders, so sanitize by casting to int.
+ db_query('SET SESSION wait_timeout = ' . (int) $backup_max_time);
+ }
+ }
+}
+
+/**
+ * Determines if time for a page execution has run out.
+ */
function _backup_migrate_check_timeout() {
static $timeout;
// Max execution of 0 means unlimited.
if (ini_get('max_execution_time') == 0) {
- return false;
+ return FALSE;
}
+
// Figure out when we should stop execution.
if (!$timeout) {
- $timeout = (!empty($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time()) + ini_get('max_execution_time') - variable_get('backup_migrate_timeout_buffer', 5);
+ $backup_max_time = max(ini_get('max_execution_time'), variable_get('backup_migrate_backup_max_time', BACKUP_MIGRATE_BACKUP_MAX_TIME));
+ $timeout = (!empty($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time()) + $backup_max_time - variable_get('backup_migrate_timeout_buffer', 5);
}
+
return (time() > $timeout);
}
/**
- * Convert an associated array to an ini format string.
+ * Converts an associated array to an ini format string.
*/
function _backup_migrate_array_to_ini($data, $prefix = '') {
- $content = "";
+ $content = '';
foreach ($data as $key => $val) {
if ($prefix) {
- $key = $prefix . '[' . $key .']';
+ $key = $prefix . '[' . $key . ']';
}
if (is_array($val)) {
$content .= _backup_migrate_array_to_ini($val, $key);
}
else {
- $content .= $key . " = \"". $val ."\"\n";
+ $content .= $key . ' = "' . $val . "\"\n";
}
}
return $content;
}
/**
- * Execute a command line command. Returns false if the function failed.
+ * Execute a command line command.
+ *
+ * @return bool
+ * Returns FALSE if the function failed.
*/
function backup_migrate_exec($command, $args = array()) {
if (!function_exists('exec') || ini_get('safe_mode')) {
return FALSE;
}
- // Escape the arguments
+ // Escape the arguments.
foreach ($args as $key => $arg) {
$args[$key] = escapeshellarg($arg);
}
@@ -1037,8 +2060,100 @@ function backup_migrate_exec($command, $args = array()) {
$output = $result = NULL;
// Run the command.
- exec($command . ' 2>&1', $output, $result);
+ exec($command, $output, $result);
return $result == 0;
}
+/**
+ * Format a size, treating 1GB as 1000 MB rather than 1024 MB.
+ *
+ * This is a more standard and expected version for storage (as opposed to
+ * memory).
+ */
+function backup_migrate_format_size($size, $langcode = LANGUAGE_NONE) {
+ $precision = 2;
+ $multiply = pow(10, $precision);
+
+ if ($size == 0) {
+ return t('0 bytes', array(), array('langcode' => $langcode));
+ }
+ if ($size < 1024) {
+ return format_plural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode));
+ }
+ else {
+ $size = ceil($size * $multiply / 1024);
+ $string = '@size KB';
+ if ($size >= (1024 * $multiply)) {
+ $size = ceil($size / 1024);
+ $string = '@size MB';
+ }
+ if ($size >= 1000 * $multiply) {
+ $size = ceil($size / 1000);
+ $string = '@size GB';
+ }
+ if ($size >= 1000 * $multiply) {
+ $size = ceil($size / 1000);
+ $string = '@size TB';
+ }
+ return t($string, array('@size' => round($size / $multiply, $precision)), array('langcode' => $langcode));
+ }
+}
+
+/**
+ * Implements hook_mail().
+ */
+function backup_migrate_mail($key, &$message, $params) {
+ if ($key == 'backup_succeed') {
+ $message['id'] = 'backup_migrate_backup_succeed';
+ $message['subject'] = t('!site backup succeeded', array('!site' => variable_get('site_name', 'Drupal site')));
+ $message['body'][] = $params['body'];
+ }
+ elseif ($key == 'backup_fail') {
+ $message['id'] = 'backup_migrate_backup_fail';
+ $message['subject'] = t('!site backup failed', array('!site' => variable_get('site_name', 'Drupal site')));
+ $message['body'][] = $params['body'];
+ }
+ elseif ($key == 'destination_mail') {
+ // @todo translate subject and parts of the body?
+ $message['subject'] = $params['subject'];
+ $message['body'][] = $params['body'];
+ $message['headers'] = array_merge($message['headers'], $params['headers']);
+ }
+}
+
+/**
+ * Identify the current memory usage.
+ *
+ * Uses the same formula as the Devel module.
+ *
+ * @return int
+ * The current memory usage, in megabytes.
+ */
+function backup_migrate_get_peak_memory_usage() {
+ return round(memory_get_peak_usage(TRUE) / 1024 / 1024, 2);
+}
+
+/**
+ * Returns the "name" element from an array.
+ *
+ * Callback for array_map() within
+ * backup_migrate_destination_db_mysql::_restore_db_from_file() and
+ * backup_migrate_source_db_mysql::_restore_db_from_file().
+ */
+function backup_migrate_array_name_value($a) {
+ return $a["name"];
+}
+
+/**
+ * Checks if a php.ini 'memory_limit' style value is valid.
+ *
+ * See http://php.net/manual/en/ini.core.php#ini.memory-limit for what are
+ * valid values.
+ */
+function _backup_migrate_is_valid_memory_limit($value) {
+ $test = preg_match('/^(-1|[0-9]+|[0-9]*(\.[0-9]+)?[mg])$/i', $value);
+ // preg_match() returns truthy or falsy values, this makes it explicit.
+ $out = $test ? TRUE : FALSE;
+ return $test;
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/backup_migrate.drush.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/backup_migrate.drush.inc
index 73097cb..13d57a3 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/backup_migrate.drush.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/backup_migrate.drush.inc
@@ -1,13 +1,12 @@
dt('Backup the site\'s database with Backup and Migrate.'),
'aliases' => array('bb'),
'examples' => array(
- 'drush bam-backup' => 'Backup the default databse to the manual backup directory using the default settings.',
- 'drush bam-backup db scheduled mysettings' => 'Backup the database to the scheduled directory using a settings profile called "mysettings"',
- 'drush bam-backup files' => 'Backup the files directory to the manual directory using the default settings. The Backup and Migrate Files module is required for files backups.',
+ 'drush bam-backup' => 'Backup the default database to the manual backup directory using the default settings.',
+ 'drush bam-backup db scheduled mysettings' => 'Backup the database to the scheduled directory using a settings profile called "mysettings"',
+ 'drush bam-backup files' => 'Backup the files directory to the manual directory using the default settings.',
),
'arguments' => array(
'source' => "Optional. The id of the source (usually a database) to backup. Use 'drush bam-sources' to get a list of sources. Defaults to 'db'",
@@ -41,7 +40,6 @@ function backup_migrate_drush_command() {
'callback' => 'backup_migrate_drush_destinations',
'description' => dt('Get a list of available destinations.'),
);
-
$items['bam-sources'] = array(
'callback' => 'backup_migrate_drush_sources',
'description' => dt('Get a list of available sources.'),
@@ -54,25 +52,40 @@ function backup_migrate_drush_command() {
'callback' => 'backup_migrate_drush_destination_files',
'description' => dt('Get a list of previously created backup files.'),
'arguments' => array(
- 'destination' => "Required. The id of destination to list backups from. Use 'drush bam-destinations' to get a list of destinations.",
+ 'destination' => "Optional. The id of destination to list backups from. Use 'drush bam-destinations' to get a list of destinations.",
),
);
+ $items['bam-schedule'] = array(
+ 'callback' => 'backup_migrate_drush_schedule',
+ 'description' => dt('Backup using a specific schedule.'),
+ 'arguments' => array(
+ 'schedule_id' => dt('The ID of the schedule to run.'),
+ ),
+ );
+ $items['bam-schedules'] = array(
+ 'callback' => 'backup_migrate_drush_schedules',
+ 'description' => dt('Get a list of available schedules.'),
+ );
return $items;
}
/**
- * Implementation of hook_drush_help().
+ * Implements hook_drush_help().
*/
function backup_migrate_drush_help($section) {
switch ($section) {
case 'drush:bam-backup':
return dt("Backup the site's database using default settings.");
+
case 'drush:bam-restore':
return dt('Restore the site\'s database with Backup and Migrate.');
+
case 'drush:bam-destinations':
return dt('Get a list of available destinations.');
+
case 'drush:bam-profiles':
return dt('Get a list of available settings profiles.');
+
case 'drush:bam-backups':
return dt('Get a list of previously created backup files.');
}
@@ -82,12 +95,14 @@ function backup_migrate_drush_help($section) {
* Backup the default database.
*/
function backup_migrate_drush_backup($source_id = 'db', $destination_id = 'manual', $profile_id = 'default') {
- backup_migrate_include('profiles', 'destinations');
+ require_once dirname(__FILE__) . '/destinations.inc';
+ require_once dirname(__FILE__) . '/profiles.inc';
+ require_once dirname(__FILE__) . '/sources.inc';
// Set the message mode to logging.
_backup_migrate_message_callback('_backup_migrate_message_drush');
- if (!backup_migrate_get_destination($source_id)) {
+ if (!backup_migrate_get_source($source_id)) {
_backup_migrate_message("Could not find the source '@source'. Try using 'drush bam-sources' to get a list of available sources or use 'db' to backup the Drupal database.", array('@source' => $source_id), 'error');
return;
}
@@ -96,7 +111,7 @@ function backup_migrate_drush_backup($source_id = 'db', $destination_id = 'manua
return;
}
$settings = backup_migrate_get_profile($profile_id);
- if(!$settings) {
+ if (!$settings) {
_backup_migrate_message("Could not find the profile '@profile'. Try using 'drush bam-profiles' to get a list of available profiles.", array('@profile' => $profile_id), 'error');
return;
}
@@ -108,20 +123,57 @@ function backup_migrate_drush_backup($source_id = 'db', $destination_id = 'manua
}
/**
- * Restore to the default database.
+ * Backup using schedule.
*/
-function backup_migrate_drush_restore($source_id = '', $destination_id = '', $file_id = '') {
- drush_print(dt('Restoring will delete some or all of your data and cannot be undone. ALWAYS TEST YOUR BACKUPS ON A NON-PRODUCTION SERVER!'));
- if (!drush_confirm(dt('Are you sure you want to restore the database?'))) {
- return drush_user_abort();
- }
-
- backup_migrate_include('profiles', 'destinations');
+function backup_migrate_drush_schedule($schedule_id = '') {
+ require_once dirname(__FILE__) . '/schedules.inc';
// Set the message mode to drush output.
_backup_migrate_message_callback('_backup_migrate_message_drush');
- if (!backup_migrate_get_destination($source_id)) {
+ if (!($schedule = backup_migrate_get_schedule($schedule_id))) {
+ _backup_migrate_message("Could not find the schedule '@schedule'. Try using 'drush bam-schedules' to get a list of available schedules.", array('@schedule' => $schedule_id), 'error');
+ return;
+ }
+
+ if (!$schedule->enabled) {
+ _backup_migrate_message("Nothing to do, the schedule '@schedule' is disabled.", array('@schedule' => $schedule_id), 'warning');
+ return;
+ }
+
+ _backup_migrate_message("Starting schedule '$schedule_id'...");
+
+ backup_migrate_schedule_run($schedule_id);
+}
+
+/**
+ * Get a list of available destinations.
+ */
+function backup_migrate_drush_schedules() {
+ require_once dirname(__FILE__) . '/schedules.inc';
+
+ $rows = array(array(dt('ID'), dt('Name')));
+ foreach (backup_migrate_get_schedules() as $schedule) {
+ $rows[] = array(
+ $schedule->get_id(),
+ $schedule->get_name(),
+ );
+ }
+ drush_print_table($rows, TRUE, array(32, 32));
+}
+
+/**
+ * Restore to the default database.
+ */
+function backup_migrate_drush_restore($source_id = '', $destination_id = '', $file_id = '') {
+ require_once dirname(__FILE__) . '/destinations.inc';
+ require_once dirname(__FILE__) . '/profiles.inc';
+ require_once dirname(__FILE__) . '/sources.inc';
+
+ // Set the message mode to drush output.
+ _backup_migrate_message_callback('_backup_migrate_message_drush');
+
+ if (!backup_migrate_get_source($source_id)) {
_backup_migrate_message("Could not find the source '@source'. Try using 'drush bam-sources' to get a list of available sources or use 'db' to backup the Drupal database.", array('@source' => $source_id), 'error');
return;
}
@@ -129,14 +181,18 @@ function backup_migrate_drush_restore($source_id = '', $destination_id = '', $fi
_backup_migrate_message("Could not find the destination '@destination'. Try using 'drush bam-destinations' to get a list of available destinations.", array('@destination' => $destination_id), 'error');
return;
}
- if (!$file_id || !$file = backup_migrate_destination_get_file($destination_id, $file_id)) {
+ elseif (!$file_id || !$file = backup_migrate_destination_get_file($destination_id, $file_id)) {
_backup_migrate_message("Could not find the file '@file'. Try using 'drush bam-backups @destination' to get a list of available backup files in this destination destinations.", array('@destination' => $destination_id, '@file' => $file_id), 'error');
return;
}
+ drush_print(dt('Restoring will delete some or all of your data and cannot be undone. ALWAYS TEST YOUR BACKUPS ON A NON-PRODUCTION SERVER!'));
+ if (!drush_confirm(dt('Are you sure you want to perform the restore?'))) {
+ return drush_user_abort();
+ }
_backup_migrate_message('Starting restore...');
$settings = array('source_id' => $source_id);
- backup_migrate_perform_restore($destination_id, $file_id);
+ backup_migrate_perform_restore($destination_id, $file_id, $settings);
}
/**
@@ -150,21 +206,38 @@ function backup_migrate_drush_destinations() {
* Get a list of available sources.
*/
function backup_migrate_drush_sources() {
- return _backup_migrate_drush_destinations('source');
+ return _backup_migrate_drush_sources('source');
}
-
/**
* Get a list of available destinations with the given op.
*/
function _backup_migrate_drush_destinations($op = NULL) {
- backup_migrate_include('destinations');
+ require_once dirname(__FILE__) . '/destinations.inc';
+
$rows = array(array(dt('ID'), dt('Name'), dt('Operations')));
foreach (backup_migrate_get_destinations($op) as $destination) {
$rows[] = array(
$destination->get_id(),
$destination->get_name(),
- implode (', ', $destination->ops()),
+ implode(', ', $destination->ops()),
+ );
+ }
+ drush_print_table($rows, TRUE, array(32, 32));
+}
+
+/**
+ * Get a list of available destinations with the given op.
+ */
+function _backup_migrate_drush_sources($op = NULL) {
+ require_once dirname(__FILE__) . '/sources.inc';
+
+ $rows = array(array(dt('ID'), dt('Name'), dt('Operations')));
+ foreach (backup_migrate_get_sources($op) as $destination) {
+ $rows[] = array(
+ $destination->get_id(),
+ $destination->get_name(),
+ implode(', ', $destination->ops()),
);
}
drush_print_table($rows, TRUE, array(32, 32));
@@ -174,7 +247,8 @@ function _backup_migrate_drush_destinations($op = NULL) {
* Get a list of available profiles.
*/
function backup_migrate_drush_profiles() {
- backup_migrate_include('profiles');
+ require_once dirname(__FILE__) . '/profiles.inc';
+
$rows = array(array(dt('ID'), dt('Name')));
foreach (backup_migrate_get_profiles() as $profile) {
$rows[] = array(
@@ -186,46 +260,60 @@ function backup_migrate_drush_profiles() {
}
/**
- * Get a list of files in a given destination
+ * Get a list of files in a given destination.
*/
function backup_migrate_drush_destination_files($destination_id = NULL) {
- backup_migrate_include('destinations');
+ require_once dirname(__FILE__) . '/destinations.inc';
+
+ $destinations = array();
// Set the message mode to drush output.
_backup_migrate_message_callback('_backup_migrate_message_drush');
-
- if (!$destination_id) {
- _backup_migrate_message("You must specify an existing destination. Try using 'drush bam-destinations' to get a list of available destinations.", array('@destination' => $destination_id), 'error');
- return;
- }
- if (!$destination = backup_migrate_get_destination($destination_id)) {
+ if ($destination_id && !$destination = backup_migrate_get_destination($destination_id)) {
_backup_migrate_message("Could not find the destination '@destination'. Try using 'drush bam-destinations' to get a list of available destinations.", array('@destination' => $destination_id), 'error');
return;
}
- $out = array(array(
- dt('Filename'),
- dt('Date'),
- dt('Age'),
- dt('Size'),
- ));
+ // Single destination required.
+ if ($destination) {
+ $destinations = array($destination);
+ }
+ // List all destinations.
+ else {
+ $destinations = backup_migrate_get_destinations('list files');
+ }
- $files = $destination->list_files();
- $i = 0;
- foreach ((array)$files as $file) {
- // Show only files that can be restored from.
- if ($file->is_recognized_type()) {
+ // Load all the files.
+ $rows = $sort = array();
+ foreach ($destinations as $destination) {
+ $destination->file_cache_clear();
+ $dest_files = $destination->list_files();
+ foreach ($dest_files as $id => $file) {
$info = $file->info();
- $out[] = array(
+ $rows[] = array(
check_plain($info['filename']),
+ $destination->get_id(),
format_date($info['filetime'], 'small'),
format_interval(time() - $info['filetime'], 1),
format_size($info['filesize']),
);
+ $sort[] = $info['filetime'];
}
}
- if (count($out) > 1) {
- drush_print_table($out, TRUE);
+
+ $headers = array(
+ array(
+ dt('Filename'),
+ dt('Destination'),
+ dt('Date'),
+ dt('Age'),
+ dt('Size'),
+ ),
+ );
+
+ if (count($rows)) {
+ array_multisort($sort, SORT_DESC, $rows);
+ drush_print_table(array_merge($headers, $rows), TRUE);
}
else {
drush_print(dt('There are no backup files to display.'));
@@ -236,8 +324,15 @@ function backup_migrate_drush_destination_files($destination_id = NULL) {
* Send a message to the drush log.
*/
function _backup_migrate_message_drush($message, $replace, $type) {
- // Use drush_log to display to the user.
- drush_log(strip_tags(dt($message, $replace)), str_replace('status', 'notice', $type));
+ // If this is an error use drush_set_error to notify the end user and set the
+ // exit status.
+ if ($type == 'error') {
+ drush_set_error(strip_tags(dt($message, $replace)));
+ }
+ else {
+ // Use drush_log to display to the user.
+ drush_log(strip_tags(dt($message, $replace)), str_replace('status', 'notice', $type));
+ }
// Watchdog log the message as well for admins.
_backup_migrate_message_log($message, $replace, $type);
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/crud.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/crud.inc
index 6461b68..6cc3f26 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/crud.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/crud.inc
@@ -14,6 +14,14 @@ define('BACKUP_MIGRATE_STORAGE_OVERRIDEN', 2);
*/
function backup_migrate_crud_types() {
$out = array(
+ 'schedule' => array(
+ 'class' => 'backup_migrate_schedule',
+ 'include' => 'schedules',
+ ),
+ 'source' => array(
+ 'class' => 'backup_migrate_source',
+ 'include' => 'sources',
+ ),
'destination' => array(
'class' => 'backup_migrate_destination',
'include' => 'destinations',
@@ -22,32 +30,102 @@ function backup_migrate_crud_types() {
'class' => 'backup_migrate_profile',
'include' => 'profiles',
),
- 'schedule' => array(
- 'class' => 'backup_migrate_schedule',
- 'include' => 'schedules',
- ),
);
return $out;
}
+/**
+ * Get the info for a particular crud type.
+ */
+function backup_migrate_crud_type_info($type) {
+ $types = backup_migrate_crud_types();
+ if (isset($types[$type])) {
+ return $types[$type];
+ }
+ return NULL;
+}
+
+/**
+ * Get a list of avaiable classes of each crud type.
+ */
+function backup_migrate_crud_subtypes($type) {
+ $out = array();
+ if ($info = backup_migrate_crud_type_info($type)) {
+ // Include the function that contains the type base.
+ if (!empty($info['include'])) {
+ require_once dirname(__FILE__) . '/' . $info['include'] . '.inc';
+ }
+
+ // Allow modules (including this one) to declare backup and migrate
+ // subtypes. We don't use module_invoke_all so we can avoid the
+ // side-effects of array_merge_recursive.
+ $out = array();
+ foreach (module_implements('backup_migrate_' . $type . '_subtypes') as $module) {
+ $function = $module . '_backup_migrate_' . $type . '_subtypes';
+ $result = $function();
+ if (isset($result) && is_array($result)) {
+ foreach ($result as $key => $val) {
+ $out[$key] = $val;
+ }
+ }
+ }
+ }
+
+ return $out;
+}
+
+/**
+ * Get the info for a particular crud subtype.
+ */
+function backup_migrate_crud_subtype_info($type, $subtype) {
+ $types = backup_migrate_crud_subtypes($type);
+ if (isset($types[$subtype])) {
+ return $types[$subtype];
+ }
+ return NULL;
+}
+
/**
* Get a generic object of the given type to be used for static-like functions.
*
- * I'm not using actual static method calls since they don't work on variables prior to PHP 5.3.0
+ * I'm not using actual static method calls since they don't work on variables
+ * prior to PHP 5.3.0.
*/
-function backup_migrate_crud_type_load($type) {
- $out = NULL;
- $types = backup_migrate_crud_types();
- if (!empty($types[$type])) {
- $info = $types[$type];
- if ($info['include']) {
- backup_migrate_include($info['include']);
+function backup_migrate_crud_type_load($type, $subtype = NULL) {
+ $out = $info = NULL;
+
+ if ($subtype) {
+ $info = backup_migrate_crud_subtype_info($type, $subtype);
+ }
+ else {
+ $info = backup_migrate_crud_type_info($type);
+ }
+
+ if (!empty($info)) {
+ if (!empty($info['include'])) {
+ require_once dirname(__FILE__) . '/' . $info['include'] . '.inc';
+ }
+ if (!empty($info['file'])) {
+ require_once './' . (isset($info['path']) ? $info['path'] : '') . $info['file'];
+ }
+
+ if (class_exists($info['class'])) {
+ $out = new $info['class']();
+ $out = $out->create(array('subtype' => $subtype));
}
- $out = new $info['class'];
}
return $out;
}
+/**
+ * Page callback to create a new item.
+ */
+function backup_migrate_crud_create($type, $subtype = NULL) {
+ if ($item = backup_migrate_crud_type_load($type, $subtype)) {
+ return $item;
+ }
+ return NULL;
+}
/**
* Get the menu items handled by the CRUD code.
@@ -55,8 +133,12 @@ function backup_migrate_crud_type_load($type) {
function backup_migrate_crud_menu() {
$items = array();
foreach (backup_migrate_crud_types() as $type => $info) {
- $type = backup_migrate_crud_type_load($type);
- $items += (array)$type->get_menu_items();
+ $item = backup_migrate_crud_type_load($type);
+ $items += (array) $item->get_menu_items();
+ foreach (backup_migrate_crud_subtypes($type) as $subtype => $info) {
+ $subitem = backup_migrate_crud_type_load($type, $subtype);
+ $items += (array) $subitem->get_menu_items();
+ }
}
return $items;
}
@@ -64,47 +146,69 @@ function backup_migrate_crud_menu() {
/**
* Page callback to create a new item.
*/
-function backup_migrate_crud_ui_create() {
- if ($type = backup_migrate_crud_type_load(arg(BACKUP_MIGRATE_MENU_DEPTH))) {
- $item = $type->create(array());
+function backup_migrate_crud_ui_create($type, $subtype = NULL) {
+ if ($item = backup_migrate_crud_create($type, $subtype)) {
return drupal_get_form('backup_migrate_crud_edit_form', $item);
}
+ return drupal_not_found();
}
/**
* Page callback to list all items.
*/
-function backup_migrate_crud_ui_list() {
+function backup_migrate_crud_ui_list($type) {
$out = '';
- if ($type = backup_migrate_crud_type_load(arg(BACKUP_MIGRATE_MENU_DEPTH))) {
+ if ($type = backup_migrate_crud_type_load($type)) {
$out = $type->get_list();
}
return $out;
}
+/**
+ * Page callback to list all items.
+ */
+function backup_migrate_crud_ui_list_all() {
+ $out = array();
+ foreach (backup_migrate_crud_types() as $type => $info) {
+ $type = backup_migrate_crud_type_load($type);
+ $out[] = theme('backup_migrate_group', array('title' => t($type->title_plural), 'body' => $type->get_list()));
+ }
+ return implode('', $out);
+}
+
/**
* Page callback to edit an item.
*/
-function backup_migrate_crud_ui_edit($item_id = NULL) {
- if ($type = backup_migrate_crud_type_load(arg(BACKUP_MIGRATE_MENU_DEPTH))) {
+function backup_migrate_crud_ui_edit($type, $item_id = NULL) {
+ if ($type = backup_migrate_crud_type_load($type)) {
if ($item_id && $item = $type->item($item_id)) {
return drupal_get_form('backup_migrate_crud_edit_form', $item);
}
- drupal_goto(BACKUP_MIGRATE_MENU_PATH. '/' . arg(BACKUP_MIGRATE_MENU_DEPTH));
+ drupal_goto($type->get_settings_path());
}
}
+/**
+ * Does a crud item with the given name exist.
+ *
+ * Callback for the 'machine_name' form type.
+ */
+function backup_migrate_crud_item_exists($machine_name, $element, $form_state) {
+ return $form_state['values']['item']->item_exists($machine_name);
+}
+
/**
* A form callback to edit an item.
*/
function backup_migrate_crud_edit_form($form, $form_state, $item) {
$form = $item->edit_form();
- $form['item'] = array(
+
+ $form['item'] = array(
'#type' => 'value',
'#value' => $item,
);
- $form['#validate'][] = 'backup_migrate_crud_edit_form_validate';
- $form['#submit'][] = 'backup_migrate_crud_edit_form_submit';
+ $form['#validate'][] = 'backup_migrate_crud_edit_form_validate';
+ $form['#submit'][] = 'backup_migrate_crud_edit_form_submit';
return $form;
}
@@ -122,22 +226,22 @@ function backup_migrate_crud_edit_form_validate($form, &$form_state) {
*/
function backup_migrate_crud_edit_form_submit($form, &$form_state) {
$item = $form_state['values']['item'];
+
$item->edit_form_submit($form, $form_state);
if (empty($form_state['redirect'])) {
- $form_state['redirect'] = BACKUP_MIGRATE_MENU_PATH . '/'. $item->type_name;
+ $form_state['redirect'] = $item->get_settings_path();
}
}
-
/**
* Page callback to delete an item.
*/
-function backup_migrate_crud_ui_delete($item_id = NULL) {
- if ($type = backup_migrate_crud_type_load(arg(BACKUP_MIGRATE_MENU_DEPTH))) {
+function backup_migrate_crud_ui_delete($type, $item_id = NULL) {
+ if ($type = backup_migrate_crud_type_load($type)) {
if ($item_id && $item = $type->item($item_id)) {
return drupal_get_form('backup_migrate_crud_delete_confirm_form', $item);
}
- drupal_goto('admin/content/backup_migrate/'. arg(BACKUP_MIGRATE_MENU_DEPTH));
+ drupal_goto($type->get_settings_path());
}
}
@@ -149,8 +253,14 @@ function backup_migrate_crud_delete_confirm_form($form, &$form_state, $item) {
'#type' => 'value',
'#value' => $item,
);
- $message = $item->delete_confirm_message();
- return confirm_form($form, t('Are you sure?'), BACKUP_MIGRATE_MENU_PATH . '/'. $item->type_name, $message, t('Delete'), t('Cancel'));
+ if ($item->storage == BACKUP_MIGRATE_STORAGE_OVERRIDEN) {
+ $message = $item->revert_confirm_message();
+ return confirm_form($form, t('Are you sure?'), $item->get_settings_path(), $message, t('Revert'), t('Cancel'));
+ }
+ else {
+ $message = $item->delete_confirm_message();
+ return confirm_form($form, t('Are you sure?'), $item->get_settings_path(), $message, t('Delete'), t('Cancel'));
+ }
}
/**
@@ -161,18 +271,18 @@ function backup_migrate_crud_delete_confirm_form_submit($form, &$form_state) {
$item = $form_state['values']['item'];
$item->delete();
}
- $form_state['redirect'] = BACKUP_MIGRATE_MENU_PATH . "/". $item->type_name;
+ $form_state['redirect'] = $item->get_settings_path();
}
/**
* Export an item.
*/
-function backup_migrate_crud_ui_export($item_id = NULL) {
- if ($type = backup_migrate_crud_type_load(arg(BACKUP_MIGRATE_MENU_DEPTH))) {
+function backup_migrate_crud_ui_export($type, $item_id = NULL) {
+ if ($type = backup_migrate_crud_type_load($type)) {
if ($item_id && $item = $type->item($item_id)) {
return drupal_get_form('backup_migrate_crud_export_form', $item->export());
}
- drupal_goto(BACKUP_MIGRATE_MENU_PATH . '/' . arg(BACKUP_MIGRATE_MENU_DEPTH));
+ drupal_goto($type->get_settings_path());
}
}
@@ -189,6 +299,72 @@ function backup_migrate_crud_export_form($form, &$form_state, $export) {
return $form;
}
+/**
+ * Page callback to import an item.
+ */
+function backup_migrate_crud_ui_import() {
+ return drupal_get_form('backup_migrate_crud_import_form');
+}
+
+/**
+ * Ask confirmation for deletion of a item.
+ */
+function backup_migrate_crud_import_form($form, &$form_state) {
+ $form['code'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Paste Exported Code Here'),
+ '#required' => TRUE,
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Import'),
+ );
+ return $form;
+}
+
+/**
+ * Validate handler to import a view.
+ */
+function backup_migrate_crud_import_form_validate($form, &$form_state) {
+ $item = backup_migrate_crud_create_from_import($form_state['values']['code']);
+ if ($item) {
+ $form_state['values']['item'] = $item;
+ }
+ else {
+ form_set_error('code', t('Unable to import item.'));
+ }
+}
+
+/**
+ * Import a item after confirmation.
+ */
+function backup_migrate_crud_import_form_submit($form, &$form_state) {
+ $item = $form_state['values']['item'];
+ $item->save();
+ _backup_migrate_message('Your !type was imported', array('!type' => t($item->singular)));
+ $form_state['redirect'] = $item->get_settings_path();
+}
+
+/**
+ * Create an object from the exported object.
+ */
+function backup_migrate_crud_create_from_import($code) {
+ $item = NULL;
+ $code = 'return ' . $code . ';';
+ ob_start();
+ $values = eval($code);
+ ob_end_clean();
+
+ if ($values) {
+ if (!empty($values['type_name']) && $type = backup_migrate_crud_type_load($values['type_name'])) {
+ $item = $type->create($values);
+ // Make sure the item's ID doesn't already exist.
+ $item->unique_id();
+ }
+ }
+ return $item;
+}
+
/**
* Get all items of the given type.
*/
@@ -198,7 +374,6 @@ function backup_migrate_crud_get_items($type) {
}
}
-
/**
* Get an item of the specified type.
*/
@@ -218,57 +393,98 @@ function backup_migrate_crud_create_item($type, $params) {
}
/**
- * A base class for items which can be stored in the database, listed, edited, deleted etc.
+ * A base class for items which can be stored in the database.
*/
class backup_migrate_item {
- var $db_table = '';
- var $type_name = '';
- var $storage = FALSE;
- var $default_values = array();
- var $singular = 'item';
- var $plural = 'items';
+ public $show_in_list = TRUE;
+ public $settings_path = '/settings/';
+ public $db_table = '';
+ public $type_name = '';
+ public $storage = FALSE;
+ public $default_values = array();
+ public $singular = 'item';
+ public $plural = 'items';
+ public $title_plural = 'Items';
+ public $title_singular = 'Item';
/**
- * Constructor, set the basic info pulled from the db or generated programatically.
+ * This function is not supposed to be called.
+ *
+ * It is just here to help the po extractor out.
*/
- function __construct($params = array()) {
- $this->from_array((array)$params + (array)$this->get_default_values());
+ public function strings() {
+ // Help the pot extractor find these strings.
+ t('item');
+ t('items');
+ t('Items');
+ t('Item');
+
+ // Help the pot extractor find these strings.
+ t('List !type');
+ t('Create !type');
+ t('Delete !type');
+ t('Edit !type');
+ t('Export !type');
+ }
+
+ /**
+ * Set the basic info pulled from the db or generated programatically.
+ */
+ public function __construct($params = array()) {
+ $this->from_array($this->_merge_defaults((array) $params, (array) $this->get_default_values()));
+ }
+
+ /**
+ * Merge parameters with the given defaults.
+ *
+ * Works like array_merge_recursive, but it doesn't turn scalar values into
+ * arrays.
+ */
+ public function _merge_defaults($params, $defaults) {
+ foreach ($defaults as $key => $val) {
+ if (!isset($params[$key])) {
+ $params[$key] = $val;
+ }
+ elseif (is_array($params[$key])) {
+ $params[$key] = $this->_merge_defaults($params[$key], $val);
+ }
+ }
+ return $params;
}
/**
* Get the default values for standard parameters.
*/
- function get_default_values() {
+ public function get_default_values() {
return $this->default_values;
}
/**
* Save the item to the database.
- */
- function save() {
+ */
+ public function save() {
if (!$this->get_id()) {
- $this->generate_id();
+ $this->unique_id();
}
- $data = $this->to_array();
- drupal_write_record($this->db_table, $data, !empty($this->storage) ? $this->get_primary_key() : array());
+ $record = $this->to_array();
+ drupal_write_record($this->db_table, $record, !empty($this->storage) ? $this->get_primary_key() : array());
}
/**
* Delete the item from the database.
- */
- function delete() {
- $keys = (array)$this->get_primary_key();
+ */
+ public function delete() {
+ $keys = (array) $this->get_machine_name_field();
db_query('DELETE FROM {' . $this->db_table . '} WHERE ' . $keys[0] . ' = :id', array(':id' => $this->get_id()));
}
-
/**
* Load an existing item from an array.
*/
- function from_array($params) {
+ public function from_array($params) {
foreach ($params as $key => $value) {
- if (method_exists($this, 'set_'. $key)) {
- $this->{'set_'. $key}($value);
+ if (method_exists($this, 'set_' . $key)) {
+ $this->{'set_' . $key}($value);
}
else {
$this->{$key} = $value;
@@ -279,7 +495,7 @@ class backup_migrate_item {
/**
* Return as an array of values.
*/
- function to_array() {
+ public function to_array() {
$out = array();
// Return fields as specified in the schema.
$schema = $this->get_schema();
@@ -294,8 +510,10 @@ class backup_migrate_item {
/**
* Return as an exported array of values.
*/
- function export() {
+ public function export() {
$out = $this->to_array();
+ $out['type_name'] = $this->type_name;
+
ob_start();
var_export($out);
$out = ob_get_contents();
@@ -306,7 +524,7 @@ class backup_migrate_item {
/**
* Load an existing item from an database (serialized) array.
*/
- function load_row($data) {
+ public function load_row($data) {
$params = array();
$schema = $this->get_schema();
// Load fields as specified in the schema.
@@ -316,11 +534,10 @@ class backup_migrate_item {
$this->from_array($params);
}
-
/**
* Decode a loaded db row (unserialize necessary fields).
*/
- function decode_db_row($data) {
+ public function decode_db_row($data) {
$params = array();
$schema = $this->get_schema();
// Load fields as specified in the schema.
@@ -333,7 +550,7 @@ class backup_migrate_item {
/**
* Return the fields which must be serialized before saving to the db.
*/
- function get_serialized_fields() {
+ public function get_serialized_fields() {
$out = array();
$schema = $this->get_schema();
foreach ($schema['fields'] as $field => $info) {
@@ -347,15 +564,26 @@ class backup_migrate_item {
/**
* Get the primary key field title from the schema.
*/
- function get_primary_key() {
+ public function get_primary_key() {
$schema = $this->get_schema();
return @$schema['primary key'];
}
+ /**
+ * Get the machine name field name from the schema.
+ */
+ public function get_machine_name_field() {
+ $schema = $this->get_schema();
+ if (isset($schema['export']['key'])) {
+ return $schema['export']['key'];
+ }
+ return @$schema['primary key'];
+ }
+
/**
* Get the schema for the item type.
*/
- function get_schema() {
+ public function get_schema() {
return drupal_get_schema($this->db_table);
}
@@ -364,16 +592,16 @@ class backup_migrate_item {
*
* We only handle single field keys since that's all we need.
*/
- function get_id() {
- $keys = (array)$this->get_primary_key();
- return !empty($this->{$keys[0]}) ? (string)$this->{$keys[0]} : '';
+ public function get_id() {
+ $keys = (array) $this->get_machine_name_field();
+ return !empty($keys[0]) && !empty($this->{$keys[0]}) ? (string) $this->{$keys[0]} : '';
}
/**
* Set the primary id for this item (if any is set).
*/
- function set_id($id) {
- $keys = (array)$this->get_primary_key();
+ public function set_id($id) {
+ $keys = (array) $this->get_machine_name_field();
if (!empty($keys[0])) {
return $this->{$keys[0]} = $id;
}
@@ -383,65 +611,97 @@ class backup_migrate_item {
/**
* Return a random (very very likely unique) string id for a new item.
*/
- function generate_id() {
- $this->set_id(md5(uniqid(mt_rand(), true)));
+ public function generate_id() {
+ $id = md5(uniqid(mt_rand(), TRUE));
+
+ // Find the shortest possible unique id from (min 4 chars).
+ for ($i = 4; $i < 32; $i++) {
+ $new_id = substr($id, 0, $i);
+ if (!$this->item($new_id)) {
+ return $new_id;
+ }
+ }
+ // If we get here, then all 28 increasingly complex ids were already taken
+ // so we'll try again; this could theoretially lead to an infinite loop,
+ // but the odds are incredibly low.
+ return $this->generate_id();
+ }
+
+ /**
+ * Make sure this item has a unique id.
+ *
+ * Should only be called for new items or the item will collide with itself.
+ */
+ public function unique_id() {
+ $id = $this->get_id();
+
+ // Unset the autoincrement field so it can be regenerated.
+ foreach ((array) $this->get_primary_key() as $key) {
+ $this->{$key} = NULL;
+ }
+
+ // If the item doesn't have an ID or if it's id is already taken, generate
+ // random one.
+ if (!$id || $this->item($id)) {
+ $this->set_id($this->generate_id());
+ }
}
/**
* Get the name of the item.
*/
- function get_name() {
+ public function get_name() {
return @$this->name;
}
/**
* Get the member with the given key.
- */
- function get($key) {
- if (method_exists($this, 'get_'. $key)) {
- return $this->{'get_'. $key}();
+ */
+ public function get($key) {
+ if (method_exists($this, 'get_' . $key)) {
+ return $this->{'get_' . $key}();
}
return @$this->{$key};
}
- /* UI Stuff */
-
/**
* Get the action links for a destination.
*/
- function get_action_links() {
- $out = array('edit' => '', 'delete' => '');
+ public function get_action_links() {
+ $out = array();
$item_id = $this->get_id();
+ $path = $this->get_settings_path();
+
if (@$this->storage == BACKUP_MIGRATE_STORAGE_DB || @$this->storage == BACKUP_MIGRATE_STORAGE_OVERRIDEN) {
- $out['edit'] = l(t("edit"), BACKUP_MIGRATE_MENU_PATH . "/$this->type_name/list/edit/$item_id");
+ $out['edit'] = l(t("edit"), $path . "/edit/$item_id");
}
- else if (@$this->storage == BACKUP_MIGRATE_STORAGE_NONE) {
- $out['edit'] = l(t("override"), BACKUP_MIGRATE_MENU_PATH . "/$this->type_name/list/edit/$item_id");
+ elseif (@$this->storage == BACKUP_MIGRATE_STORAGE_NONE) {
+ $out['edit'] = l(t("override"), $path . "/edit/$item_id");
}
if (@$this->storage == BACKUP_MIGRATE_STORAGE_DB) {
- $out['delete'] = l(t("delete"), BACKUP_MIGRATE_MENU_PATH . "/$this->type_name/list/delete/$item_id");
+ $out['delete'] = l(t("delete"), $path . "/delete/$item_id");
}
- else if (@$this->storage == BACKUP_MIGRATE_STORAGE_OVERRIDEN) {
- $out['delete'] = l(t("revert"), BACKUP_MIGRATE_MENU_PATH . "/$this->type_name/list/delete/$item_id");
+ elseif (@$this->storage == BACKUP_MIGRATE_STORAGE_OVERRIDEN) {
+ $out['delete'] = l(t("revert"), $path . "/delete/$item_id");
}
-
- // Export link disabled until we have an import function.
- //$out['export'] = l(t("export"), BACKUP_MIGRATE_MENU_PATH . "/$this->type_name/list/export/$item_id");
+ $out['export'] = l(t("export"), $path . "/export/$item_id");
return $out;
}
/**
* Get a table of all items of this type.
- */
- function get_list() {
+ */
+ public function get_list() {
$items = $this->all_items();
$rows = array();
- foreach ($items as $item) {
- if ($row = $item->get_list_row()) {
- $rows[] = $row;
+ foreach ((array) $items as $item) {
+ if ($item->show_in_list()) {
+ if ($row = $item->get_list_row()) {
+ $rows[] = $row;
+ }
}
}
if (count($rows)) {
@@ -450,13 +710,30 @@ class backup_migrate_item {
else {
$out = t('There are no !items to display.', array('!items' => $this->plural));
}
+ if (user_access('administer backup and migrate')) {
+ $out .= ' ' . l(t('Create a new !item', array('!item' => $this->singular)), $this->get_settings_path() . '/add');
+ }
return $out;
}
/**
* Get the columns needed to list the type.
- */
- function get_list_column_info() {
+ */
+ public function show_in_list() {
+ return $this->show_in_list;
+ }
+
+ /**
+ * Get the columns needed to list the type.
+ */
+ public function get_settings_path() {
+ return BACKUP_MIGRATE_MENU_PATH . $this->settings_path . $this->type_name;
+ }
+
+ /**
+ * Get the columns needed to list the type.
+ */
+ public function get_list_column_info() {
return array(
'actions' => array('title' => t('Operations'), 'html' => TRUE),
);
@@ -464,8 +741,8 @@ class backup_migrate_item {
/**
* Get header for a lost of this type.
- */
- function get_list_header() {
+ */
+ public function get_list_header() {
$out = array();
foreach ($this->get_list_column_info() as $key => $col) {
$out[] = $col['title'];
@@ -475,11 +752,14 @@ class backup_migrate_item {
/**
* Get a row of data to be used in a list of items of this type.
- */
- function get_list_row() {
+ */
+ public function get_list_row() {
$out = array();
foreach ($this->get_list_column_info() as $key => $col) {
$out[$key] = empty($col['html']) ? check_plain($this->get($key)) : $this->get($key);
+ if (isset($col['class'])) {
+ $out[$key] = array('data' => $out[$key], 'class' => $col['class']);
+ }
}
return $out;
}
@@ -487,7 +767,7 @@ class backup_migrate_item {
/**
* Get the rendered action links for a destination.
*/
- function get_actions() {
+ public function get_actions() {
$links = $this->get_action_links();
return implode(" ", $links);
}
@@ -495,118 +775,133 @@ class backup_migrate_item {
/**
* Get the edit form for the item.
*/
- function edit_form() {
+ public function edit_form() {
$form = array();
$form['item'] = array(
'#type' => 'value',
'#value' => $this,
);
+ $name = $this->get('name');
+ $form['name'] = array(
+ "#type" => "textfield",
+ "#title" => t("!type name", array('!type' => $this->title_singular)),
+ "#default_value" => empty($name) ? t('Untitled !type', array('!type' => $this->title_singular)) : $name,
+ "#required" => TRUE,
+ );
$form['id'] = array(
'#type' => 'value',
'#value' => $this->get_id(),
);
+
+ $form['machine_name'] = array(
+ '#type' => 'machine_name',
+ '#default_value' => $this->get_id(),
+ '#maxlength' => 255,
+ '#machine_name' => array(
+ 'source' => array('name'),
+ 'exists' => 'backup_migrate_crud_item_exists',
+ ),
+ );
+
$form['actions'] = array('#prefix' => '
', '#suffix' => '
', '#weight' => 99);
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save !type', array('!type' => t($this->singular))));
- $form['actions']['cancel'] = array('#markup' => l(t('Cancel'), BACKUP_MIGRATE_MENU_PATH . '/destination'));
+ $form['actions']['cancel'] = array('#value' => l(t('Cancel'), $this->get_settings_path()));
return $form;
}
/**
* Validate the edit form for the item.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
}
/**
* Submit the edit form for the item.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
$this->from_array($form_state['values']);
$this->save();
- _backup_migrate_message('!type saved', array('!type' => t(ucwords($this->singular))));
+ _backup_migrate_message('Your !type was saved', array('!type' => t($this->singular)));
}
/**
- * Get the message to send to the user when confirming the deletion of the item.
+ * The message to send to the user when confirming the deletion of the item.
*/
- function delete_confirm_message() {
- return t('Are you sure you want to delete this !type?', array('!type' => t($item->singular)));
+ public function delete_confirm_message() {
+ return t('Are you sure you want to delete the !type %name?', array('!type' => t($this->singular), '%name' => $this->get('name')));
}
- /* Static Functions */
-
- /**
- * This function is not supposed to be called. It is just here to help the po extractor out.
+ /**
+ * The message to send to the user when confirming the deletion of the item.
*/
- function strings() {
- // Help the pot extractor find these strings.
- t('List !type');
- t('Create !type');
- t('Delete !type');
- t('Edit !type');
- t('Export !type');
+ public function revert_confirm_message() {
+ return t('Are you sure you want to revert the !type %name back to the default settings?', array('!type' => t($this->singular), '%name' => $this->get('name')));
}
/**
* Get the menu items for manipulating this type.
*/
- function get_menu_items() {
+ public function get_menu_items() {
+ $path = $this->get_settings_path();
+
$type = $this->type_name;
- $items[BACKUP_MIGRATE_MENU_PATH . '/' . $type] = array(
- 'title' => ucwords($this->plural),
+ $items[$path] = array(
+ 'title' => $this->title_plural,
'page callback' => 'backup_migrate_menu_callback',
- 'page arguments' => array('crud', 'backup_migrate_crud_ui_list', TRUE),
+ 'page arguments' => array('crud', 'backup_migrate_crud_ui_list', TRUE, $this->type_name),
'access arguments' => array('administer backup and migrate'),
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
- $items[BACKUP_MIGRATE_MENU_PATH . '/' . $type .'/list'] = array(
+ $items[$path . '/list'] = array(
'title' => 'List !type',
- 'title arguments' => array('!type' => t(ucwords($this->plural))),
+ 'title arguments' => array('!type' => t($this->title_plural)),
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
- $items[BACKUP_MIGRATE_MENU_PATH . '/' . $type .'/list/add'] = array(
+ $items[$path . '/add'] = array(
'title' => 'Add !type',
- 'title arguments' => array('!type' => t(ucwords($this->singular))),
+ 'title arguments' => array('!type' => t($this->title_singular)),
'page callback' => 'backup_migrate_menu_callback',
- 'page arguments' => array('crud', 'backup_migrate_crud_ui_create', TRUE),
+ 'page arguments' => array('crud', 'backup_migrate_crud_ui_create', TRUE, $this->type_name),
'access arguments' => array('administer backup and migrate'),
'weight' => 2,
'type' => MENU_LOCAL_ACTION,
);
- $items[BACKUP_MIGRATE_MENU_PATH . '/' . $type .'/list/delete'] = array(
+ $items[$path . '/delete'] = array(
'title' => 'Delete !type',
- 'title arguments' => array('!type' => t(ucwords($this->singular))),
+ 'title arguments' => array('!type' => t($this->title_singular)),
'page callback' => 'backup_migrate_menu_callback',
- 'page arguments' => array('crud', 'backup_migrate_crud_ui_delete', TRUE),
+ 'page arguments' => array('crud', 'backup_migrate_crud_ui_delete', TRUE, $this->type_name),
'access arguments' => array('administer backup and migrate'),
'type' => MENU_CALLBACK,
);
- $items[BACKUP_MIGRATE_MENU_PATH . '/' . $type .'/list/edit'] = array(
+ $items[$path . '/edit'] = array(
'title' => 'Edit !type',
- 'title arguments' => array('!type' => t(ucwords($this->singular))),
+ 'title arguments' => array('!type' => t($this->title_singular)),
'page callback' => 'backup_migrate_menu_callback',
- 'page arguments' => array('crud', 'backup_migrate_crud_ui_edit', TRUE),
+ 'page arguments' => array('crud', 'backup_migrate_crud_ui_edit', TRUE, $this->type_name),
'access arguments' => array('administer backup and migrate'),
'type' => MENU_CALLBACK,
);
- $items[BACKUP_MIGRATE_MENU_PATH . '/' . $type .'/list/export'] = array(
+ $items[$path . '/export'] = array(
'title' => 'Export !type',
- 'title arguments' => array('!type' => t(ucwords($this->singular))),
+ 'title arguments' => array('!type' => t($this->title_singular)),
'page callback' => 'backup_migrate_menu_callback',
- 'page arguments' => array('crud', 'backup_migrate_crud_ui_export', TRUE),
+ 'page arguments' => array('crud', 'backup_migrate_crud_ui_export', TRUE, $this->type_name),
'access arguments' => array('administer backup and migrate'),
'type' => MENU_CALLBACK,
);
return $items;
}
-
/**
- * Create a new items with the given input. Doesn't load the parameters, but could use them to determine what type to create.
+ * Create a new items with the given input.
+ *
+ * Doesn't load the parameters, but could use them to determine what type to
+ * create.
*/
- function create($params = array()) {
+ public function create($params = array()) {
$type = get_class($this);
return new $type($params);
}
@@ -614,14 +909,12 @@ class backup_migrate_item {
/**
* Get all of the given items.
*/
- function all_items() {
- static $cache = array();
+ public function all_items() {
+ $items = array();
- // Allow other modules to declare destinations programatically.
- $items = module_invoke_all($this->db_table);
-
- // Get any items stored as a variable. This allows destinations to be defined in settings.php
- $defaults = (array)variable_get($this->db_table .'_defaults', array());
+ // Get any items stored as a variable. This allows destinations to be
+ // defined in settings.php.
+ $defaults = (array) variable_get($this->db_table . '_defaults', array());
foreach ($defaults as $info) {
if (is_array($info) && $item = $this->create($info)) {
$items[$item->get_id()] = $item;
@@ -638,9 +931,53 @@ class backup_migrate_item {
}
}
- // Allow other modules to alter the items. This should maybe be before the db override code above
- // but then the filters are not able to set defaults for missing values. Other modules should just
- // be careful not to overwrite the user's UI changes in an unexpected way.
+ // Allow other modules to declare destinations programatically.
+ $default_items = module_invoke_all($this->db_table);
+
+ // Get CTools exported versions.
+ if (function_exists('ctools_include')) {
+ ctools_include('export');
+ $defaults = ctools_export_load_object($this->db_table);
+ foreach ($defaults as $info) {
+ $info = (array) $info;
+ if (!empty($info) && $item = $this->create($info)) {
+ // If this item is not already in $default_items,
+ // set flag to indicate it's only there because of ctools export.
+ if (empty($default_items[$item->get_id()])) {
+ $item->settings['ctools_export'] = TRUE;
+ }
+ $default_items[$item->get_id()] = $item;
+ }
+ }
+ }
+
+ // Get any items stored as a variable again to correctly mark overrides.
+ $defaults = (array) variable_get($this->db_table . '_defaults', array());
+ foreach ($defaults as $info) {
+ if (is_array($info) && $item = $this->create($info)) {
+ $default_items[] = $item;
+ }
+ }
+
+ // Add the default items to the array or set the storage flag if they've
+ // already been overridden.
+ foreach ($default_items as $item) {
+ if (isset($items[$item->get_id()])) {
+ // Items added by ctools export are not overrides.
+ if (empty($item->settings['ctools_export'])) {
+ $items[$item->get_id()]->storage = BACKUP_MIGRATE_STORAGE_OVERRIDEN;
+ }
+ }
+ else {
+ $item->storage = BACKUP_MIGRATE_STORAGE_NONE;
+ $items[$item->get_id()] = $item;
+ }
+ }
+
+ // Allow other modules to alter the items. This should maybe be before the
+ // db override code above but then the filters are not able to set defaults
+ // for missing values. Other modules should just be careful not to
+ // overwrite the user's UI changes in an unexpected way.
drupal_alter($this->db_table, $items);
return $items;
@@ -649,8 +986,17 @@ class backup_migrate_item {
/**
* A particular item.
*/
- function item($item_id) {
+ public function item($item_id) {
$items = $this->all_items();
return !empty($items[$item_id]) ? $items[$item_id] : NULL;
}
-}
\ No newline at end of file
+
+ /**
+ * A particular item.
+ */
+ public function item_exists($item_id) {
+ $items = $this->all_items();
+ return !empty($items[$item_id]);
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.browser.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.browser.inc
index a33be2a..63ddf21 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.browser.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.browser.inc
@@ -1,6 +1,5 @@
$file->uri));
backup_migrate_temp_files_add($file->uri);
@@ -47,6 +55,7 @@ class backup_migrate_destination_browser_upload extends backup_migrate_destinati
}
return NULL;
}
+
}
/**
@@ -55,20 +64,35 @@ class backup_migrate_destination_browser_upload extends backup_migrate_destinati
* @ingroup backup_migrate_destinations
*/
class backup_migrate_destination_browser_download extends backup_migrate_destination_browser {
- var $supported_ops = array('manual backup');
- function __construct() {
+
+ /**
+ * {@inheritdoc}
+ */
+ public $supported_ops = array('manual backup');
+
+ /**
+ * Browser downloads must always be the last destination as they must end the
+ * current process when they are done.
+ */
+ public $weight = 1000;
+
+ /**
+ * Constructor.
+ */
+ public function __construct() {
$params = array();
$params['name'] = "Download";
- $params['destination_id'] = 'download';
+ $params['machine_name'] = 'download';
parent::__construct($params);
}
/**
* File save destination callback.
*/
- function save_file($file, $settings) {
- backup_migrate_include('files');
+ public function save_file($file, $settings) {
+ require_once dirname(__FILE__) . '/files.inc';
+
$file->transfer();
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.inc
index 27d947b..0412404 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.inc
@@ -1,6 +1,5 @@
set_source($this->get_id());
@@ -40,10 +41,10 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Destination configuration callback.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['scheme']['#title'] = t('Database type');
-// $form['scheme']['#options'] = array($GLOBALS['db_type'] => $GLOBALS['db_type']);
+ // $form['scheme']['#options'] = array($GLOBALS['db_type'] => $GLOBALS['db_type']);
$form['scheme']['#description'] = t('The type of the database. Drupal only supports one database type at a time, so this must be the same as the current database type.');
$form['path']['#title'] = t('Database name');
$form['path']['#description'] = t('The name of the database. The database must exist, it will not be created for you.');
@@ -54,7 +55,7 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Validate the configuration form. Make sure the db info is valid.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
if (!preg_match('/[a-zA-Z0-9_\$]+/', $form_state['values']['path'])) {
form_set_error('path', t('The database name is not valid.'));
}
@@ -62,66 +63,74 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
}
/**
- * Get the form for the settings for this destination.
+ * Get the default settings for this object.
*
- * Return the default tables whose data can be ignored. These tables mostly contain
- * info which can be easily reproducted (such as cache or search index)
- * but also tables which can become quite bloated but are not necessarily extremely
- * important to back up or migrate during development (such ass access log and watchdog)
+ * @return array
+ * The default tables whose data can be ignored. These tables mostly
+ * contain info which can be easily reproducted (such as cache or search
+ * index) but also tables which can become quite bloated but are not
+ * necessarily extremely important to back up or migrate during development
+ * (such as access log and watchdog).
*/
- function backup_settings_default() {
- $core = array(
- 'cache',
- 'cache_admin_menu',
- 'cache_browscap',
- 'cache_content',
- 'cache_filter',
- 'cache_calendar_ical',
- 'cache_location',
- 'cache_menu',
- 'cache_page',
- 'cache_reptag',
- 'cache_views',
- 'cache_views_data',
- 'cache_block',
- 'cache_update',
- 'cache_form',
- 'cache_bootstrap',
- 'cache_field',
- 'cache_image',
- 'cache_path',
- 'sessions',
- 'search_dataset',
- 'search_index',
- 'search_keywords_log',
- 'search_total',
- 'watchdog',
- 'accesslog',
- 'devel_queries',
- 'devel_times',
- );
- $nodata_tables = array_merge($core, module_invoke_all('devel_caches'));
- return array(
- 'nodata_tables' => $nodata_tables,
- 'exclude_tables' => array(),
+ public function backup_settings_default() {
+ $all_tables = $this->_get_table_names();
+
+ // Basic modules that should be excluded.
+ $basic = array(
+ // Default core tables.
+ 'accesslog',
+ 'sessions',
+ 'watchdog',
+ // Search module.
+ 'search_dataset',
+ 'search_index',
+ 'search_keywords_log',
+ 'search_total',
+ // Devel module.
+ 'devel_queries',
+ 'devel_times',
+ );
+
+ // Identify all cache tables.
+ $cache = array('cache');
+ foreach ($all_tables as $table_name) {
+ if (strpos($table_name, 'cache_') === 0) {
+ $cache[] = $table_name;
+ }
+ }
+
+ // Simpletest can create a lot of tables that do not need to be backed up,
+ // but all of them start with the string 'simpletest' so they can be easily
+ // excluded.
+ $simpletest = array();
+ foreach ($all_tables as $table_name) {
+ if (strpos($table_name, 'simpletest') === 0) {
+ $simpletest[] = $table_name;
+ }
+ }
+
+ return array(
+ 'nodata_tables' => array_merge($basic, $cache, module_invoke_all('devel_caches')),
+ 'exclude_tables' => $simpletest,
'utils_lock_tables' => FALSE,
- );
+ );
}
/**
* Get the form for the backup settings for this destination.
*/
- function backup_settings_form($settings) {
- $tables = $this->get_table_names();
+ public function backup_settings_form($settings) {
+ $objects = $this->get_object_names();
$form['#description'] = t("You may omit specific tables, or specific table data from the backup file. Only omit data that you know you will not need such as cache data, or tables from other applications. Excluding tables can break your Drupal install, so do not change these settings unless you know what you're doing.");
$form['exclude_tables'] = array(
"#type" => "select",
"#multiple" => TRUE,
"#title" => t("Exclude the following tables altogether"),
- "#options" => $tables,
+ "#options" => $objects,
"#default_value" => $settings['exclude_tables'],
"#description" => t("The selected tables will not be added to the backup file."),
);
+ $tables = $this->get_table_names();
$form['nodata_tables'] = array(
"#type" => "select",
"#multiple" => TRUE,
@@ -142,16 +151,15 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Backup from this source.
*/
- function backup_to_file($file, $settings) {
+ public function backup_to_file($file, $settings) {
$file->push_type($this->get_file_type_id());
backup_migrate_filters_invoke_all('pre_backup', $this, $file, $settings);
- //$this->lock_tables($settings);
-
+ // $this->lock_tables($settings);
// Switch to a different db if specified.
$success = $this->_backup_db_to_file($file, $settings);
- //$this->unlock_tables($settings);
+ // $this->unlock_tables($settings);
backup_migrate_filters_invoke_all('post_backup', $this, $file, $settings, $success);
return $success ? $file : FALSE;
@@ -160,7 +168,7 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Restore to this source.
*/
- function restore_from_file($file, &$settings) {
+ public function restore_from_file($file, &$settings) {
$num = 0;
$type = $this->get_file_type_id();
// Open the file using the file wrapper. Check that the dump is of the right type (allow .sql for legacy reasons).
@@ -182,7 +190,7 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Get the db connection for the specified db.
*/
- function _get_db_connection() {
+ public function _get_db_connection() {
if (!$this->connection) {
$target = $key = '';
$parts = explode(':', $this->get_id());
@@ -195,13 +203,13 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
else {
// If the url is specified build it into a connection info array.
if (!empty($this->dest_url)) {
- $info = array(
- 'driver' => empty($this->dest_url['scheme']) ? NULL : $this->dest_url['scheme'],
- 'host' => empty($this->dest_url['host']) ? NULL : $this->dest_url['host'],
- 'port' => empty($this->dest_url['port']) ? NULL : $this->dest_url['port'],
- 'username' => empty($this->dest_url['user']) ? NULL : $this->dest_url['user'],
- 'password' => empty($this->dest_url['pass']) ? NULL : $this->dest_url['pass'],
- 'database' => empty($this->dest_url['path']) ? NULL : $this->dest_url['path'],
+ $info = array(
+ 'driver' => empty($this->dest_url['scheme']) ? NULL : $this->dest_url['scheme'],
+ 'host' => empty($this->dest_url['host']) ? NULL : $this->dest_url['host'],
+ 'port' => empty($this->dest_url['port']) ? NULL : $this->dest_url['port'],
+ 'username' => empty($this->dest_url['user']) ? NULL : $this->dest_url['user'],
+ 'password' => empty($this->dest_url['pass']) ? NULL : $this->dest_url['pass'],
+ 'database' => empty($this->dest_url['path']) ? NULL : $this->dest_url['path'],
);
$key = uniqid('backup_migrate_tmp_');
$target = 'default';
@@ -222,21 +230,33 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Backup the databases to a file.
*/
- function _backup_db_to_file($file, $settings) {
+ public function _backup_db_to_file($file, $settings) {
// Must be overridden.
}
/**
* Backup the databases to a file.
*/
- function _restore_db_from_file($file, $settings) {
+ public function _restore_db_from_file($file, $settings) {
// Must be overridden.
}
+ /**
+ * Get a list of objects in the database.
+ */
+ public function get_object_names() {
+ // Must be overridden.
+ $out = $this->_get_table_names();
+ if (method_exists($this, '_get_view_names')) {
+ $out += $this->_get_view_names();
+ }
+ return $out;
+ }
+
/**
* Get a list of tables in the database.
*/
- function get_table_names() {
+ public function get_table_names() {
// Must be overridden.
$out = $this->_get_table_names();
return $out;
@@ -245,7 +265,7 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Get a list of tables in the database.
*/
- function _get_table_names() {
+ public function _get_table_names() {
// Must be overridden.
return array();
}
@@ -253,12 +273,12 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Lock the database in anticipation of a backup.
*/
- function lock_tables($settings) {
+ public function lock_tables($settings) {
if ($settings->filters['utils_lock_tables']) {
$tables = array();
foreach ($this->get_table_names() as $table) {
// There's no need to lock excluded or structure only tables because it doesn't matter if they change.
- if (empty($settings->filters['exclude_tables']) || !in_array($table, (array)$settings->filters['exclude_tables'])) {
+ if (empty($settings->filters['exclude_tables']) || !in_array($table, (array) $settings->filters['exclude_tables'])) {
$tables[] = $table;
}
}
@@ -269,14 +289,14 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Lock the list of given tables in the database.
*/
- function _lock_tables($tables) {
+ public function _lock_tables($tables) {
// Must be overridden.
}
/**
* Unlock any tables that have been locked.
*/
- function unlock_tables($settings) {
+ public function unlock_tables($settings) {
if ($settings->filters['utils_lock_tables']) {
$this->_unlock_tables();
}
@@ -285,14 +305,15 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote {
/**
* Unlock the list of given tables in the database.
*/
- function _unlock_tables($tables) {
+ public function _unlock_tables($tables) {
// Must be overridden.
}
/**
* Get the file type for to backup this destination to.
*/
- function get_file_type_id() {
+ public function get_file_type_id() {
return 'sql';
}
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.mysql.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.mysql.inc
index 019da7b..c783aff 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.mysql.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.db.mysql.inc
@@ -1,6 +1,10 @@
array(
"extension" => "sql",
@@ -41,17 +69,27 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Declare any mysql databases defined in the settings.php file as a possible destination.
*/
- function destinations() {
+ public function destinations() {
$out = array();
global $databases;
- foreach ((array)$databases as $db_key => $target) {
- foreach ((array)$target as $tgt_key => $info) {
+ foreach ((array) $databases as $db_key => $target) {
+ foreach ((array) $target as $tgt_key => $info) {
// Only mysql/mysqli supported by this destination.
$key = $db_key . ':' . $tgt_key;
if ($info['driver'] === 'mysql') {
- $url = $info['driver'] . '://' . $info['username'] . ':' . $info['password'] . '@' . $info['host'] . (isset($info['port']) ? ':' . $info['port'] : '') . '/' . $info['database'];
+ // Compile the database connection string.
+ $url = 'mysql://';
+ $url .= urlencode($info['username']) . ':' . urlencode($info['password']);
+ $url .= '@';
+ $url .= urlencode($info['host']);
+ if (!empty($info['port'])) {
+ $url .= ':' . $info['port'];
+ }
+ $url .= '/' . urlencode($info['database']);
+
if ($destination = backup_migrate_create_destination('mysql', array('url' => $url))) {
- // Treat the default database differently because it is probably the only one available.
+ // Treat the default database differently because it is probably
+ // the only one available.
if ($key == 'default:default') {
$destination->set_id('db');
$destination->set_name(t('Default Database'));
@@ -60,8 +98,8 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
$destination->remove_op('manual backup');
}
else {
- $destination->set_id('db:'. $key);
- $destination->set_name($key .": ". $destination->get_display_location());
+ $destination->set_id('db:' . $key);
+ $destination->set_name($key . ": " . $destination->get_display_location());
}
$out[$destination->get_id()] = $destination;
}
@@ -74,35 +112,34 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Get the file type for to backup this destination to.
*/
- function get_file_type_id() {
+ public function get_file_type_id() {
return 'mysql';
}
/**
* Get the form for the backup settings for this destination.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = parent::backup_settings_form($settings);
$form['use_mysqldump'] = array(
"#type" => "checkbox",
"#title" => t("Use mysqldump command"),
"#default_value" => !empty($settings['use_mysqldump']),
- "#description" => t("Use the mysqldump command line tool if available. This can be faster for large databases but will not work on all servers. EXPERIMENTAL"),
+ "#description" => t("Use the mysqldump command line tool if available. This can be faster for large databases but will not work on all servers. Also exporting SQL views is not really solid with this option. EXPERIMENTAL"),
);
return $form;
}
-
/**
* Backup the databases to a file.
*
* Returns a list of sql commands, one command per line.
* That makes it easier to import without loading the whole file into memory.
- * The files are a little harder to read, but human-readability is not a priority
+ * The files are a little harder to read, but human-readability is not a priority.
*/
- function _backup_db_to_file($file, $settings) {
+ public function _backup_db_to_file($file, $settings) {
if (!empty($settings->filters['use_mysqldump']) && $this->_backup_db_to_file_mysqldump($file, $settings)) {
return TRUE;
}
@@ -113,6 +150,8 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
if ($file->open(TRUE)) {
$file->write($this->_get_sql_file_header());
$alltables = $this->_get_tables();
+ $allviews = $this->_get_views();
+
foreach ($alltables as $table) {
if (_backup_migrate_check_timeout()) {
return FALSE;
@@ -125,6 +164,15 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
}
}
}
+ foreach ($allviews as $view) {
+ if (_backup_migrate_check_timeout()) {
+ return FALSE;
+ }
+ if ($view['name'] && !isset($exclude[$view['name']])) {
+ $file->write($this->_get_view_create_sql($view));
+ }
+
+ }
$file->write($this->_get_sql_file_footer());
$file->close();
return $lines;
@@ -134,16 +182,14 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
}
}
-
/**
* Backup the databases to a file using the mysqldump command.
*/
- function _backup_db_to_file_mysqldump($file, $settings) {
+ public function _backup_db_to_file_mysqldump($file, $settings) {
$success = FALSE;
$nodata_tables = array();
$alltables = $this->_get_tables();
-
$command = 'mysqldump --result-file=%file --opt -Q --host=%host --port=%port --user=%user --password=%pass %db';
$args = array(
'%file' => $file->filepath(),
@@ -155,17 +201,19 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
);
// Ignore the excluded and no-data tables.
+ $db = $this->dest_url['path'];
if (!empty($settings->filters['exclude_tables'])) {
- $db = $this->dest_url['path'];
- foreach ((array)$settings->filters['exclude_tables'] as $table) {
+ foreach ((array) $settings->filters['exclude_tables'] as $table) {
if (isset($alltables[$table])) {
- $command .= ' --ignore-table='. $db .'.'. $table;
+ $command .= ' --ignore-table=' . $db . '.' . $table;
}
}
- foreach ((array)$settings->filters['nodata_tables'] as $table) {
+ }
+ if (!empty($settings->filters['nodata_tables'])) {
+ foreach ((array) $settings->filters['nodata_tables'] as $table) {
if (isset($alltables[$table])) {
$nodata_tables[] = $table;
- $command .= ' --ignore-table='. $db .'.'. $table;
+ $command .= ' --ignore-table=' . $db . '.' . $table;
}
}
}
@@ -183,10 +231,19 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Backup the databases to a file.
*/
- function _restore_db_from_file($file, $settings) {
+ public function _restore_db_from_file($file, $settings) {
$num = 0;
if ($file->open() && $conn = $this->_get_db_connection()) {
+ // Optionally drop all existing tables.
+ if (!empty($settings->filters['utils_drop_all_tables'])) {
+ $all_tables = $this->_get_tables();
+ $table_names = array_map('backup_migrate_array_name_value', $all_tables);
+ $table_list = join(', ', $table_names);
+ $stmt = $conn->prepare("DROP TABLE IF EXISTS $table_list;\n");
+ $stmt->execute();
+ }
+
// Read one line at a time and run the query.
while ($line = $this->_read_sql_command_from_file($file)) {
if (_backup_migrate_check_timeout()) {
@@ -209,17 +266,16 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
return $num;
}
-
/**
* Read a multiline sql command from a file.
*
* Supports the formatting created by mysqldump, but won't handle multiline comments.
*/
- function _read_sql_command_from_file($file) {
+ public function _read_sql_command_from_file($file) {
$out = '';
while ($line = $file->read()) {
$first2 = substr($line, 0, 2);
- $first3 = substr($line, 0, 2);
+ $first3 = substr($line, 0, 3);
// Ignore single line comments. This function doesn't support multiline comments or inline comments.
if ($first2 != '--' && ($first2 != '/*' || $first3 == '/*!')) {
@@ -236,46 +292,90 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Get a list of tables in the database.
*/
- function _get_table_names() {
- $out = array();
- foreach ($this->_get_tables() as $table) {
- $out[$table['name']] = $table['name'];
+ public function _get_table_names() {
+ if (empty(static::$tableNames)) {
+ static::$tableNames = $this->query("SHOW FULL TABLES WHERE Table_Type = 'BASE TABLE'")
+ ->fetchAllKeyed(0, 0);
}
- return $out;
+
+ return static::$tableNames;
+ }
+
+ /**
+ * Get a list of views in the database.
+ */
+ public function _get_view_names() {
+ if (empty(static::$viewNames)) {
+ static::$viewNames = $this->query("SHOW FULL TABLES WHERE Table_Type = 'VIEW'")
+ ->fetchAllKeyed(0, 0);
+ }
+
+ return static::$viewNames;
}
/**
* Lock the list of given tables in the database.
*/
- function _lock_tables($tables) {
+ public function _lock_tables($tables) {
if ($tables) {
$tables_escaped = array();
foreach ($tables as $table) {
- $tables_escaped[] = '`'. db_escape_table($table) .'` WRITE';
+ $tables_escaped[] = '`' . db_escape_table($table) . '` WRITE';
}
- $this->query('LOCK TABLES '. implode(', ', $tables_escaped));
+ $this->query('LOCK TABLES ' . implode(', ', $tables_escaped));
}
}
/**
* Unlock all tables in the database.
*/
- function _unlock_tables($settings) {
+ public function _unlock_tables($settings) {
$this->query('UNLOCK TABLES');
}
+ /**
+ * Get a list of table and view data in the db.
+ */
+ protected function get_table_data() {
+ if (empty(static::$tableData)) {
+ $tables = $this->query('SHOW TABLE STATUS')
+ ->fetchAll(PDO::FETCH_ASSOC);
+
+ foreach ($tables as $table) {
+ // Lowercase the keys because between Drupal 7.12 and 7.13/14 the
+ // default query behavior was changed.
+ // See: http://drupal.org/node/1171866
+ $table = array_change_key_case($table);
+ static::$tableData[$table['name']] = $table;
+ }
+ }
+
+ return static::$tableData;
+ }
+
/**
* Get a list of tables in the db.
*/
- function _get_tables() {
+ public function _get_tables() {
$out = array();
- // get auto_increment values and names of all tables
- $tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC));
- foreach ($tables as $table) {
- // Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
- // See: http://drupal.org/node/1171866
- $table = array_change_key_case($table);
- $out[$table['name']] = $table;
+ foreach ($this->get_table_data() as $table) {
+ if (!empty($table['engine'])) {
+ $out[$table['name']] = $table;
+ }
+ }
+
+ return $out;
+ }
+
+ /**
+ * Get a list of views in the db.
+ */
+ public function _get_views() {
+ $out = array();
+ foreach ($this->get_table_data() as $table) {
+ if (empty($table['engine'])) {
+ $out[$table['name']] = $table;
+ }
}
return $out;
}
@@ -283,86 +383,124 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/**
* Get the sql for the structure of the given table.
*/
- function _get_table_structure_sql($table) {
+ public function _get_table_structure_sql($table) {
$out = "";
- $result = $this->query("SHOW CREATE TABLE `". $table['name'] ."`", array(), array('fetch' => PDO::FETCH_ASSOC));
+ $result = $this->query("SHOW CREATE TABLE `" . $table['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $create) {
// Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
// See: http://drupal.org/node/1171866
$create = array_change_key_case($create);
- $out .= "DROP TABLE IF EXISTS `". $table['name'] ."`;\n";
+ $out .= "DROP TABLE IF EXISTS `" . $table['name'] . "`;\n";
// Remove newlines and convert " to ` because PDO seems to convert those for some reason.
$out .= strtr($create['create table'], array("\n" => ' ', '"' => '`'));
if ($table['auto_increment']) {
- $out .= " AUTO_INCREMENT=". $table['auto_increment'];
+ $out .= " AUTO_INCREMENT=" . $table['auto_increment'];
}
$out .= ";\n";
}
return $out;
}
-
- /**
- * Get the sql to insert the data for a given table
- */
- function _dump_table_data_sql_to_file($file, $table) {
- $rows_per_line = variable_get('backup_migrate_data_rows_per_line', 30);
- $bytes_per_line = variable_get('backup_migrate_data_bytes_per_line', 2000);
-
- $lines = 0;
- $data = $this->query("SELECT * FROM `". $table['name'] ."`", array(), array('fetch' => PDO::FETCH_ASSOC));
- $rows = $bytes = 0;
- // Escape backslashes, PHP code, special chars
+ /**
+ * Get the sql for the structure of the given table.
+ */
+ public function _get_view_create_sql($view) {
+ $out = "";
+ // Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more permissions + troubles with the DEFINER user.
+ $sql_mode = $this->query("SELECT @@SESSION.sql_mode")->fetchField();
+ $this->query("SET sql_mode = 'ANSI'");
+ $result = $this->query("SHOW CREATE VIEW `" . $view['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
+ $this->query("SET SQL_mode = :mode", array(':mode' => $sql_mode));
+ foreach ($result as $create) {
+ $out .= "DROP VIEW IF EXISTS `" . $view['name'] . "`;\n";
+ $out .= "SET sql_mode = 'ANSI';\n";
+ $out .= strtr($create['Create View'], "\n", " ") . ";\n";
+ $out .= "SET sql_mode = '$sql_mode';\n";
+ }
+ return $out;
+ }
+
+ /**
+ * Get the sql to insert the data for a given table.
+ */
+ public function _dump_table_data_sql_to_file($file, $table) {
+ $rows_per_query = variable_get('backup_migrate_data_rows_per_query', BACKUP_MIGRATE_DATA_ROWS_PER_QUERY);
+ $rows_per_line = variable_get('backup_migrate_data_rows_per_line', BACKUP_MIGRATE_DATA_ROWS_PER_LINE);
+ $bytes_per_line = variable_get('backup_migrate_data_bytes_per_line', BACKUP_MIGRATE_DATA_BYTES_PER_LINE);
+
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Table: %table', array('%table' => $table['name']), 'success');
+ }
+
+ // Escape backslashes, PHP code, special chars.
$search = array('\\', "'", "\x00", "\x0a", "\x0d", "\x1a");
$replace = array('\\\\', "''", '\0', '\n', '\r', '\Z');
-
- $line = array();
- foreach ($data as $row) {
- // DB Escape the values.
- $items = array();
- foreach ($row as $key => $value) {
- $items[] = is_null($value) ? "null" : "'". str_replace($search, $replace, $value) ."'";
+
+ $lines = 0;
+ $from = 0;
+ $args = array('fetch' => PDO::FETCH_ASSOC);
+ while ($data = $this->query("SELECT * FROM `" . $table['name'] . "`", array(), $args, $from, $rows_per_query)) {
+ if ($data->rowCount() == 0) {
+ break;
}
-
- // If there is a row to be added.
- if ($items) {
- // Start a new line if we need to.
- if ($rows == 0) {
- $file->write("INSERT INTO `". $table['name'] ."` VALUES ");
- $bytes = $rows = 0;
+
+ $rows = $bytes = 0;
+
+ $line = array();
+ foreach ($data as $row) {
+ $from++;
+
+ // DB Escape the values.
+ $items = array();
+ foreach ($row as $key => $value) {
+ $items[] = is_null($value) ? "null" : "'" . str_replace($search, $replace, $value) . "'";
}
- // Otherwise add a comma to end the previous entry.
- else {
- $file->write(",");
- }
-
- // Write the data itself.
- $sql = implode(',', $items);
- $file->write('('. $sql .')');
- $bytes += strlen($sql);
- $rows++;
-
- // Finish the last line if we've added enough items
- if ($rows >= $rows_per_line || $bytes >= $bytes_per_line) {
- $file->write(";\n");
- $lines++;
- $bytes = $rows = 0;
+
+ // If there is a row to be added.
+ if ($items) {
+ // Start a new line if we need to.
+ if ($rows == 0) {
+ $file->write("INSERT INTO `" . $table['name'] . "` VALUES ");
+ $bytes = $rows = 0;
+ }
+ // Otherwise add a comma to end the previous entry.
+ else {
+ $file->write(",");
+ }
+
+ // Write the data itself.
+ $sql = implode(',', $items);
+ $file->write('(' . $sql . ')');
+ $bytes += strlen($sql);
+ $rows++;
+
+ // Finish the last line if we've added enough items.
+ if ($rows >= $rows_per_line || $bytes >= $bytes_per_line) {
+ $file->write(";\n");
+ $lines++;
+ $bytes = $rows = 0;
+ }
}
}
+
+ // Finish any unfinished insert statements.
+ if ($rows > 0) {
+ $file->write(";\n");
+ $lines++;
+ }
}
- // Finish any unfinished insert statements.
- if ($rows > 0) {
- $file->write(";\n");
- $lines++;
+
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Peak memory usage: %mem', array('%mem' => backup_migrate_get_peak_memory_usage() . 'MB'), 'success');
}
-
+
return $lines;
}
/**
* Get the db connection for the specified db.
*/
- function _get_db_connection() {
+ public function _get_db_connection() {
if (!$this->connection) {
$this->connection = parent::_get_db_connection();
// Set the sql mode because the default is ANSI,TRADITIONAL which is not aware of collation or storage engine.
@@ -372,11 +510,34 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
}
/**
- * Run a db query on this destination's db.
+ * Run a query on this destination's database using Drupal's MySQL engine.
+ *
+ * @param string $query
+ * The query string.
+ * @param array $args
+ * Arguments for the query.
+ * @param array $options
+ * Options to pass to the query.
+ * @param int|null $from
+ * The starting point for the query; when passed will perform a queryRange()
+ * method instead of a regular query().
+ * @param int|null $count
+ * The number of records to obtain from this query. Will be ignored if the
+ * $from argument is empty.
+ *
+ * @see DatabaseConnection_mysql::query()
+ * @see DatabaseConnection_mysql::queryRange()
*/
- function query($query, $args = array(), $options = array()) {
+ public function query($query, array $args = array(), array $options = array(), $from = NULL, $count = NULL) {
if ($conn = $this->_get_db_connection()) {
- return $conn->query($query, $args, $options);
+ // If no $from is passed in, just do a basic query.
+ if (is_null($from)) {
+ return $conn->query($query, $args, $options);
+ }
+ // The $from variable was passed in, so do a ranged query.
+ else {
+ return $conn->queryRange($query, $from, $count, $args, $options);
+ }
}
}
@@ -384,7 +545,7 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
* The header for the top of the sql dump file. These commands set the connection
* character encoding to help prevent encoding conversion issues.
*/
- function _get_sql_file_header() {
+ public function _get_sql_file_header() {
return "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
@@ -392,17 +553,17 @@ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
-SET NAMES utf8;
+SET NAMES utf8mb4;
";
}
-
+
/**
* The footer of the sql dump file.
*/
- function _get_sql_file_footer() {
+ public function _get_sql_file_footer() {
return "
-
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
@@ -411,5 +572,5 @@ SET NAMES utf8;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
";
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.email.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.email.inc
index 826c427..fd93405 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.email.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.email.inc
@@ -1,6 +1,5 @@
filepath());
- $max = variable_get('backup_migrate_max_email_size', 20971520);
+ $max = variable_get('backup_migrate_max_email_size', BACKUP_MIGRATE_MAX_EMAIL_SIZE);
if ($size > $max) {
_backup_migrate_message('Could not email the file @file because it is @size and Backup and Migrate only supports emailing files smaller than @max.', array('@file' => $file->filename(), '@size' => format_size($size), '@max' => format_size($max)), 'error');
return FALSE;
@@ -34,14 +33,14 @@ class backup_migrate_destination_email extends backup_migrate_destination {
/**
* Get the form for the settings for this filter.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['location'] = array(
"#type" => "textfield",
"#title" => t("Email Address"),
"#default_value" => $this->get_location(),
"#required" => TRUE,
- "#description" => t('Enter the email address to send the backup files to. Make sure the email sever can handle large file attachments'),
+ "#description" => t('Enter the email address to send the backup files to. Make sure the email server can handle large file attachments'),
);
return $form;
}
@@ -49,11 +48,12 @@ class backup_migrate_destination_email extends backup_migrate_destination {
/**
* Validate the configuration form. Make sure the email address is valid.
*/
- function settings_form_validate($values) {
+ public function settings_form_validate($values) {
if (!valid_email_address($values['location'])) {
form_set_error('[location]', t('The e-mail address %mail is not valid.', array('%mail' => $form_state['values']['location'])));
}
}
+
}
/**
@@ -72,69 +72,106 @@ class backup_migrate_destination_email extends backup_migrate_destination {
* filename and "filename" which is just the filename.
*/
function _backup_migrate_destination_email_mail_backup($attachment, $to) {
- // Send mail
+ // Send mail.
$attach = fread(fopen($attachment->path, "r"), filesize($attachment->path));
$mail = new mime_mail();
$mail->from = variable_get('site_mail', ini_get('sendmail_from'));
- $mail->headers = 'Errors-To: [EMAIL='. $mail->from .']'. $mail->from .'[/EMAIL]';
+ $mail->headers = 'Errors-To: [EMAIL=' . $mail->from . ']' . $mail->from . '[/EMAIL]';
$mail->to = $to;
$mail->subject = t('Database backup from !site: !file', array('!site' => variable_get('site_name', 'drupal'), '!file' => $attachment->filename));
- $mail->body = t('Database backup attached.') ."\n\n";
+ $mail->body = t('Database backup attached.') . "\n\n";
- $mail->add_attachment("$attach", $attachment->filename, "Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAgEASABIAAD/7QT+UGhvdG9zaG", NULL, TRUE);
+ $mail->add_attachment($attach, $attachment->filename, "application/octet-stream");
$mail->send();
}
+/**
+ *
+ */
class mime_mail {
- var $parts;
- var $to;
- var $from;
- var $headers;
- var $subject;
- var $body;
+ public $parts;
+ public $to;
+ public $from;
+ public $headers;
+ public $subject;
+ public $body;
- function mime_mail() {
+ /**
+ *
+ */
+ public function __construct() {
$this->parts = array();
$this->to = "";
$this->from = "";
- $this->headers = "";
+ $this->headers = array();
$this->subject = "";
$this->body = "";
}
- function add_attachment($message, $name = "", $ctype = "application/octet-stream", $encode = NULL, $attach = FALSE) {
+ /**
+ *
+ */
+ public function add_attachment($message, $name, $ctype) {
$this->parts[] = array(
- "ctype" => $ctype,
"message" => $message,
- "encode" => $encode,
"name" => $name,
- "attach" => $attach,
+ "ctype" => $ctype,
);
}
- function build_message($part) {
- $message = $part["message"];
- $message = chunk_split(base64_encode($message));
- $encoding = "base64";
- $disposition = $part['attach'] ? "Content-Disposition: attachment; filename=$part[name]\n" : '';
- return "Content-Type: ". $part["ctype"] . ($part["name"] ? "; name = \"". $part["name"] ."\"" : "") ."\nContent-Transfer-Encoding: $encoding\n$disposition\n$message\n";
- }
+ /**
+ *
+ */
+ public function build_message($part) {
+ $crlf = "\r\n";
+ // See RFC 2184.
+ $continuation = $crlf . ' ';
+ $name = $part['name'];
+ $len = strlen($name);
- function build_multipart() {
- $boundary = "b". md5(uniqid(time()));
- $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary";
- for ($i = sizeof($this->parts) - 1; $i >= 0; $i--) {
- $multipart .= "\n". $this->build_message($this->parts[$i]) ."--$boundary";
+ // RFC 5322 recommends lines of no longer than 78 chars, which in
+ // this case comes down to filenames of no longer than 64 chars.
+ if ($len > 64) {
+ // We want to preserve the time stamp and extension and such.
+ $head = substr($name, 0, 28);
+ $tail = substr($name, ($len - 32));
+ $name = $head . '___' . $tail;
}
- return $multipart .= "--\n";
+ $message = chunk_split(base64_encode($part["message"]), 70, $crlf);
+ $disposition = $name ? "Content-Disposition: attachment; {$continuation}filename=\"$name\"$crlf" : "";
+ return "Content-Type: " . $part["ctype"] . ($name ? ";{$continuation}name=\"$name\"" : "") .
+ "{$crlf}Content-Transfer-Encoding: base64$crlf$disposition$crlf$message";
}
- function send() {
- $mime = "";
- if (!empty($this->from)) $mime .= "From: ". $this->from ."\n";
- if (!empty($this->headers)) $mime .= $this->headers ."\n";
- if (!empty($this->body)) $this->add_attachment($this->body, "", "text/plain");
- $mime .= "MIME-Version: 1.0\n". $this->build_multipart();
- mail($this->to, $this->subject, "", $mime);
+ /**
+ *
+ */
+ public function build_multipart($boundary) {
+ $multipart = "This is a MIME encoded message.\r\n\r\n--$boundary";
+ for ($i = count($this->parts) - 1; $i >= 0; $i--) {
+ $multipart .= "\r\n" . $this->build_message($this->parts[$i]) . "--$boundary";
+ }
+ return $multipart . "--\r\n";
}
+
+ /**
+ *
+ */
+ public function send() {
+ $headers = array();
+ if (!empty($this->body)) {
+ $this->add_attachment($this->body, "", "text/plain");
+ }
+ $headers['MIME-Version'] = "1.0";
+ $boundary = "b" . md5(uniqid(time()));
+ $headers['Content-Type'] = "multipart/mixed; boundary=\"$boundary\"";
+ $message = $this->build_multipart($boundary);
+ $params = array();
+ $params['body'] = $message;
+ $params['headers'] = $headers;
+ $params['subject'] = $this->subject;
+
+ drupal_mail('backup_migrate', 'destination_mail', trim($this->to), '', $params, $this->from);
+ }
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.file.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.file.inc
index 4cc7e93..c9c495e 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.file.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.file.inc
@@ -1,6 +1,5 @@
get_location());
+ public function get_realpath() {
+ if ($realpath = drupal_realpath($this->get_location())) {
+ return $realpath;
+ }
+ return $this->get_location();
}
/**
* File save destination callback.
*/
- function _save_file($file, $settings) {
- if ($dir = $this->get_location()) {
- if ($dir = $this->check_dir($dir)) {
- $filepath = rtrim($dir, "/") ."/". $file->filename();
- if (file_unmanaged_move($file->filepath(), $filepath)) {
-
- // chmod, chown and chgrp the file if needed.
- if ($chmod = $this->settings('chmod')) {
- if (!@drupal_chmod($filepath, octdec($chmod))) {
- _backup_migrate_message('Unable to set the file mode for: @file', array('@file' => $filepath), 'error');
- }
- }
- if ($chgrp = $this->settings('chgrp')) {
- if (!@chgrp($filepath, $chgrp)) {
- _backup_migrate_message('Unable to set the file group for: @file', array('@file' => $filepath), 'error');
- }
- }
- return $file;
- }
- else {
- _backup_migrate_message('Unable to save the file to the directory: @dir', array('@dir' => $dir), 'error');
+ public function _save_file($file, $settings) {
+ if ($this->confirm_destination() && $dir = $this->get_location()) {
+ $filepath = rtrim($dir, "/") . "/" . $file->filename();
+
+ // Allow files to be overwritten by the filesystem.
+ $replace_method = $settings->append_timestamp == 2 ? FILE_EXISTS_REPLACE : FILE_EXISTS_RENAME;
+
+ // Copy the file if there are multiple destinations.
+ if (count($settings->get_destinations()) > 1) {
+ file_unmanaged_copy($file->filepath(), $filepath, $replace_method);
+ }
+ // Otherwise we can move it and save a delete.
+ else {
+ file_unmanaged_move($file->filepath(), $filepath, $replace_method);
+ }
+
+ // chmod, chown and chgrp the file if needed.
+ if ($chmod = $this->settings('chmod')) {
+ if (!@drupal_chmod($filepath, octdec($chmod))) {
+ _backup_migrate_message('Unable to set the file mode for: @file', array('@file' => $filepath), 'error');
}
}
+ if ($chgrp = $this->settings('chgrp')) {
+ if (!@chgrp($filepath, $chgrp)) {
+ _backup_migrate_message('Unable to set the file group for: @file', array('@file' => $filepath), 'error');
+ }
+ }
+ return $file;
}
}
/**
* Determine if we can read the given file.
*/
- function can_read_file($file_id) {
+ public function can_read_file($file_id) {
return $this->op('restore') && is_readable($this->get_filepath($file_id));
}
/**
* File load destination callback.
*/
- function load_file($file_id) {
+ public function load_file($file_id) {
$filepath = $this->get_filepath($file_id);
if (file_exists($filepath)) {
- backup_migrate_include('files');
+ require_once dirname(__FILE__) . '/files.inc';
+
return new backup_file(array('filepath' => $filepath));
}
}
+ /**
+ * Get the file object for the given file.
+ */
+ public function get_file($file_id) {
+ $files = $this->list_files();
+ if (isset($files[$file_id])) {
+ isset($files[$file_id]);
+ }
+ return NULL;
+ }
+
/**
* File list destination callback.
*/
- function _list_files() {
+ public function _list_files() {
$files = array();
if ($dir = $this->get_realpath()) {
if ($handle = @opendir($dir)) {
- backup_migrate_include('files');
+ require_once dirname(__FILE__) . '/files.inc';
+
while (FALSE !== ($file = readdir($handle))) {
- $filepath = $dir ."/". $file;
- $files[$file] = new backup_file(array('filepath' => $filepath));
+ if (substr($file, 0, 1) !== '.') {
+ $filepath = $dir . "/" . $file;
+ $files[$file] = new backup_file(array('filepath' => $filepath));
+ }
}
}
}
@@ -93,7 +117,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* File delete destination callback.
*/
- function _delete_file($file_id) {
+ public function _delete_file($file_id) {
$filepath = $this->get_filepath($file_id);
file_unmanaged_delete($filepath);
}
@@ -101,9 +125,9 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Get the filepath from the given file id.
*/
- function get_filepath($file_id) {
+ public function get_filepath($file_id) {
if ($dir = $this->get_realpath()) {
- $filepath = rtrim($dir, '/') .'/'. $file_id;
+ $filepath = rtrim($dir, '/') . '/' . $file_id;
return $filepath;
}
return FALSE;
@@ -112,7 +136,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Get the form for the settings for the files destination.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['location'] = array(
"#type" => "textfield",
@@ -152,7 +176,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Validate the form for the settings for the files destination.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
$values = $form_state['values'];
if (isset($values['settings']['chmod']) && !empty($values['settings']['chmod']) && !preg_match('/0?[0-7]{3}/', $values['settings']['chmod'])) {
form_set_error('chmod', t('You must enter a valid chmod octal value (e.g. 644 or 0644) in the change mode field, or leave it blank.'));
@@ -163,7 +187,7 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Submit the form for the settings for the files destination.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
// Add a 0 to the start of a 3 digit file mode to make it proper PHP encoded octal.
if (strlen($form_state['values']['settings']['chmod']) == 3) {
$form_state['values']['settings']['chmod'] = '0' . $form_state['values']['settings']['chmod'];
@@ -171,15 +195,26 @@ class backup_migrate_destination_files extends backup_migrate_destination {
parent::edit_form_submit($form, $form_state);
}
+ /**
+ * Check that a destination is valid.
+ */
+ public function confirm_destination() {
+ if ($dir = $this->get_location()) {
+ return $this->check_dir($dir);
+ }
+ return FALSE;
+ }
+
/**
* Prepare the destination directory for the backups.
*/
- function check_dir($directory) {
+ public function check_dir($directory) {
if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) {
// Unable to create destination directory.
- _backup_migrate_message("Unable to create or write to the save directory '%directory'. Please check the file permissions that directory and try again.", array('%directory' => $directory), "error");
+ _backup_migrate_message("Unable to create or write to the save directory '%directory'. Please check the file permissions of that directory and try again.", array('%directory' => $directory), "error");
return FALSE;
}
+
// If the destination directory is within the webroot, then secure it as best we can.
if ($this->dir_in_webroot($directory)) {
$directory = $this->check_web_dir($directory);
@@ -191,45 +226,60 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Check that a web accessible directory has been properly secured, othewise attempt to secure it.
*/
- function check_web_dir($directory) {
- file_create_htaccess($directory, TRUE);
-
- // Check the user agent to make sure we're not responding to a request from drupal itself.
- // That should prevent infinite loops which could be caused by poormanscron in some circumstances.
- if (strpos($_SERVER['HTTP_USER_AGENT'], 'Drupal') !== FALSE) {
- return FALSE;
+ public function check_web_dir($directory) {
+ // Check if the file has already been tested.
+ if (is_file($directory . '/tested.txt')) {
+ return $directory;
}
+ else {
+ file_create_htaccess($directory, TRUE);
- // Check to see if the destination is publicly accessible
- $test_contents = "this file should not be publicly accessible";
- // Create the the text.txt file if it's not already there.
- if (!is_file($directory .'/test.txt') || file_get_contents($directory .'/test.txt') != $test_contents) {
- if ($fp = fopen($directory .'/test.txt', 'w')) {
- @fputs($fp, $test_contents);
- fclose($fp);
- }
- else {
- $message = t("Security notice: Backup and Migrate was unable to write a test text file to the destination directory %directory, and is therefore unable to check the security of the backup destination. Backups to the server will be disabled until the destination becomes writable and secure.", array('%directory' => $directory));
- drupal_set_message($message, "error");
+ // Check the user agent to make sure we're not responding to a request from drupal itself.
+ // That should prevent infinite loops which could be caused by poormanscron in some circumstances.
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'Drupal') !== FALSE) {
return FALSE;
}
- }
- // Attempt to read the test file via http. This may fail for other reasons,
- // so it's not a bullet-proof check.
- if ($this->test_file_readable_remotely($directory .'/test.txt', $test_contents)) {
- $message = t("Security notice: Backup and Migrate will not save backup files to the server because the destination directory is publicly accessible. If you want to save files to the server, please secure the '%directory' directory", array('%directory' => $directory));
- drupal_set_message($message, "error");
- return FALSE;
+ // Check to see if the destination is publicly accessible.
+ $test_contents = "this file should not be publicly accessible";
+ // Create the the text.txt file if it's not already there.
+ if (!is_file($directory . '/test.txt') || file_get_contents($directory . '/test.txt') != $test_contents) {
+ if ($fp = fopen($directory . '/test.txt', 'w')) {
+ @fputs($fp, $test_contents);
+ fclose($fp);
+ }
+ else {
+ $message = t("Security notice: Backup and Migrate was unable to write a test text file to the destination directory %directory, and is therefore unable to check the security of the backup destination. Backups to the server will be disabled until the destination becomes writable and secure.", array('%directory' => $directory));
+ drupal_set_message($message, "error");
+ return FALSE;
+ }
+ }
+
+ // Attempt to read the test file via http. This may fail for other
+ // reasons, so it's not a bullet-proof check.
+ if ($this->test_file_readable_remotely($directory . '/test.txt', $test_contents)) {
+ $message = t("Security notice: Backup and Migrate will not save backup files to the server because the destination directory is publicly accessible. If you want to save files to the server, please secure the '%directory' directory", array('%directory' => $directory));
+ drupal_set_message($message, "error");
+ unlink($directory . '/test.txt');
+ return FALSE;
+ }
+ // Directory tested OK, so we mark it as tested.
+ if ($fp = fopen($directory . '/tested.txt', 'w')) {
+ $contents = t('The presence of this file indicates that this directory has been tested as safe to use as a destination for Backup and Migrate. If you change the permissions of this directory or change your web server settings, please delete this file so that the directory can be checked again.');
+ @fputs($fp, $contents);
+ fclose($fp);
+ }
+ return $directory;
}
- return $directory;
}
/**
* Check if the given directory is within the webroot and is therefore web accessible.
*/
- function dir_in_webroot($directory) {
- if (strpos(drupal_realpath($directory), realpath($_SERVER['DOCUMENT_ROOT'])) !== FALSE) {
+ public function dir_in_webroot($directory) {
+ $real_dir = drupal_realpath($directory);
+ $real_root = drupal_realpath(DRUPAL_ROOT);
+ if ($real_dir == $real_root || strpos($real_dir, $real_root . '/') === 0) {
return TRUE;
}
return FALSE;
@@ -238,35 +288,52 @@ class backup_migrate_destination_files extends backup_migrate_destination {
/**
* Check if a file can be read remotely via http.
*/
- function test_file_readable_remotely($path, $contents) {
- $url = file_create_url($path);
- // TODO: Proper checking for absolute paths.
- $result = drupal_http_request($url);
- if (!empty($result->data) && strpos($result->data, $contents) !== FALSE) {
- return TRUE;
+ public function test_file_readable_remotely($directory, $contents) {
+ $real_dir = drupal_realpath($directory);
+ $real_root = drupal_realpath(DRUPAL_ROOT);
+ if ($real_dir && $real_root) {
+ // Get the root relative path.
+ $path = substr($real_dir, strlen($real_root));
+
+ $url = $GLOBALS['base_url'] . str_replace('\\', '/', $path);
+ $result = drupal_http_request($url);
+ if (!empty($result->data) && strpos($result->data, $contents) !== FALSE) {
+ return TRUE;
+ }
}
return FALSE;
}
+
}
/**
* The manual files directory.
*/
class backup_migrate_destination_files_manual extends backup_migrate_destination_files {
- var $supported_ops = array('manual backup', 'restore', 'list files', 'configure', 'delete');
- function __construct($params = array()) {
+ public $supported_ops = array('manual backup', 'restore', 'list files', 'configure', 'delete');
+
+ /**
+ *
+ */
+ public function __construct($params = array()) {
$dir = 'private://backup_migrate/manual';
parent::__construct($params + array('location' => $dir, 'name' => t('Manual Backups Directory')));
}
+
}
/**
* The scheduled files directory.
*/
class backup_migrate_destination_files_scheduled extends backup_migrate_destination_files {
- var $supported_ops = array('scheduled backup', 'restore', 'list files', 'configure', 'delete');
- function __construct($params = array()) {
+ public $supported_ops = array('scheduled backup', 'restore', 'list files', 'configure', 'delete');
+
+ /**
+ *
+ */
+ public function __construct($params = array()) {
$dir = 'private://backup_migrate/scheduled';
parent::__construct($params + array('location' => $dir, 'name' => t('Scheduled Backups Directory')));
}
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.ftp.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.ftp.inc
index 306b1ba..8b635ac 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.ftp.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.ftp.inc
@@ -1,6 +1,5 @@
ftp_object();
if (drupal_ftp_file_to_ftp($file->filepath(), $file->filename(), '.', $ftp)) {
return $file;
@@ -29,8 +28,9 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
/**
* Load from the ftp destination.
*/
- function load_file($file_id) {
- backup_migrate_include('files');
+ public function load_file($file_id) {
+ require_once dirname(__FILE__) . '/files.inc';
+
$file = new backup_file(array('filename' => $file_id));
$this->ftp_object();
if (drupal_ftp_ftp_to_file($file->filepath(), $file_id, '.', $this->ftp)) {
@@ -42,16 +42,20 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
/**
* Delete from the ftp destination.
*/
- function _delete_file($file_id) {
+ public function _delete_file($file_id) {
$this->ftp_object();
drupal_ftp_delete_file($file_id, $this->ftp);
}
- function _list_files() {
- backup_migrate_include('files');
+ /**
+ *
+ */
+ public function _list_files() {
+ require_once dirname(__FILE__) . '/files.inc';
+
$files = array();
$this->ftp_object();
- $ftp_files = drupal_ftp_file_list('.', $this->ftp);
+ $ftp_files = (array) drupal_ftp_file_list('.', $this->ftp);
foreach ($ftp_files as $file) {
$files[$file['filename']] = new backup_file($file);
}
@@ -61,7 +65,7 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
/**
* Get the form for the settings for this filter.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['scheme']['#type'] = 'value';
$form['scheme']['#value'] = 'ftp';
@@ -80,15 +84,24 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
return $form;
}
- function set_pasv($value) {
- $this->settings['pasv'] = (bool)$value;
+ /**
+ *
+ */
+ public function set_pasv($value) {
+ $this->settings['pasv'] = (bool) $value;
}
- function get_pasv() {
+ /**
+ *
+ */
+ public function get_pasv() {
return isset($this->settings['pasv']) ? $this->settings['pasv'] : FALSE;
}
- function ftp_object() {
+ /**
+ *
+ */
+ public function ftp_object() {
if (!$this->ftp) {
$this->dest_url['port'] = empty($this->dest_url['port']) ? '21' : $this->dest_url['port'];
$this->dest_url['pasv'] = $this->get_pasv();
@@ -96,19 +109,18 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote {
}
return $this->ftp;
}
+
}
// The FTP code below was taken from the ftp module by Aaron Winborn.
-
// Inspired by http://www.devarticles.com/c/a/PHP/My-FTP-Wrapper-Class-for-PHP/
// It's been drupalized, however, and most of the bugs from that example have been fixed.
-// - winborn 2007-06-22 - 2007-06-28
-
+// - winborn 2007-06-22 - 2007-06-28.
define('DRUPAL_FTP_FT_DIRECTORY', 0);
define('DRUPAL_FTP_FT_FILE', 1);
/**
- * creates a new ftp object. if any elements of ftp_map are missing, they'll be filled with the server defaults.
+ * Creates a new ftp object. if any elements of ftp_map are missing, they'll be filled with the server defaults.
*/
function drupal_ftp_ftp_object($server, $port, $user, $pass, $dir, $pasv) {
$ftp = new stdClass();
@@ -124,17 +136,17 @@ function drupal_ftp_ftp_object($server, $port, $user, $pass, $dir, $pasv) {
}
/**
- * The drupal_ftp_connect function
+ * The drupal_ftp_connect function
* This function connects to an FTP server and attempts to change into the directory specified by
* the fourth parameter, $directory.
*/
function drupal_ftp_connect(&$ftp) {
- if (is_NULL($ftp)) {
+ if (is_null($ftp)) {
$ftp = drupal_ftp_ftp_object();
}
- if (empty($ftp->__conn) && !drupal_ftp_connected($ftp)) {
- // Attempt to connect to the remote server
+ if (!$ftp->__conn && !drupal_ftp_connected($ftp)) {
+ // Attempt to connect to the remote server.
$ftp->__conn = @ftp_connect($ftp->__server, $ftp->__port);
if (!$ftp->__conn) {
@@ -142,7 +154,7 @@ function drupal_ftp_connect(&$ftp) {
return FALSE;
}
- // Attempt to login to the remote server
+ // Attempt to login to the remote server.
$ftp->__login = @ftp_login($ftp->__conn, $ftp->__user, $ftp->__password);
if (!$ftp->__login) {
@@ -150,7 +162,7 @@ function drupal_ftp_connect(&$ftp) {
return FALSE;
}
- // Attempt to change into the working directory
+ // Attempt to change into the working directory.
$chdir = @ftp_chdir($ftp->__conn, $ftp->__directory);
if (!$chdir) {
@@ -158,7 +170,7 @@ function drupal_ftp_connect(&$ftp) {
return FALSE;
}
- // Set PASV - if needed
+ // Set PASV - if needed.
if ($ftp->__pasv) {
$pasv = @ftp_pasv($ftp->__conn, TRUE);
if (!$pasv) {
@@ -168,7 +180,7 @@ function drupal_ftp_connect(&$ftp) {
}
}
- // Everything worked OK, return TRUE
+ // Everything worked OK, return TRUE.
return TRUE;
}
@@ -179,38 +191,36 @@ function drupal_ftp_connect(&$ftp) {
*/
function drupal_ftp_connected(&$ftp) {
// Attempt to call the ftp_systype to see if the connect
- // to the FTP server is still alive and kicking
-
- if (is_NULL($ftp)) {
+ // to the FTP server is still alive and kicking.
+ if (is_null($ftp)) {
$ftp = drupal_ftp_ftp_object();
return FALSE;
}
if (!@ftp_systype($ftp->__conn)) {
- // The connection is dead
+ // The connection is dead.
return FALSE;
}
else {
- // The connection is still alive
+ // The connection is still alive.
return TRUE;
}
}
/**
- * This function tries to retrieve the contents of a file from the FTP server.
+ * This function tries to retrieve the contents of a file from the FTP server.
* Firstly it changes into the $directory directory, and then attempts to download the file $filename.
* The file is saved locally and its contents are returned to the caller of the function.
*/
function drupal_ftp_ftp_to_file($file, $filename, $directory, &$ftp) {
// Change into the remote directory and retrieve the content
- // of a file. Once retrieve, return this value to the caller
-
+ // of a file. Once retrieve, return this value to the caller.
if (!@drupal_ftp_connect($ftp)) {
return FALSE;
}
// We are now connected, so let's retrieve the file contents.
- // Firstly, we change into the directory
+ // Firstly, we change into the directory.
$chdir = @ftp_chdir($ftp->__conn, $directory);
if (!$chdir) {
@@ -218,7 +228,7 @@ function drupal_ftp_ftp_to_file($file, $filename, $directory, &$ftp) {
return FALSE;
}
- // We have changed into the directory, let's attempt to get the file
+ // We have changed into the directory, let's attempt to get the file.
$fp = @fopen($file, 'wb');
$get_file = @ftp_fget($ftp->__conn, $fp, $filename, FTP_BINARY);
fclose($fp);
@@ -229,7 +239,7 @@ function drupal_ftp_ftp_to_file($file, $filename, $directory, &$ftp) {
_backup_migrate_message('FTP Error: Unable to download file: @filename from @directory', array('@filename' => $filename, '@directory' => $directory), 'error');
return FALSE;
}
-
+
return TRUE;
}
@@ -242,15 +252,15 @@ function drupal_ftp_file_to_ftp($file, $ftp_filename, $ftp_directory, &$ftp) {
}
if ($source = drupal_realpath($file)) {
- // Now we can try to write to the remote file
- $complete_filename = $ftp_directory .'/'. $ftp_filename;
+ // Now we can try to write to the remote file.
+ $complete_filename = $ftp_directory . '/' . $ftp_filename;
$put_file = @ftp_put($ftp->__conn, $complete_filename, $source, FTP_BINARY);
if (!$put_file) {
_backup_migrate_message('FTP Error: Couldn\'t write to @complete_filename when trying to save file on the ftp server.', array('@complete_filename' => $complete_filename), 'error');
return FALSE;
}
- // Everything worked OK
+ // Everything worked OK.
return TRUE;
}
else {
@@ -260,19 +270,18 @@ function drupal_ftp_file_to_ftp($file, $ftp_filename, $ftp_directory, &$ftp) {
}
/**
- * The drupal_ftp_change_directory Function
+ * The drupal_ftp_change_directory Function
* This function simply changes into the $directory folder on the FTP server.
* If a connection or permission error occurs then _backup_migrate_message() will contain the error message.
*/
function drupal_ftp_change_directory($directory, &$ftp) {
// Switch to another directory on the web server. If we don't
- // have permissions then an error will occur
-
+ // have permissions then an error will occur.
if (!@drupal_ftp_connect($ftp)) {
return FALSE;
}
- // Try and change into another directory
+ // Try and change into another directory.
$chdir = ftp_chdir($ftp->__conn, $directory);
if (!$chdir) {
@@ -280,21 +289,20 @@ function drupal_ftp_change_directory($directory, &$ftp) {
return FALSE;
}
else {
- // Changing directories worked OK
+ // Changing directories worked OK.
return TRUE;
}
}
/**
- * The drupal_ftp_file_list Function
+ * The drupal_ftp_file_list Function
* This function will change into the $directory folder and get a list of files and directories contained in that folder.
* This function still needs a lot of work, but should work in most cases.
*/
function drupal_ftp_file_list($directory, &$ftp) {
// This function will attempt to change into the specified
// directory and retrieve a list of files as an associative
- // array. This list will include file name, size and date last modified
-
+ // array. This list will include file name, size and date last modified.
$file_array = array();
// Can we switch to the desired directory?
@@ -306,14 +314,14 @@ function drupal_ftp_file_list($directory, &$ftp) {
// This is slower than parsing the raw return values, but it is faster.
$file_list = ftp_nlist($ftp->__conn, $directory);
- // Save the list of files
+ // Save the list of files.
if (@is_array($file_list)) {
- // Interate through the array
+ // Interate through the array.
foreach ($file_list as $file) {
$file_array[] = array(
'filename' => $file,
- 'filesize' => ftp_size($ftp->__conn, $directory ."/". $file),
- 'filetime' => ftp_mdtm($ftp->__conn, $directory ."/". $file),
+ 'filesize' => ftp_size($ftp->__conn, $directory . "/" . $file),
+ 'filetime' => ftp_mdtm($ftp->__conn, $directory . "/" . $file),
);
}
}
@@ -322,13 +330,12 @@ function drupal_ftp_file_list($directory, &$ftp) {
}
/**
- * The drupal_ftp_create_directory Function
+ * The drupal_ftp_create_directory Function
* This function tries to make a new directory called $folder_name on the FTP server.
* If it can create the folder, then the folder is given appropriate rights with the CHMOD command.
*/
function drupal_ftp_create_directory($folder_name, &$ftp) {
- // Makes a new folder on the web server via FTP
-
+ // Makes a new folder on the web server via FTP.
if (!@drupal_ftp_connect($ftp)) {
return FALSE;
}
@@ -337,7 +344,7 @@ function drupal_ftp_create_directory($folder_name, &$ftp) {
if ($create_result == TRUE) {
// Can we change the files permissions?
- $exec_result = @ftp_site($ftp->__conn, 'chmod 0777 '. $folder_name .'/');
+ $exec_result = @ftp_site($ftp->__conn, 'chmod 0777 ' . $folder_name . '/');
if ($exec_result == TRUE) {
return TRUE;
@@ -354,11 +361,11 @@ function drupal_ftp_create_directory($folder_name, &$ftp) {
}
/**
- * The drupal_ftp_delete_file Function
+ * The drupal_ftp_delete_file Function
* This function attempts to delete a file called $filename from the FTP server.
*/
function drupal_ftp_delete_file($filename, &$ftp) {
- // Remove the specified file from the FTP server
+ // Remove the specified file from the FTP server.
if (!@drupal_ftp_connect($ftp)) {
return FALSE;
}
@@ -366,18 +373,18 @@ function drupal_ftp_delete_file($filename, &$ftp) {
$delete_result = @ftp_delete($ftp->__conn, $filename);
if ($delete_result == TRUE) {
- // The file/folder was renamed successfully
+ // The file/folder was renamed successfully.
return TRUE;
}
else {
- // Couldn't delete the selected file
+ // Couldn't delete the selected file.
_backup_migrate_message('FTP Error: Couldn\'t delete the selected file: @filename', array('@filename' => $filename), 'error');
return FALSE;
}
}
/**
- * The drupal_ftp_delete_folder Function
+ * The drupal_ftp_delete_folder Function
* This function was one of the hardest to write. It recursively deletes all files and folders from a directory called $folder_name.
*/
function drupal_ftp_delete_folder($folder_name, &$ftp) {
@@ -394,18 +401,18 @@ function drupal_ftp_delete_folder($folder_name, &$ftp) {
$file_counter = 0;
$content = @ftp_nlist($ftp->__conn, ".");
- for ($i = 0; $i < sizeof($content); $i++) {
+ for ($i = 0; $i < count($content); $i++) {
// If we can change into this then it's a directory.
- // If not, it's a file
+ // If not, it's a file.
if ($content[$i] != "." && $content[$i] != "..") {
if (@ftp_chdir($ftp->__conn, $content[$i])) {
- // We have a directory
+ // We have a directory.
$directories[] = $content[$i];
$dir_counter++;
@ftp_cdup($ftp->__conn);
}
else {
- // We have a file
+ // We have a file.
$files[] = $content[$i];
$file_counter++;
}
@@ -417,10 +424,10 @@ function drupal_ftp_delete_folder($folder_name, &$ftp) {
}
for ($j = 0; $j < $dir_counter; $j++) {
- if ($directories[$j] != "." OR $directories[$j] != "..") {
+ if ($directories[$j] != "." or $directories[$j] != "..") {
$location = ftp_pwd($ftp->__conn);
drupal_ftp_delete_folder($directories[$j], $ftp);
- @ftp_cdup ($ftp->__conn);
+ @ftp_cdup($ftp->__conn);
@ftp_rmdir($ftp->__conn, $directories[$j]);
}
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.inc
index 1a9af3e..172b5f3 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.inc
@@ -1,91 +1,80 @@
array(
- 'description' => t('Save the backup files to any directory on the server which the web-server can write to.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.file.inc',
+ 'description' => t('Save the backup files to any directory on this server which the web-server can write to.'),
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.file.inc',
'class' => 'backup_migrate_destination_files',
'type_name' => t('Server Directory'),
+ 'local' => TRUE,
'can_create' => TRUE,
),
'file_manual' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.file.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.file.inc',
'type_name' => t('Server Directory'),
'class' => 'backup_migrate_destination_files_manual',
),
'file_scheduled' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.file.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.file.inc',
'type_name' => t('Server Directory'),
'class' => 'backup_migrate_destination_files_scheduled',
),
);
- }
+ }
$out += array(
'browser_download' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.browser.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.browser.inc',
'class' => 'backup_migrate_destination_browser_download',
),
'browser_upload' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.browser.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.browser.inc',
'class' => 'backup_migrate_destination_browser_upload',
),
- 'db' => array(
- 'type_name' => t('Database'),
- 'description' => t('Import the backup directly into another database. Database destinations can also be used as a source to backup from.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.db.inc',
- 'class' => 'backup_migrate_destination_db',
- 'can_create' => FALSE,
- ),
- 'mysql' => array(
- 'type_name' => t('MySQL Database'),
- 'description' => t('Import the backup directly into another MySQL database. Database destinations can also be used as a source to backup from.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.db.mysql.inc',
- 'class' => 'backup_migrate_destination_db_mysql',
- 'can_create' => TRUE,
- ),
'ftp' => array(
'description' => t('Save the backup files to any a directory on an FTP server.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.ftp.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.ftp.inc',
'class' => 'backup_migrate_destination_ftp',
'type_name' => t('FTP Directory'),
'can_create' => TRUE,
+ 'remote' => TRUE,
),
's3' => array(
- 'description' => t('Save the backup files to a bucket on your !link.', array('!link' => l(t('Amazon S3 account'), 'http://aws.amazon.com/s3/'))),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.s3.inc',
+ 'description' => t('Save the backup files to a bucket on your Amazon S3 account.', array('@link' => url('http://aws.amazon.com/s3/'))),
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.s3.inc',
'class' => 'backup_migrate_destination_s3',
'type_name' => t('Amazon S3 Bucket'),
'can_create' => TRUE,
+ 'remote' => TRUE,
),
'email' => array(
'type_name' => t('Email'),
'description' => t('Send the backup as an email attachment to the specified email address.'),
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.email.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.email.inc',
'class' => 'backup_migrate_destination_email',
'can_create' => TRUE,
+ 'remote' => TRUE,
),
);
@@ -93,18 +82,19 @@ function backup_migrate_backup_migrate_destination_types() {
}
/**
- * Implementation of hook_backup_migrate_destinations().
- *
- * Get the built in backup destinations and those in the db.
+ * Implements hook_backup_migrate_destinations().
*/
function backup_migrate_backup_migrate_destinations() {
- $out = array();
+ require_once dirname(__FILE__) . '/filters.inc';
+
+ // Get the built in backup destinations and those in the db.
+ $out = array();
// Add the default, out of the box destinations for new users.
if (variable_get('backup_migrate_allow_backup_to_file', TRUE)) {
if (variable_get('file_private_path', FALSE)) {
- $out['manual'] = backup_migrate_create_destination('file_manual', array('destination_id' => 'manual'));
- $out['scheduled'] = backup_migrate_create_destination('file_scheduled', array('destination_id' => 'scheduled'));
+ $out['manual'] = backup_migrate_create_destination('file_manual', array('machine_name' => 'manual'));
+ $out['scheduled'] = backup_migrate_create_destination('file_scheduled', array('machine_name' => 'scheduled'));
}
else {
_backup_migrate_message('You must specify a private file system path in the !settings to backup to the server.', array('!settings' => l(t('file system settings'), 'admin/config/media/file-system')), 'warning');
@@ -112,37 +102,13 @@ function backup_migrate_backup_migrate_destinations() {
}
// Add the browser destination for downloading to the desktop.
if (variable_get('backup_migrate_allow_backup_to_download', TRUE)) {
- $out['download'] = backup_migrate_create_destination('browser_download');
+ $out['download'] = backup_migrate_create_destination('browser_download');
}
- $out['upload'] = backup_migrate_create_destination('browser_upload');
+ $out['upload'] = backup_migrate_create_destination('browser_upload');
// Expose the configured databases as sources.
- backup_migrate_include('filters');
- $out += backup_migrate_filters_invoke_all('destinations');
-/*
- global $db_url;
- $urls = is_array($db_url) ? $db_url : array('default' => $db_url);
- foreach ((array)$urls as $key => $url) {
- // Only mysql is currently supported. If more DBMs's are implemented, theis will need to be abstacted.
- if (strpos($url, 'mysql') === 0) {
- if ($destination = backup_migrate_create_destination('mysql', array('url' => $url))) {
- // Treat the default database differently because it is probably the only one available.
- if ($key == 'default') {
- $destination->set_id('db');
- $destination->set_name(t('Default Database'));
- // Dissalow backing up to the default database because that's confusing and potentially dangerous.
- unset($destination->supported_ops['scheduled backup']);
- unset($destination->supported_ops['manual backup']);
- }
- else {
- $destination->set_id('db:'. $key);
- $destination->set_name($key .": ". $destination->get_display_location());
- }
- $out[$destination->get_id()] = $destination;
- }
- }
- }
-*/
+ $out += backup_migrate_filters_invoke_all('destinations');
+
return $out;
}
@@ -150,9 +116,9 @@ function backup_migrate_backup_migrate_destinations() {
* Get all the available backup destination.
*
* @param $op
- * The operation which will be performed on the destination. Hooks can use this
- * to return only those destinations appropriate for the given op.
- * Options include:
+ * The operation which will be performed on the destination. Hooks can use this
+ * to return only those destinations appropriate for the given op.
+ * Options include:
* 'manual backup' - destinations available for manual backup
* 'scheduled backup' - destinations available for schedules backup
* 'list files' - destinations whose backup files can be listed
@@ -160,7 +126,7 @@ function backup_migrate_backup_migrate_destinations() {
* 'all' - all available destinations should be returned
*/
function backup_migrate_get_destinations($op = 'all') {
- static $destinations = NULL;
+ $destinations = &drupal_static('backup_migrate_get_destinations', NULL);
// Get the list of destinations and cache them locally.
if ($destinations === NULL) {
@@ -194,10 +160,8 @@ function backup_migrate_get_destination($id) {
* Create a destination object of the given type with the given params.
*/
function backup_migrate_create_destination($destination_type, $params = array()) {
- $params['type'] = $destination_type;
- // Create a new dummy destination to call the create method on because the base item create is not static.
- $destination = new backup_migrate_destination();
- return $destination->create($params);
+ $params['subtype'] = $destination_type;
+ return backup_migrate_crud_create_item('destination', $params);
}
/**
@@ -210,6 +174,28 @@ function backup_migrate_destination_get_file($destination_id, $file_id) {
return NULL;
}
+/**
+ * Load a file from a destination and return the file info.
+ */
+function backup_migrate_destination_get_latest_file($destination_id) {
+ $out = NULL;
+ if ($destination = backup_migrate_get_destination($destination_id)) {
+ $files = $destination->list_files();
+ $max = 0;
+ foreach ((array) $files as $file) {
+ $info = $file->info();
+
+ // If there's a datestamp, it should override the filetime as it's probably more reliable.
+ $time = !empty($info['datestamp']) ? $info['datestamp'] : $info['filetime'];
+ if ($time > $max) {
+ $max = $time;
+ $out = $file;
+ }
+ }
+ }
+ return $out;
+}
+
/**
* Check if a file exists in the given destination.
*/
@@ -223,12 +209,36 @@ function backup_migrate_destination_file_exists($destination_id, $file_id) {
/**
* Send a file to the destination specified by the settings array.
*/
-function backup_migrate_destination_save_file($file, &$settings) {
- if ($destination = $settings->get_destination()) {
- $file = $destination->save_file($file, $settings);
- return $file;
+function backup_migrate_destination_confirm_destination(&$settings) {
+ if ($destinations = $settings->get_destinations()) {
+ foreach ($destinations as $key => $destination) {
+ // Check that the destination is ready to go.
+ if (!$destination->confirm_destination()) {
+ unset($destinations[$key]);
+ }
+ }
}
- return NULL;
+ $settings->destinations = $destinations;
+ return count($destinations);
+}
+
+/**
+ * Send a file to the destination specified by the settings array.
+ */
+function backup_migrate_destination_save_file($file, &$settings) {
+ $saved_to = array();
+ if ($destinations = $settings->get_destinations()) {
+ foreach ($destinations as $destination) {
+ // Make sure the file only gets saved to each destination once.
+ $id = $destination->get('id');
+ if (!in_array($id, $saved_to)) {
+ if ($destination->save_file($file, $settings)) {
+ $saved_to[] = $id;
+ }
+ }
+ }
+ }
+ return $saved_to ? $file : FALSE;
}
/**
@@ -257,75 +267,281 @@ function _backup_migrate_destination_get_file_links($destination_id, $file_id) {
* List the backup files in the given destination.
*/
function backup_migrate_ui_destination_display_files($destination_id = NULL) {
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
$rows = $sort = array();
if ($destination = backup_migrate_get_destination($destination_id)) {
+ drupal_set_title(t('@title Files', array('@title' => $destination->get_name())));
+ return _backup_migrate_ui_destination_display_files($destination, 20, TRUE);
+ }
+ drupal_goto(BACKUP_MIGRATE_MENU_PATH . "/destination");
+}
+
+/**
+ * List the backup files in the given destination.
+ */
+function _backup_migrate_ui_destination_display_files($destination = NULL, $limit = NULL, $show_pager = FALSE) {
+ if ($destination) {
// Refresh the file listing cache if requested.
if (isset($_GET['refresh'])) {
$destination->file_cache_clear();
drupal_goto($_GET['q']);
}
+ $files = $destination->list_files();
- drupal_set_title(t('@title Files', array('@title' => $destination->get_name())));
+ $fetch = $out = '';
+
+ // Get the fetch link.
+ if ($destination->cache_files && $destination->fetch_time) {
+ $fetch = '
';
- }
- return $out;
+
+ $out = theme('table', array(
+ 'header' => $headers,
+ 'rows' => $rows,
+ 'class' => 'backup-migrate-listing backup-migrate-listing-files',
+ ));
+ $out .= $showing;
}
- drupal_goto(BACKUP_MIGRATE_MENU_PATH . "/destination");
+ else {
+ $out = t('There are no backup files to display.');
+ }
+ return $out;
}
/**
@@ -333,9 +549,11 @@ function backup_migrate_ui_destination_display_files($destination_id = NULL) {
*/
function backup_migrate_ui_destination_download_file($destination_id = NULL, $file_id = NULL) {
if ($file = backup_migrate_destination_get_file($destination_id, $file_id)) {
- backup_migrate_include('files');
+ require_once dirname(__FILE__) . '/files.inc';
+
$file->transfer();
}
+
drupal_goto(BACKUP_MIGRATE_MENU_PATH);
}
@@ -346,19 +564,23 @@ function backup_migrate_ui_destination_restore_file($destination_id = NULL, $fil
if (backup_migrate_destination_file_exists($destination_id, $file_id)) {
return drupal_get_form('backup_migrate_ui_destination_restore_file_confirm', $destination_id, $file_id);
}
- drupal_goto(user_access('access backup files') ? BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/". $destination_id : BACKUP_MIGRATE_MENU_PATH);
+ _backup_migrate_message('Cannot restore from the the file: %file_id because it does not exist.', array('%file_id' => $file_id), 'error');
+ if ($destination_id && user_access('access backup files')) {
+ drupal_goto(BACKUP_MIGRATE_MENU_PATH . '/destination/list/files/' . $destination_id);
+ }
+ drupal_goto(BACKUP_MIGRATE_MENU_PATH);
}
/**
* Ask confirmation for file restore.
*/
function backup_migrate_ui_destination_restore_file_confirm($form, &$form_state, $destination_id, $file_id) {
- $sources = _backup_migrate_get_destination_form_item_options('source');
+ $sources = _backup_migrate_get_source_form_item_options();
if (count($sources) > 1) {
$form['source_id'] = array(
"#type" => "select",
- "#title" => t("Database"),
- "#options" => _backup_migrate_get_destination_form_item_options('source'),
+ "#title" => t("Restore to"),
+ "#options" => $sources,
"#description" => t("Choose the database to restore to. Any database destinations you have created and any databases specified in your settings.php can be restored to."),
"#default_value" => 'db',
);
@@ -372,7 +594,7 @@ function backup_migrate_ui_destination_restore_file_confirm($form, &$form_state,
$form['destination_id'] = array('#type' => 'value', '#value' => $destination_id);
$form['file_id'] = array('#type' => 'value', '#value' => $file_id);
- $form = confirm_form($form, t('Are you sure you want to restore the database?'), BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/". $destination_id, t('Are you sure you want to restore the database from the backup file %file_id? This will delete some or all of your data and cannot be undone. Always test your backups on a non-production server!', array('%file_id' => $file_id)), t('Restore'), t('Cancel'));
+ $form = confirm_form($form, t('Are you sure you want to restore the database?'), BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/" . $destination_id, t('Are you sure you want to restore the database from the backup file %file_id? This will delete some or all of your data and cannot be undone. Always test your backups on a non-production server!', array('%file_id' => $file_id)), t('Restore'), t('Cancel'));
drupal_set_message(t('Restoring will delete some or all of your data and cannot be undone. Always test your backups on a non-production server!'), 'warning', FALSE);
$form = array_merge_recursive($form, backup_migrate_filters_settings_form(backup_migrate_filters_settings_default('restore'), 'restore'));
$form['actions']['#weight'] = 100;
@@ -381,8 +603,8 @@ function backup_migrate_ui_destination_restore_file_confirm($form, &$form_state,
if (@$form['advanced']) {
$form['advanced']['#type'] = 'fieldset';
$form['advanced']['#title'] = t('Advanced Options');
- $form['advanced']['#collapsed'] = true;
- $form['advanced']['#collapsible'] = true;
+ $form['advanced']['#collapsed'] = TRUE;
+ $form['advanced']['#collapsible'] = TRUE;
}
return $form;
@@ -397,7 +619,7 @@ function backup_migrate_ui_destination_restore_file_confirm_submit($form, &$form
if ($destination_id && $file_id) {
backup_migrate_perform_restore($destination_id, $file_id, $form_state['values']);
}
- $redir = user_access('access backup files') ? BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/". $destination_id : BACKUP_MIGRATE_MENU_PATH;
+ $redir = user_access('access backup files') ? BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/" . $destination_id : BACKUP_MIGRATE_MENU_PATH;
$form_state['redirect'] = $redir;
}
@@ -408,6 +630,10 @@ function backup_migrate_ui_destination_delete_file($destination_id = NULL, $file
if (backup_migrate_destination_file_exists($destination_id, $file_id)) {
return drupal_get_form('backup_migrate_ui_destination_delete_file_confirm', $destination_id, $file_id);
}
+ _backup_migrate_message('Cannot delete the file: %file_id because it does not exist.', array('%file_id' => $file_id), 'error');
+ if ($destination_id && user_access('access backup files')) {
+ drupal_goto(BACKUP_MIGRATE_MENU_PATH . '/destination/list/files/' . $destination_id);
+ }
drupal_goto(BACKUP_MIGRATE_MENU_PATH);
}
@@ -417,7 +643,7 @@ function backup_migrate_ui_destination_delete_file($destination_id = NULL, $file
function backup_migrate_ui_destination_delete_file_confirm($form, &$form_state, $destination_id, $file_id) {
$form['destination_id'] = array('#type' => 'value', '#value' => $destination_id);
$form['file_id'] = array('#type' => 'value', '#value' => $file_id);
- return confirm_form($form, t('Are you sure you want to delete the backup file?'), BACKUP_MIGRATE_MENU_PATH . '/destination/list/files/'. $destination_id, t('Are you sure you want to delete the backup file %file_id? This action cannot be undone.', array('%file_id' => $file_id)), t('Delete'), t('Cancel'));
+ return confirm_form($form, t('Are you sure you want to delete the backup file?'), BACKUP_MIGRATE_MENU_PATH . '/destination/list/files/' . $destination_id, t('Are you sure you want to delete the backup file %file_id? This action cannot be undone.', array('%file_id' => $file_id)), t('Delete'), t('Cancel'));
}
/**
@@ -430,63 +656,125 @@ function backup_migrate_ui_destination_delete_file_confirm_submit($form, &$form_
backup_migrate_destination_delete_file($destination_id, $file_id);
_backup_migrate_message('Database backup file deleted: %file_id', array('%file_id' => $file_id));
}
- $form_state['redirect'] = user_access('access backup files') ? BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/". $destination_id : BACKUP_MIGRATE_MENU_PATH;
+ $form_state['redirect'] = user_access('access backup files') ? BACKUP_MIGRATE_MENU_PATH . "/destination/list/files/" . $destination_id : BACKUP_MIGRATE_MENU_PATH;
}
/* Utilities */
/**
- * Get the source options as a form element.
+ * Get pulldown to select existing source options.
*/
-function _backup_migrate_get_source_form($source_id = 'db') {
- backup_migrate_include('destinations');
+function _backup_migrate_get_destination_pulldown($op, $destination_id = NULL, $copy_destination_id = NULL) {
+ drupal_add_js(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.js');
- $form = array();
- $sources = _backup_migrate_get_source_pulldown($source_id);
- if (count($sources['#options']) > 1) {
- $form['source'] = array(
- "#type" => "fieldset",
- "#title" => t("Backup Source"),
- "#collapsible" => TRUE,
- "#collapsed" => FALSE,
- "#tree" => FALSE,
- );
- $sources['#description'] = t("Choose the database to backup. Any database destinations you have created and any databases specified in your settings.php can be backed up.");
+ $destinations = _backup_migrate_get_destination_form_item_options($op);
+ $form = array(
+ '#element_validate' => array('_backup_migrate_destination_pulldown_validate'),
+ '#after_build' => array('_backup_migrate_process_destination_pulldown'),
+ );
+ $form['destination_id'] = array(
+ '#type' => 'select',
+ '#title' => t('Backup Destination'),
+ '#options' => $destinations,
+ '#default_value' => $destination_id,
+ // '#process' => array('_backup_migrate_process_destination_pulldown'),
+ );
+ if (user_access('administer backup and migrate')) {
+ $form['destination_id']['#description'] = l(t('Create new destination'), BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add');
+ }
+ $form['copy'] = array(
+ '#type' => 'checkbox',
+ '#title' => '' . t('Save a copy to a second destination') . '',
+ '#default_value' => !empty($copy_destination_id),
+ );
+ $form['copy_destination'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'copy' => TRUE,
+ ),
+ );
+ $form['copy_destination']['copy_destination_id'] = array(
+ '#type' => 'select',
+ '#title' => t('Second Backup Destination'),
+ '#options' => $destinations,
+ '#default_value' => $copy_destination_id,
+ );
- $form['source']['source_id'] = $sources;
- }
- else {
- $form = array();
- $form['source']['source_id'] = array(
- "#type" => "value",
- "#value" => $source_id,
- );
- }
return $form;
}
/**
- * Get pulldown to select existing source options.
+ * Return the destination pulldown with an option to save a second copy.
*/
-function _backup_migrate_get_source_pulldown($source_id = NULL) {
- backup_migrate_include('destinations');
- $sources = _backup_migrate_get_destination_form_item_options('source');
- $form = array(
- "#type" => "select",
- "#title" => t("Backup Source"),
- "#options" => _backup_migrate_get_destination_form_item_options('source'),
- "#default_value" => $source_id,
+function _backup_migrate_process_destination_pulldown($element) {
+ $id = $element['destination_id']['#id'];
+ $settings = array(
+ 'backup_migrate' => array(
+ 'destination_selectors' => array(
+ $id => array(
+ 'destination_selector' => $id,
+ 'copy_destination_selector' => $element['copy_destination']['copy_destination_id']['#id'],
+ 'copy' => $element['copy']['#id'],
+ 'labels' => array(
+ t('Local') => t('Save an offsite copy to'),
+ t('Offsite') => t('Save a local copy to'),
+ ),
+ ),
+ ),
+ ),
);
- return $form;
+ drupal_add_js($settings, 'setting');
+
+ return $element;
+}
+
+/**
+ * Validate the destination and second destination widget.
+ */
+function _backup_migrate_destination_pulldown_validate($element, &$form_state, $form) {
+ if (empty($element['copy']['#value']) || $element['copy_destination']['copy_destination_id']['#value'] == $element['destination_id']['#value']) {
+ _backup_migrate_destination_pulldown_set_value($form_state['values'], $element['copy_destination']['copy_destination_id']['#parents'], '');
+ }
+}
+
+/**
+ * Set the value of a form field given it's parent array.
+ */
+function _backup_migrate_destination_pulldown_set_value(&$values, $parents, $value) {
+ $key = array_shift($parents);
+ if (empty($parents)) {
+ $values[$key] = $value;
+ }
+ else {
+ _backup_migrate_destination_pulldown_set_value($values[$key], $parents, $value);
+ }
}
/**
* Get the destination options as an options array for a form item.
*/
function _backup_migrate_get_destination_form_item_options($op) {
- $out = array();
+ $remote = $local = array();
foreach (backup_migrate_get_destinations($op) as $key => $destination) {
- $out[$key] = $destination->get_name();
+ // Only work with destinations that are currently configured and will work.
+ if ($destination->confirm_destination()) {
+ if ($destination->op('remote backup')) {
+ $remote[$key] = $destination->get_name();
+ }
+ else {
+ $local[$key] = $destination->get_name();
+ }
+ }
+ }
+ $out = array();
+ if ($remote && $local) {
+ $out = array(
+ t('Local') => $local,
+ t('Offsite') => $remote,
+ );
+ }
+ else {
+ $out = $remote + $local;
}
return $out;
}
@@ -494,23 +782,33 @@ function _backup_migrate_get_destination_form_item_options($op) {
/**
* A base class for creating destinations.
*/
-class backup_migrate_destination extends backup_migrate_item {
- var $db_table = "backup_migrate_destinations";
- var $type_name = "destination";
- var $default_values = array('settings' => array());
- var $singular = 'destination';
- var $plural = 'destinations';
- var $cache_files = FALSE;
- var $fetch_time = NULL;
- var $cache_expire = 86400; // 24 hours
-
- var $destination_type = "";
- var $supported_ops = array();
+class backup_migrate_destination extends backup_migrate_location {
+ public $db_table = 'backup_migrate_destinations';
+ public $type_name = 'destination';
+ public $default_values = array('settings' => array());
+ public $singular = 'destination';
+ public $plural = 'destinations';
+ public $title_plural = 'Destinations';
+ public $title_singular = 'Destination';
+ public $cache_files = FALSE;
+ public $fetch_time = NULL;
+ public $weight = 0;
+ public $destination_type = '';
+ public $supported_ops = array();
/**
- * This function is not supposed to be called. It is just here to help the po extractor out.
+ * 24 hours, i.e. 24 * 60 * 60 seconds.
+ *
+ * @var int.
*/
- function strings() {
+ public $cache_expire = 86400;
+
+ /**
+ * This function is not supposed to be called.
+ *
+ * It is just here to help the po extractor out.
+ */
+ public function strings() {
// Help the pot extractor find these strings.
t('Destination');
t('Destinations');
@@ -518,79 +816,10 @@ class backup_migrate_destination extends backup_migrate_item {
t('destination');
}
- function ops() {
- return $this->supported_ops;
- }
-
- /**
- * Does this destination support the given operation.
- */
- function op($op) {
- $ops = (array)$this->ops();
- return in_array($op, $ops);
- }
-
- /**
- * Remove the given op from the support list.
- */
- function remove_op($op) {
- $key = array_search($op, $this->supported_ops);
- if ($key !== FALSE) {
- unset($this->supported_ops[$key]);
- }
- }
-
- function get_name() {
- return @$this->name;
- }
-
- function set_name($name) {
- return $this->name = $name;
- }
-
- function set_type($type) {
- $this->type = $type;
- }
-
- function set_location($location) {
- $this->location = $location;
- }
-
- function get_location() {
- return @$this->location;
- }
-
- function get_display_location() {
- return $this->get_location();
- }
-
- function file_types() {
- return array();
- }
-
- function settings($key = NULL) {
- $out = $this->settings;
- if ($key) {
- $out = isset($out[$key]) ? $out[$key] : NULL;
- }
- return $out;
- }
-
- /**
- * Get the type name of this destination for display to the user.
- */
- function get_destination_type_name() {
- if ($type = $this->destination_type) {
- $types = backup_migrate_get_destination_types();
- return isset($types[$type]['type_name']) ? $types[$type]['type_name'] : $type;
- }
- }
-
/**
* Save the given file to the destination.
*/
- function save_file($file, $settings) {
- // This must be overriden.
+ public function save_file($file, $settings) {
$this->file_cache_clear();
// Save the file metadata if the destination supports it.
@@ -601,75 +830,114 @@ class backup_migrate_destination extends backup_migrate_item {
/**
* Save the given file to the destination.
*/
- function _save_file($file, $settings) {
+ public function _save_file($file, $settings) {
// This must be overriden.
return $file;
}
/**
- * Save the file metadata
+ * Save the file metadata.
+ *
+ * @return object
+ * The file object after it has been saved.
*/
- function save_file_info($file, $settings) {
+ public function save_file_info($file, $settings) {
$info = $this->create_info_file($file);
// Save the info file and the actual file.
return $this->_save_file($info, $settings);
}
/**
- * Load the file with the given destination specific id and return as a backup_file object.
+ * Load the file with the given destination specific ID.
+ *
+ * @return \backup_file
+ * A backup file.
*/
- function load_file($file_id) {
+ public function load_file($file_id) {
// This must be overriden.
return NULL;
}
/**
- * Check if a file exists in the given destination.
+ * Check if the file exists in the list of available files.
+ *
+ * Actual destination types may have more efficient ways of doing this.
*/
- function file_exists($file_id) {
- // Check if the file exists in the list of available files. Actual destination types may have more efficient ways of doing this.
+ public function file_exists($file_id) {
$files = $this->list_files();
return isset($files[$file_id]);
}
/**
- * List all the available files in the given destination with their destination specific id.
+ * List all the available files in the given destination.
+ *
+ * Includes their destination specific id.
*/
- function list_files() {
- $out = NULL;
+ public function list_files() {
+ $files = NULL;
if ($this->cache_files) {
- $out = $this->file_cache_get();
+ $files = $this->file_cache_get();
}
- if ($out === NULL) {
- $out = $this->_list_files();
- $out = $this->load_files_info($out);
+ if ($files === NULL) {
+ require_once dirname(__FILE__) . '/files.inc';
+
+ $files = $this->_list_files();
+ $files = $this->load_files_info($files);
if ($this->cache_files) {
- $this->file_cache_set($out);
+ $this->file_cache_set($files);
+ }
+
+ // Clean up any previous abandoned tmp files before going further.
+ _backup_migrate_temp_files_delete();
+ }
+
+ $out = array();
+ if (is_array($files)) {
+ foreach ($files as $id => $file) {
+ if ($file->is_recognized_type()) {
+ $out[$id] = $file;
+ $out[$id]->destination = &$this;
+ }
}
}
return $out;
}
/**
- * List all the available files in the given destination with their destination specific id.
+ * Count all the available files in the given destination.
*/
- function _list_files() {
+ public function count_files() {
+ return count($this->list_files());
+ }
+
+ /**
+ * List all the available files in the given destination.
+ *
+ * Includes their destination specific id.
+ */
+ public function _list_files() {
return array();
}
/**
* Load up the file's metadata from the accompanying .info file if applicable.
*/
- function load_files_info($files) {
+ public function load_files_info($files) {
foreach ($files as $key => $file) {
+ // See if there is an info file with the same name as the backup.
if (isset($files[$key . '.info'])) {
- // See if there is an info file with the same name as the backup.
- $info = drupal_parse_info_file($files[$key . '.info']->filepath());
+ $info_file = $this->load_file($files[$key . '.info']->file_id());
+ $info = drupal_parse_info_file($info_file->filepath());
// Allow the stored metadata to override the detected metadata.
+ unset($info['filename']);
$file->file_info = $info + $file->file_info;
- // Remove the metadata file from the list
+ // Remove the metadata file from the list.
unset($files[$key . '.info']);
}
+
+ // Add destination specific info.
+ $file->info_set('destination_id', $this->get('id'));
+ $file->info_set('remote', $this->get('remote'));
}
return $files;
@@ -678,7 +946,7 @@ class backup_migrate_destination extends backup_migrate_item {
/**
* Create an ini file and write the meta data.
*/
- function create_info_file($file) {
+ public function create_info_file($file) {
$info = $this->_file_info_file($file);
$data = _backup_migrate_array_to_ini($file->file_info);
$info->put_contents($data);
@@ -688,7 +956,7 @@ class backup_migrate_destination extends backup_migrate_item {
/**
* Create the info file object.
*/
- function _file_info_file($file) {
+ public function _file_info_file($file) {
$info = new backup_file(array('filename' => $this->_file_info_filename($file->file_id())));
return $info;
}
@@ -696,35 +964,37 @@ class backup_migrate_destination extends backup_migrate_item {
/**
* Determine the file name of the info file for a file.
*/
- function _file_info_filename($file_id) {
+ public function _file_info_filename($file_id) {
return $file_id . '.info';
}
/**
* Cache the file list.
*/
- function file_cache_set($files) {
- cache_set('backup_migrate_file_list:'. $this->get_id(), $files, 'cache', time() + $this->cache_expire);
+ public function file_cache_set($files) {
+ cache_set('backup_migrate_file_list:' . $this->get_id(), $files, 'cache', time() + $this->cache_expire);
}
/**
* Retrieve the file list.
*/
- function file_cache_get() {
- backup_migrate_include('files');
- $cache = cache_get('backup_migrate_file_list:'. $this->get_id());
+ public function file_cache_get() {
+ require_once dirname(__FILE__) . '/files.inc';
+
+ $cache = cache_get('backup_migrate_file_list:' . $this->get_id());
if (!empty($cache->data) && $cache->created > (time() - $this->cache_expire)) {
$this->fetch_time = $cache->created;
return $cache->data;
}
$this->fetch_time = 0;
+
return NULL;
}
/**
* Retrieve the file list.
*/
- function file_cache_clear() {
+ public function file_cache_clear() {
if ($this->cache_files) {
$this->file_cache_set(NULL);
}
@@ -733,7 +1003,7 @@ class backup_migrate_destination extends backup_migrate_item {
/**
* Delete the file with the given destination specific id.
*/
- function delete_file($file_id) {
+ public function delete_file($file_id) {
$this->file_cache_clear();
$this->_delete_file($file_id);
$this->_delete_file($this->_file_info_filename($file_id));
@@ -742,41 +1012,70 @@ class backup_migrate_destination extends backup_migrate_item {
/**
* Delete the file with the given destination specific id.
*/
- function _delete_file($file_id) {
+ public function _delete_file($file_id) {
// This must be overriden.
}
/**
* Get the edit form for the item.
*/
- function edit_form() {
+ public function edit_form() {
if (get_class($this) !== 'backup_migrate_destination') {
$form = parent::edit_form();
- $form['name'] = array(
- "#type" => "textfield",
- "#title" => t("Destination name"),
- "#default_value" => $this->get_name(),
- "#required" => TRUE,
- );
- $form['type'] = array(
+ $form['subtype'] = array(
"#type" => "value",
- "#default_value" => $this->destination_type,
+ "#default_value" => $this->get('subtype'),
);
}
else {
- $types = backup_migrate_get_destination_types();
- $items = array();
- // If no (valid) node type has been provided, display a node type overview.
+ $types = backup_migrate_get_destination_subtypes();
+ $items = array(
+ 'remote' => array(
+ 'title' => t('Offsite Destinations'),
+ 'description' => t('For the highest level of protection, set up an offsite backup destination in a location separate from your website.'),
+ 'items' => array(),
+ ),
+ 'local' => array(
+ 'title' => t('Local Destinations'),
+ 'description' => t('Local backups are quick and convenient but do not provide the additional safety of offsite backups.'),
+ 'items' => array(),
+ ),
+ 'other' => array(
+ 'title' => t('Other Destinations'),
+ 'description' => t('These destinations have not been classified because they were created for Backup and Migrate version 2. They may not work correctly with this version.'),
+ 'items' => array(),
+ ),
+
+ );
+
+ // If no (valid) node type has been provided, display a node type
+ // overview.
+ $path = $this->get_settings_path();
foreach ($types as $key => $type) {
if (@$type['can_create']) {
$type_url_str = str_replace('_', '-', $key);
- $out = '
'. l($type['type_name'], BACKUP_MIGRATE_MENU_PATH . "/destination/list/add/$type_url_str", array('attributes' => array('title' => t('Add a new @s destination.', array('@s' => $type['type_name']))))) .'
';
- $out .= '
'. filter_xss_admin($type['description']) .'
';
- $items[] = $out;
+ $out = '
' . l($type['type_name'], $path . "/add/$type_url_str", array('attributes' => array('title' => t('Add a new @s destination.', array('@s' => $type['type_name']))))) . '
';
+ $out .= '
' . filter_xss_admin($type['description']) . '
';
+
+ if (!empty($type['local'])) {
+ $items['local']['items'][] = $out;
+ }
+ if (!empty($type['remote'])) {
+ $items['remote']['items'][] = $out;
+ }
+ if (empty($type['local']) && empty($type['remote'])) {
+ $items['other']['items'][] = $out;
+ }
}
}
- if (count($items)) {
- $output = t('Choose the type of destination you would like to create:') .'
' . t('Choose the type of destination you would like to create:') . '
';
+ foreach ($items as $group) {
+ if (count($group['items'])) {
+ $group['body'] = '
' . implode('', $group['items']) . '
';
+ $output .= theme('backup_migrate_group', $group);
+ }
+ }
}
else {
$output = t('No destination types available.');
@@ -790,49 +1089,30 @@ class backup_migrate_destination extends backup_migrate_item {
}
/**
- * Get the message to send to the user when confirming the deletion of the item.
+ * Get a message to send to the user when confirming the deletion of the item.
*/
- function delete_confirm_message() {
+ public function delete_confirm_message() {
return t('Are you sure you want to delete the destination %name? Backup files already saved to this destination will not be deleted.', array('%name' => $this->get_name()));
}
-
/**
- * Get the columns needed to list the type.
- */
- function get_list_column_info() {
- $out = parent::get_list_column_info();
- $out = array(
- 'name' => array('title' => t('Name')),
- 'destination_type_name' => array('title' => t('Type')),
- 'display_location' => array('title' => t('Location')),
- ) + $out;
- return $out;
- }
-
- /**
- * Get a row of data to be used in a list of items of this type.
- */
- function get_list_row() {
- $out = parent::get_list_row();
-
- // Supress destinations with no actions as there's no value in showing them (and they may confuse new users).
- if (empty($out['actions'])) {
- return NULL;
- }
- return $out;
+ * Get a boolean representing if the destination is remote or local.
+ */
+ public function get_remote() {
+ return $this->op('remote backup');
}
/**
* Get the action links for a destination.
*/
- function get_action_links() {
+ public function get_action_links() {
$out = parent::get_action_links();
$item_id = $this->get_id();
- // Don't display the download/delete/restore ops if they are not available for this destination.
+ // Don't display the download/delete/restore ops if they are not available
+ // for this destination.
if ($this->op('list files') && user_access("access backup files")) {
- $out = array('list files' => l(t("list files"), BACKUP_MIGRATE_MENU_PATH . "/$this->type_name/list/files/". $item_id)) + $out;
+ $out = array('list files' => l(t("list files"), $this->get_settings_path() . '/list/files/' . $item_id)) + $out;
}
if (!$this->op('configure') || !user_access('administer backup and migrate')) {
unset($out['edit']);
@@ -843,22 +1123,25 @@ class backup_migrate_destination extends backup_migrate_item {
/**
* Get the action links for a file on a given destination.
*/
- function get_file_links($file_id) {
- $out = array('download' => '', 'restore' => '', 'delete' => '');
+ public function get_file_links($file_id) {
+ $out = array();
- // Don't display the download/delete/restore ops if they are not available for this destination.
- $can_read = $this->can_read_file($file_id);
- $can_delete = $this->can_delete_file($file_id);
+ // Don't display the download/delete/restore ops if they are not available
+ // for this destination.
+ $can_read = $this->can_read_file($file_id);
+ $can_delete = $this->can_delete_file($file_id);
+
+ $path = $this->get_settings_path();
$destination_id = $this->get_id();
if ($can_read && user_access("access backup files")) {
- $out['download'] = l(t("download"), BACKUP_MIGRATE_MENU_PATH . "/destination/downloadfile/". $destination_id .'/'. $file_id);
+ $out[] = l(t("download"), $path . '/downloadfile/' . $destination_id . '/' . $file_id);
}
if ($can_read && user_access("restore from backup")) {
- $out['restore'] = l(t("restore"), BACKUP_MIGRATE_MENU_PATH . "/destination/restorefile/". $destination_id .'/'. $file_id);
+ $out[] = l(t("restore"), $path . '/list/restorefile/' . $destination_id . '/' . $file_id);
}
if ($can_delete && user_access("delete backup files")) {
- $out['delete'] = l(t("delete"), BACKUP_MIGRATE_MENU_PATH . "/destination/deletefile/". $destination_id .'/'. $file_id);
+ $out[] = l(t("delete"), $path . '/list/deletefile/' . $destination_id . '/' . $file_id);
}
return $out;
}
@@ -866,237 +1149,148 @@ class backup_migrate_destination extends backup_migrate_item {
/**
* Determine if we can read the given file.
*/
- function can_read_file($file_id) {
+ public function can_read_file($file_id) {
return $this->op('restore');
}
/**
* Determine if we can read the given file.
*/
- function can_delete_file($file_id) {
+ public function can_delete_file($file_id) {
return $this->op('delete');
}
/**
* Get the form for the settings for this destination type.
*/
- function settings_default() {
+ public function settings_default() {
return array();
}
/**
* Get the form for the settings for this destination.
*/
- function settings_form($form) {
+ public function settings_form($form) {
return $form;
}
/**
* Validate the form for the settings for this destination.
*/
- function settings_form_validate($form_values) {
+ public function settings_form_validate($form_values) {
}
/**
* Submit the settings form. Any values returned will be saved.
*/
- function settings_form_submit($form_values) {
+ public function settings_form_submit($form_values) {
return $form_values;
}
-
/**
- * Create a new destination of the correct type.
+ * Check that a destination is valid.
*/
- function create($params = array()) {
- $out = NULL;
- $types = backup_migrate_get_destination_types();
-
- // Get the type passed in in the params, or if none, check the url for a valid type name.
- // This is to allow new destination type to be specified in the path.
- $destination_type = !empty($params['type']) ? $params['type'] : arg(BACKUP_MIGRATE_MENU_DEPTH + 3);
-
- if ($destination_type && ($type = @$types[$destination_type])) {
- // Include the necessary file if specified by the type.
- if (!empty($type['file'])) {
- require_once './'. $type['file'];
- }
- $out = new $type['class']($params + array('destination_type' => $destination_type));
- }
- if (empty($out)) {
- $out = new backup_migrate_destination();
- }
- return $out;
+ public function confirm_destination() {
+ return TRUE;
}
/**
* Add the menu items specific to the destination type.
*/
- function get_menu_items() {
+ public function get_menu_items() {
$items = parent::get_menu_items();
- $items[BACKUP_MIGRATE_MENU_PATH . '/destination/list/files'] = array(
+
+ $path = $this->get_settings_path();
+
+ $items[$path . '/list/files'] = array(
'title' => 'Destination Files',
'page callback' => 'backup_migrate_menu_callback',
- 'page arguments' => array('destinations', 'backup_migrate_ui_destination_display_files', TRUE),
+ 'page arguments' => array(
+ 'destinations',
+ 'backup_migrate_ui_destination_display_files',
+ TRUE,
+ ),
'access arguments' => array('access backup files'),
'type' => MENU_LOCAL_TASK,
);
- $items[BACKUP_MIGRATE_MENU_PATH . '/destination/deletefile'] = array(
+ $items[$path . '/list/deletefile'] = array(
'title' => 'Delete File',
'description' => 'Delete a backup file',
'page callback' => 'backup_migrate_menu_callback',
- 'page arguments' => array('destinations', 'backup_migrate_ui_destination_delete_file', TRUE),
+ 'page arguments' => array(
+ 'destinations',
+ 'backup_migrate_ui_destination_delete_file',
+ TRUE,
+ ),
'access arguments' => array('delete backup files'),
- 'type' => MENU_CALLBACK,
+ 'type' => MENU_LOCAL_TASK,
);
- $items[BACKUP_MIGRATE_MENU_PATH . '/destination/restorefile'] = array(
+ $items[$path . '/list/restorefile'] = array(
'title' => 'Restore from backup',
'description' => 'Restore database from a backup file on the server',
'page callback' => 'backup_migrate_menu_callback',
- 'page arguments' => array('destinations', 'backup_migrate_ui_destination_restore_file', TRUE),
+ 'page arguments' => array(
+ 'destinations',
+ 'backup_migrate_ui_destination_restore_file',
+ TRUE,
+ ),
'access arguments' => array('restore from backup'),
- 'type' => MENU_CALLBACK,
+ 'type' => MENU_LOCAL_TASK,
);
- $items[BACKUP_MIGRATE_MENU_PATH . '/destination/downloadfile'] = array(
+ $items[$path . '/downloadfile'] = array(
'title' => 'Download File',
'description' => 'Download a backup file',
'page callback' => 'backup_migrate_menu_callback',
- 'page arguments' => array('destinations', 'backup_migrate_ui_destination_download_file', TRUE),
+ 'page arguments' => array(
+ 'destinations',
+ 'backup_migrate_ui_destination_download_file',
+ TRUE,
+ ),
'access arguments' => array('access backup files'),
'type' => MENU_CALLBACK,
);
return $items;
}
- /**
- * Get the form for the settings for this filter.
- */
- function backup_settings_default() {
- return array();
- }
-
- /**
- * Get the form for the settings for this filter.
- */
- function backup_settings_form($settings) {
- return array();
- }
-
- /**
- * Get the form for the settings for this filter.
- */
- function backup_settings_form_validate($form, &$form_state) {
- }
-
- /**
- * Submit the settings form. Any values returned will be saved.
- */
- function backup_settings_form_submit($form, &$form_state) {
- }
-
- /**
- * Get the form for the settings for this filter.
- */
- function restore_settings_default() {
- return array();
- }
-
- /**
- * Get the form for the settings for this filter.
- */
- function restore_settings_form($settings) {
- return array();
- }
-
- /**
- * Get the form for the settings for this filter.
- */
- function restore_settings_form_validate($form_values) {
- }
-
- /**
- * Submit the settings form. Any values returned will be saved.
- */
- function restore_settings_form_submit($form_values) {
- return $form_values;
- }
}
/**
* A base class for creating destinations.
*/
class backup_migrate_destination_remote extends backup_migrate_destination {
+
/**
* The location is a URI so parse it and store the parts.
*/
- function get_location() {
+ public function get_location() {
return $this->url(FALSE);
}
/**
* The location to display is the url without the password.
*/
- function get_display_location() {
+ public function get_display_location() {
return $this->url(TRUE);
}
/**
* Return the location with the password.
*/
- function set_location($location) {
+ public function set_location($location) {
$this->location = $location;
$this->set_url($location);
}
- /**
- * Get a url from the parts.
- */
- function url($hide_password = TRUE) {
- return $this->glue_url($this->dest_url, $hide_password);
- }
-
- /**
- * Glue a URLs component parts back into a URL.
- */
- function glue_url($parts, $hide_password = TRUE) {
- // Obscure the password if we need to.
- $parts['pass'] = $hide_password ? "" : $parts['pass'];
-
- // Assemble the URL.
- $out = "";
- $out .= $parts['scheme'] .'://';
- $out .= $parts['user'] ? urlencode($parts['user']) : '';
- $out .= ($parts['user'] && $parts['pass']) ? ":". urlencode($parts['pass']) : '';
- $out .= ($parts['user'] || $parts['pass']) ? "@" : "";
- $out .= $parts['host'];
- $out .= !empty($parts['port']) ? ':'. $parts['port'] : '';
- $out .= "/". $parts['path'];
- return $out;
- }
-
- /**
- * Break a URL into it's component parts.
- */
- function set_url($url) {
- $parts = (array)parse_url($url);
- $parts['user'] = urldecode(@$parts['user']);
- $parts['pass'] = urldecode(@$parts['pass']);
- $parts['path'] = urldecode(@$parts['path']);
- $parts['path'] = ltrim(@$parts['path'], "/");
- $this->dest_url = $parts;
- }
-
/**
* Destination configuration callback.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['scheme'] = array(
- "#type" => "value",
+ "#type" => "textfield",
"#title" => t("Scheme"),
- "#default_value" => @$this->dest_url['scheme'] ? $this->dest_url['scheme'] : 'mysql',
+ "#default_value" => @$this->dest_url['scheme'] ? $this->dest_url['scheme'] : '',
"#required" => TRUE,
-// "#options" => array($GLOBALS['db_type'] => $GLOBALS['db_type']),
"#weight" => 0,
);
$form['host'] = array(
@@ -1132,18 +1326,21 @@ class backup_migrate_destination_remote extends backup_migrate_destination {
"#type" => "value",
"#value" => @$this->dest_url['pass'],
);
- $form['pass']["#description"] .= t(' You do not need to enter a password unless you wish to change the currently saved password.');
+ $form['pass']["#description"] .= ' ' . t('You do not need to enter a password unless you wish to change the currently saved password.');
}
return $form;
}
/**
- * Submit the configuration form. Glue the url together and add the old password back if a new one was not specified.
+ * Submit the configuration form.
+ *
+ * Glue the url together and add the old password back if a new one was not
+ * specified.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
$form_state['values']['pass'] = $form_state['values']['pass'] ? $form_state['values']['pass'] : $form_state['values']['old_password'];
$form_state['values']['location'] = $this->glue_url($form_state['values'], FALSE);
parent::edit_form_submit($form, $form_state);
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.s3.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.s3.inc
index 8937162..fbf8db7 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.s3.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/destinations.s3.inc
@@ -1,6 +1,5 @@
s3_object()) {
$path = $file->filename();
if ($s3->putObject($s3->inputFile($file->filepath(), FALSE), $this->get_bucket(), $this->remote_path($file->filename()), S3::ACL_PRIVATE)) {
@@ -33,8 +31,9 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Load from the s3 destination.
*/
- function load_file($file_id) {
- backup_migrate_include('files');
+ public function load_file($file_id) {
+ require_once dirname(__FILE__) . '/files.inc';
+
$file = new backup_file(array('filename' => $file_id));
if ($s3 = $this->s3_object()) {
$data = $s3->getObject($this->get_bucket(), $this->remote_path($file_id), $file->filepath());
@@ -42,13 +41,14 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
return $file;
}
}
+
return NULL;
}
/**
* Delete from the s3 destination.
*/
- function _delete_file($file_id) {
+ public function _delete_file($file_id) {
if ($s3 = $this->s3_object()) {
$s3->deleteObject($this->get_bucket(), $this->remote_path($file_id));
}
@@ -57,12 +57,13 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* List all files from the s3 destination.
*/
- function _list_files() {
- backup_migrate_include('files');
+ public function _list_files() {
+ require_once dirname(__FILE__) . '/files.inc';
+
$files = array();
if ($s3 = $this->s3_object()) {
$s3_files = $s3->getBucket($this->get_bucket(), $this->get_subdir());
- foreach ((array)$s3_files as $id => $file) {
+ foreach ((array) $s3_files as $id => $file) {
$info = array(
'filename' => $this->local_path($file['name']),
'filesize' => $file['size'],
@@ -71,21 +72,21 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
$files[$info['filename']] = new backup_file($info);
}
}
+
return $files;
}
/**
* Get the form for the settings for this filter.
*/
- function edit_form() {
+ public function edit_form() {
// Check for the library.
$this->s3_object();
$form = parent::edit_form();
$form['scheme']['#type'] = 'value';
$form['scheme']['#value'] = 'https';
- $form['host']['#type'] = 'value';
- $form['host']['#value'] = 's3.amazonaws.com';
+ $form['host']['#default_value'] = @$this->dest_url['host'] ? $this->dest_url['host'] : 's3.amazonaws.com';
$form['path']['#title'] = 'S3 Bucket';
$form['path']['#default_value'] = $this->get_bucket();
@@ -98,7 +99,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
'#type' => 'textfield',
'#title' => t('Subdirectory'),
'#default_value' => $this->get_subdir(),
- '#weight' => 25
+ '#weight' => 25,
);
$form['settings']['#weight'] = 50;
@@ -108,11 +109,10 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Submit the form for the settings for the s3 destination.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
// Append the subdir onto the path.
-
if (!empty($form_state['values']['subdir'])) {
- $form_state['values']['path'] .= '/'. trim($form_state['values']['subdir'], '/');
+ $form_state['values']['path'] .= '/' . trim($form_state['values']['subdir'], '/');
}
parent::edit_form_submit($form, $form_state);
}
@@ -120,9 +120,9 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Generate a filepath with the correct prefix.
*/
- function remote_path($path) {
+ public function remote_path($path) {
if ($subdir = $this->get_subdir()) {
- $path = $subdir .'/'. $path;
+ $path = $subdir . '/' . $path;
}
return $path;
}
@@ -130,9 +130,9 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Generate a filepath with the correct prefix.
*/
- function local_path($path) {
+ public function local_path($path) {
if ($subdir = $this->get_subdir()) {
- $path = str_replace($subdir .'/', '', $path);
+ $path = str_replace($subdir . '/', '', $path);
}
return $path;
}
@@ -140,7 +140,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Get the bucket which is the first part of the path.
*/
- function get_bucket() {
+ public function get_bucket() {
$parts = explode('/', @$this->dest_url['path']);
return $parts[0];
}
@@ -148,7 +148,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
/**
* Get the bucket which is the first part of the path.
*/
- function get_subdir() {
+ public function get_subdir() {
// Support the older style of subdir saving.
if ($subdir = $this->settings('subdir')) {
return $subdir;
@@ -158,7 +158,10 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
return implode('/', array_filter($parts));
}
- function s3_object() {
+ /**
+ *
+ */
+ public function s3_object() {
// Try to use libraries module if available to find the path.
if (function_exists('libraries_get_path')) {
$library_paths[] = libraries_get_path('s3-php5-curl');
@@ -169,11 +172,16 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
$library_paths[] = drupal_get_path('module', 'backup_migrate') . '/includes/s3-php5-curl';
$library_paths[] = drupal_get_path('module', 'backup_migrate') . '/includes';
- foreach($library_paths as $path) {
+ foreach ($library_paths as $path) {
if (file_exists($path . '/S3.php')) {
require_once $path . '/S3.php';
if (!$this->s3 && !empty($this->dest_url['user'])) {
- $this->s3 = new S3($this->dest_url['user'], $this->dest_url['pass']);
+ // The hostname can be overridden.
+ $host = 's3.amazonaws.com';
+ if (isset($this->dest_url['host'])) {
+ $host = $this->dest_url['host'];
+ }
+ $this->s3 = new S3($this->dest_url['user'], $this->dest_url['pass'], FALSE, $host);
}
return $this->s3;
}
@@ -181,4 +189,5 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote {
drupal_set_message(t('Due to drupal.org code hosting policies, the S3 library needed to use an S3 destination is no longer distributed with this module. You must download the library from !link and place it in one of these locations: %locations.', array('%locations' => implode(', ', $library_paths), '!link' => l('http://undesigned.org.za/2007/10/22/amazon-s3-php-class', 'http://undesigned.org.za/2007/10/22/amazon-s3-php-class'))), 'error', FALSE);
return NULL;
}
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/files.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/files.inc
index d7a61c2..b511814 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/files.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/files.inc
@@ -1,6 +1,5 @@
getDirectoryPath();
- $expire = time() - variable_get('backup_migrate_cleanup_time', 21600);
- if (file_exists($dir) && is_dir($dir) && is_readable($dir) && $handle = opendir($dir)) {
- while (FALSE !== ($file = @readdir($handle))) {
- // Delete 'backup_migrate_' files in the temp directory that are older than the expire time.
- // We should only attempt to delete writable files to prevent errors in shared environments.
- // This could still cause issues in shared environments with poorly configured file permissions.
- if (strpos($file, 'backup_migrate_') === 0 && is_writable("$dir/$file") && @filectime("$dir/$file") < $expire) {
- unlink("$dir/$file");
+/**
+ * Move files recursively.
+ */
+function _backup_migrate_move_files($from, $to) {
+ if (is_readable($from)) {
+ if (is_dir($from) && is_readable($from) && $handle = opendir($from)) {
+ if (!file_exists($to)) {
+ mkdir($to);
}
+ while (FALSE !== ($file = @readdir($handle))) {
+ if ($file != '..' && $file != '.') {
+ _backup_migrate_move_files("$from/$file", "$to/$file");
+ }
+ }
+ closedir($handle);
+ }
+ else {
+ rename($from, $to);
}
- closedir($handle);
}
+ return FALSE;
+}
+
+/**
+ * Create a temporary directory.
+ */
+function backup_migrate_temp_directory() {
+ $tmp = realpath(file_directory_temp());
+ // Check the writability of the temp directory.
+ if (!is_writable(realpath(file_directory_temp()))) {
+ _backup_migrate_message('Your temporary directory %tmp is not writable. Backup and migrate needs to be able to create temporary files.', array('%tmp' => $tmp), 'error');
+ }
+
+ // Use a full path so that the files can be deleted during the shutdown function if needed.
+ $file = $tmp . '/' . uniqid('backup_migrate_');
+ mkdir($file);
+ backup_migrate_temp_files_add($file);
+ return $file;
}
/**
* Return a list of backup filetypes.
*/
function _backup_migrate_filetypes() {
- backup_migrate_include('filters');
+ require_once dirname(__FILE__) . '/filters.inc';
$out = backup_migrate_filters_file_types();
foreach ($out as $key => $info) {
$out[$key]['id'] = empty($info['id']) ? $key : $info['id'];
}
+
return $out;
}
@@ -78,19 +140,33 @@ function _backup_migrate_filename_append_prepare($filename, $append_str) {
/**
* Construct a filename using token and some cleaning.
*/
-function _backup_migrate_construct_filename($filename, $timestamp='') {
- if (module_exists('token')) {
+function _backup_migrate_construct_filename($settings) {
+ // Get the raw filename from the settings.
+ $filename = $settings->filename;
+
+ // Replace any tokens.
+ if (module_exists('token') && function_exists('token_replace')) {
$filename = token_replace($filename);
}
- $filename = preg_replace("/[^a-zA-Z0-9\.\-_]/", "", $filename);
+
+ // Remove illegal characters.
+ $filename = _backup_migrate_clean_filename($filename);
+
+ // Generate a timestamp if needed.
+ $timestamp = '';
+ if ($settings->append_timestamp == 1 && $settings->timestamp_format) {
+ $timestamp = format_date(time(), 'custom', $settings->timestamp_format);
+ }
+
+ // Trim to length if needed to allow the timestamp to fit into the max filename.
$filename = _backup_migrate_filename_append_prepare($filename, $timestamp);
$filename .= '-' . $timestamp;
$filename = trim($filename, '-');
+ // If there is no filename, then just call it untitled.
if (drupal_strlen($filename) == 0) {
$filename = 'untitled';
}
-
return $filename;
}
@@ -102,11 +178,20 @@ function _backup_migrate_default_filename() {
return '[site:name]';
}
else {
- // Cleaning the string isn't strictly necessary but it looks better in the settings field.
- return variable_get('site_name', 'backup_migrate');
+ // Cleaning the string isn't strictly necessary but it looks better in the
+ // settings field.
+ return _backup_migrate_clean_filename(variable_get('site_name', "backup_migrate"));
}
}
+/**
+ * Clean up a filename to remove unsafe characters.
+ */
+function _backup_migrate_clean_filename($filename) {
+ $filename = preg_replace("/[^a-zA-Z0-9\.\-_]/", "", $filename);
+ return $filename;
+}
+
/**
* An output buffer callback which simply throws away the buffer instead of sending it to the browser.
*/
@@ -114,22 +199,21 @@ function _backup_migrate_file_dispose_buffer($buffer) {
return "";
}
-
/**
* A backup file which allows for saving to and reading from the server.
*/
class backup_file {
- var $file_info = array();
- var $type = array();
- var $ext = array();
- var $path = "";
- var $name = "";
- var $handle = NULL;
+ public $file_info = array();
+ public $type = array();
+ public $ext = array();
+ public $path = "";
+ public $name = "";
+ public $handle = NULL;
/**
* Construct a file object given a file path, or create a temp file for writing.
*/
- function backup_file($params = array()) {
+ public function __construct($params = array()) {
if (isset($params['filepath']) && file_exists($params['filepath'])) {
$this->set_filepath($params['filepath']);
}
@@ -142,7 +226,7 @@ class backup_file {
/**
* Get the file_id if the file has been saved to a destination.
*/
- function file_id() {
+ public function file_id() {
// The default file_id is the filename. Destinations can override the file_id if needed.
return isset($this->file_info['file_id']) ? $this->file_info['file_id'] : $this->filename();
}
@@ -150,27 +234,33 @@ class backup_file {
/**
* Get the current filepath.
*/
- function filepath() {
- return drupal_realpath($this->path);
+ public function filepath() {
+ if ($filepath = drupal_realpath($this->path)) {
+ return $filepath;
+ }
+ return $this->path;
}
/**
* Get the final filename.
*/
- function filename($name = NULL) {
+ public function filename($name = NULL) {
if ($name) {
$this->name = $name;
}
- return $this->name .'.'. $this->extension();
+ $extension_str = '.' . $this->extension();
+ $this->name = _backup_migrate_filename_append_prepare($this->name, $extension_str);
+ return $this->name . $extension_str;
}
/**
* Set the current filepath.
*/
- function set_filepath($path) {
+ public function set_filepath($path) {
$this->path = $path;
$params = array(
'filename' => basename($path),
+ 'file_id' => basename($path),
);
if (file_exists($path)) {
$params['filesize'] = filesize($path);
@@ -182,67 +272,93 @@ class backup_file {
/**
* Get one or all pieces of info for the file.
*/
- function info($key = NULL) {
+ public function info($key = NULL) {
if ($key) {
return @$this->file_info[$key];
}
return $this->file_info;
}
+ /**
+ * Get one or all pieces of info for the file.
+ */
+ public function info_set($key, $value) {
+ $this->file_info[$key] = $value;
+ }
+
/**
* Get the file extension.
*/
- function extension() {
+ public function extension() {
return implode(".", $this->ext);
}
/**
* Get the file type.
*/
- function type() {
+ public function type() {
return $this->type;
}
/**
* Get the file mimetype.
*/
- function mimetype() {
+ public function mimetype() {
return @$this->type['filemime'] ? $this->type['filemime'] : 'application/octet-stream';
}
/**
* Get the file mimetype.
*/
- function type_id() {
+ public function type_id() {
return @$this->type['id'];
}
+ /**
+ *
+ */
+ public function filesize() {
+ if (empty($this->file_info['filesize'])) {
+ $this->calculate_filesize();
+ }
+ return $this->file_info['filesize'];
+ }
+
+ /**
+ *
+ */
+ public function calculate_filesize() {
+ $this->file_info['filesize'] = '';
+ if (!empty($this->path) && file_exists($this->path)) {
+ $this->file_info['filesize'] = filesize($this->path);
+ }
+ }
/**
* Can this file be used to backup to.
*/
- function can_backup() {
+ public function can_backup() {
return @$this->type['backup'];
}
/**
* Can this file be used to restore to.
*/
- function can_restore() {
+ public function can_restore() {
return @$this->type['restore'];
}
/**
* Can this file be used to restore to.
*/
- function is_recognized_type() {
+ public function is_recognized_type() {
return @$this->type['restore'] || @$this->type['backup'];
}
/**
* Open a file for reading or writing.
*/
- function open($write = FALSE, $binary = FALSE) {
+ public function open($write = FALSE, $binary = FALSE) {
if (!$this->handle) {
$path = $this->filepath();
@@ -267,7 +383,7 @@ class backup_file {
/**
* Close a file when we're done reading/writing.
*/
- function close() {
+ public function close() {
fclose($this->handle);
$this->handle = NULL;
}
@@ -275,7 +391,7 @@ class backup_file {
/**
* Write a line to the file.
*/
- function write($data) {
+ public function write($data) {
if (!$this->handle) {
$this->handle = $this->open(TRUE);
}
@@ -287,7 +403,7 @@ class backup_file {
/**
* Read a line from the file.
*/
- function read($size = NULL) {
+ public function read($size = NULL) {
if (!$this->handle) {
$this->handle = $this->open();
}
@@ -300,14 +416,14 @@ class backup_file {
/**
* Write data to the file.
*/
- function put_contents($data) {
+ public function put_contents($data) {
file_put_contents($this->filepath(), $data);
}
/**
* Read data from the file.
*/
- function get_contents() {
+ public function get_contents() {
return file_get_contents($this->filepath());
}
@@ -315,11 +431,16 @@ class backup_file {
* Transfer file using http to client. Similar to the built in file_transfer,
* but it calls module_invoke_all('exit') so that temp files can be deleted.
*/
- function transfer() {
+ public function transfer() {
$headers = array(
array('key' => 'Content-Type', 'value' => $this->mimetype()),
- array('key' => 'Content-Disposition', 'value' => 'attachment; filename="'. $this->filename() .'"'),
+ array('key' => 'Content-Disposition', 'value' => 'attachment; filename="' . $this->filename() . '"'),
);
+ // In some circumstances, web-servers will double compress gzipped files.
+ // This may help aleviate that issue by disabling mod-deflate.
+ if ($this->mimetype() == 'application/x-gzip') {
+ $headers[] = array('key' => 'Content-Encoding', 'value' => 'gzip');
+ }
if ($size = $this->info('filesize')) {
$headers[] = array('key' => 'Content-Length', 'value' => $size);
}
@@ -358,7 +479,7 @@ class backup_file {
/**
* Push a file extension onto the file and return the previous file path.
*/
- function push_type($extension) {
+ public function push_type($extension) {
$types = _backup_migrate_filetypes();
if ($type = @$types[$extension]) {
$this->push_filetype($type);
@@ -372,7 +493,7 @@ class backup_file {
/**
* Push a file extension onto the file and return the previous file path.
*/
- function pop_type() {
+ public function pop_type() {
$out = new backup_file(array('filepath' => $this->filepath()));
$this->pop_filetype();
$this->temporary_file();
@@ -382,7 +503,7 @@ class backup_file {
/**
* Set the current file type.
*/
- function set_filetype($type) {
+ public function set_filetype($type) {
$this->type = $type;
$this->ext = array($type['extension']);
}
@@ -390,7 +511,7 @@ class backup_file {
/**
* Set the current file type.
*/
- function push_filetype($type) {
+ public function push_filetype($type) {
$this->ext[] = $type['extension'];
$this->type = $type;
}
@@ -398,7 +519,7 @@ class backup_file {
/**
* Pop the current file type.
*/
- function pop_filetype() {
+ public function pop_filetype() {
array_pop($this->ext);
$this->detect_filetype_from_extension();
}
@@ -406,7 +527,7 @@ class backup_file {
/**
* Set the file info.
*/
- function set_file_info($file_info) {
+ public function set_file_info($file_info) {
$this->file_info = $file_info;
$this->ext = explode('.', @$this->file_info['filename']);
@@ -421,7 +542,7 @@ class backup_file {
/**
* Get the filetype info of the given file, or false if the file is not a valid type.
*/
- function detect_filetype_from_extension() {
+ public function detect_filetype_from_extension() {
$ext = end($this->ext);
$this->type = array();
$types = _backup_migrate_filetypes();
@@ -436,17 +557,17 @@ class backup_file {
/**
* Get a temporary file name with path.
*/
- function temporary_file() {
+ public function temporary_file() {
$file = drupal_tempnam('temporary://', 'backup_migrate_');
// Add the version without the extension. The tempnam function creates this for us.
backup_migrate_temp_files_add($file);
if ($this->extension()) {
- $file .= '.'. $this->extension();
+ $file .= '.' . $this->extension();
// Add the version with the extension. This is the one we will actually use.
backup_migrate_temp_files_add($file);
}
$this->path = $file;
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.backup_restore.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.backup_restore.inc
index e9f2519..12578a5 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.backup_restore.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.backup_restore.inc
@@ -1,9 +1,10 @@
0, 'restore' => 0);
+ public $op_weights = array('backup' => 0, 'restore' => 0);
/**
* Get the default destinations for this filter.
*/
- function destinations() {
+ public function destinations() {
$out = array();
foreach ($this->_get_destination_types() as $destination) {
if (method_exists($destination, 'destinations')) {
@@ -27,15 +28,28 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
return $out;
}
+ /**
+ * Get the default sources for this filter.
+ */
+ public function sources() {
+ $out = array();
+ foreach ($this->_get_source_types() as $type) {
+ if (method_exists($type, 'sources')) {
+ $out += $type->sources();
+ }
+ }
+ return $out;
+ }
/**
* Get the default backup settings for this filter.
*/
- function backup_settings_default() {
- backup_migrate_include('destinations');
+ public function backup_settings_default() {
+ require_once dirname(__FILE__) . '/sources.inc';
+
$out = array();
- foreach (backup_migrate_get_destinations('source') as $destination) {
- $out['destinations'][$destination->get_id()] = $destination->backup_settings_default();
+ foreach (backup_migrate_get_sources() as $source) {
+ $out['sources'][$source->get_id()] = $source->backup_settings_default();
}
return $out;
}
@@ -43,7 +57,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form_validate($form, &$form_state) {
+ public function backup_settings_form_validate($form, &$form_state) {
foreach ($this->_get_destination_types() as $destination) {
$destination->backup_settings_form_validate($form, $form_state);
}
@@ -52,7 +66,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Submit the settings form. Any values returned will be saved.
*/
- function backup_settings_form_submit($form, &$form_state) {
+ public function backup_settings_form_submit($form, &$form_state) {
foreach ($this->_get_destination_types() as $destination) {
$destination->backup_settings_form_submit($form, $form_state);
}
@@ -61,7 +75,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the default restore settings for this filter.
*/
- function restore_settings_default() {
+ public function restore_settings_default() {
$out = array();
foreach ($this->_get_destination_types() as $destination) {
$out += $destination->restore_settings_default();
@@ -72,22 +86,24 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the form for the backup settings for this filter.
*/
- function backup_settings_form($settings) {
- backup_migrate_include('destinations');
- $out = array('destinations' => array(
- '#tree' => TRUE,
-
- ));
- foreach (backup_migrate_get_destinations('source') as $destination) {
- $destination_settings = (array)(@$settings['destinations'][$destination->get_id()]) + $settings;
- if ($form = $destination->backup_settings_form($destination_settings)) {
- $out['destinations'][$destination->get_id()] = array(
+ public function backup_settings_form($settings) {
+ require_once dirname(__FILE__) . '/sources.inc';
+
+ $out = array(
+ 'sources' => array(
+ '#tree' => TRUE,
+ ),
+ );
+ foreach (backup_migrate_get_sources() as $source) {
+ $source_settings = (array) (@$settings['sources'][$source->get_id()]) + $settings;
+ if ($form = $source->backup_settings_form($source_settings)) {
+ $out['sources'][$source->get_id()] = array(
'#type' => 'fieldset',
- '#title' => t('!name Backup Options', array('!name' => $destination->get('name'))),
+ '#title' => t('!name Backup Options', array('!name' => $source->get('name'))),
"#collapsible" => TRUE,
"#collapsed" => TRUE,
'#tree' => TRUE,
- '#parents' => array('filters', 'destinations', $destination->get_id()),
+ '#parents' => array('filters', 'sources', $source->get_id()),
) + $form;
}
}
@@ -97,7 +113,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Get the form for the restore settings for this filter.
*/
- function restore_settings_form($settings) {
+ public function restore_settings_form($settings) {
$form = array();
foreach ($this->_get_destination_types() as $destination) {
$destination->restore_settings_form($form, $settings);
@@ -105,25 +121,72 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
return $form;
}
+ /**
+ * Get the before-backup form for the active sources and destinations.
+ */
+ public function before_action_form($op, $settings) {
+ $form = array();
+ $method = 'before_' . $op . '_form';
+ if ($source = $settings->get_source()) {
+ if (method_exists($source, $method)) {
+ $form += $source->{$method}($settings);
+ }
+ }
+ foreach ($settings->get_destinations() as $destination) {
+ if (method_exists($destination, $method)) {
+ $form += $destination->{$method}($settings);
+ }
+ }
+ return $form;
+ }
+
+ /**
+ * Get the before-backup form for the active sources and destinations.
+ */
+ public function before_action_form_validate($op, $settings, $form, $form_state) {
+ $method = 'before_' . $op . '_form_validate';
+ foreach ($settings->get_all_locations() as $location) {
+ if (method_exists($location, $method)) {
+ $location->{$method}($settings, $form, $form_state);
+ }
+ }
+ }
+
+ /**
+ * Get the before-backup form for the active sources and destinations.
+ */
+ public function before_action_form_submit($op, $settings, $form, $form_state) {
+ $method = 'before_' . $op . '_form_submit';
+ foreach ($settings->get_all_locations() as $location) {
+ if (method_exists($location, $method)) {
+ $location->{$method}($settings, $form, $form_state);
+ }
+ }
+ }
+
/**
* Get the file types supported by this destination.
*/
- function file_types() {
+ public function file_types() {
$types = array();
foreach ($this->_get_destination_types() as $destination) {
$types += $destination->file_types();
}
+ foreach ($this->_get_source_types() as $source) {
+ $types += $source->file_types();
+ }
return $types;
}
/**
* Backup the data from the source specified in the settings.
*/
- function backup($file, &$settings) {
+ public function backup($file, $settings) {
if ($source = $settings->get_source()) {
- if (!empty($settings->filters['destinations'][$source->get_id()])) {
- $settings->filters = (array)($settings->filters['destinations'][$source->get_id()]) + $settings->filters;
+ if (!empty($settings->filters['sources'][$source->get_id()])) {
+ $settings->filters = (array) ($settings->filters['sources'][$source->get_id()]) + $settings->filters;
}
+
$file = $source->backup_to_file($file, $settings);
return $file;
}
@@ -134,10 +197,10 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
/**
* Restore the data from to source specified in the settings.
*/
- function restore($file, &$settings) {
+ public function restore($file, $settings) {
if ($source = $settings->get_source()) {
- if (!empty($settings->filters['destinations'][$source->get_id()])) {
- $settings->filters = (array)($settings->filters['destinations'][$source->get_id()]) + $settings->filters;
+ if (!empty($settings->filters['sources'][$source->get_id()])) {
+ $settings->filters = (array) ($settings->filters['sources'][$source->get_id()]) + $settings->filters;
}
$num = $source->restore_from_file($file, $settings);
return $num ? $file : FALSE;
@@ -147,23 +210,54 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter {
}
/**
- * Get a list of dummy destinations representing each of the available destination types.
+ * Dummy destinations representing each of the available destination types.
+ *
+ * @return array
+ * All of the available destination types.
*/
- function _get_destination_types() {
- backup_migrate_include('destinations');
- static $destinations = NULL;
+ public function _get_destination_types() {
+ require_once dirname(__FILE__) . '/destinations.inc';
+
+ $destinations = &drupal_static('backup_migrate_filter_backup_restore::_get_destination_types', NULL);
if (!is_array($destinations)) {
$destinations = array();
- $types = backup_migrate_get_destination_types();
+ $types = backup_migrate_get_destination_subtypes();
// If no (valid) node type has been provided, display a node type overview.
foreach ($types as $key => $type) {
// Include the necessary file if specified by the type.
if (!empty($type['file'])) {
- require_once './'. $type['file'];
+ require_once './' . $type['file'];
}
$destinations[] = new $type['class'](array());
}
}
return $destinations;
}
+
+ /**
+ * Dummy destinations representing each of the available source types.
+ *
+ * @return array
+ * All of the available source types.
+ */
+ public function _get_source_types() {
+ require_once dirname(__FILE__) . '/sources.inc';
+
+ $sources = &drupal_static('backup_migrate_filter_backup_restore::_get_source_types', NULL);
+ if (!is_array($sources)) {
+ $sources = array();
+ $types = backup_migrate_get_source_subtypes();
+ // If no (valid) node type has been provided, display a node type
+ // overview.
+ foreach ($types as $key => $type) {
+ // Include the necessary file if specified by the type.
+ if (!empty($type['file'])) {
+ require_once './' . $type['file'];
+ }
+ $sources[] = new $type['class'](array());
+ }
+ }
+ return $sources;
+ }
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.compression.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.compression.inc
index 6a0e111..e55ff92 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.compression.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.compression.inc
@@ -1,6 +1,5 @@
100, 'restore' => -100);
+ public $op_weights = array('backup' => 100, 'restore' => -100);
/**
* This function is called on a backup file after the backup has been completed.
*/
- function backup($file, &$settings) {
+ public function backup($file, $settings) {
return $this->_backup_migrate_file_compress($file, $settings);
}
/**
* This function is called on a backup file before importing it.
*/
- function restore($file, &$settings) {
- return $this->_backup_migrate_file_decompress($file);
+ public function restore($file, $settings) {
+ return $this->_backup_migrate_file_decompress($file, $settings);
}
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
$options = $this->_backup_migrate_get_compression_form_item_options();
return array('compression' => isset($options['gzip']) ? 'gzip' : 'none');
}
@@ -39,7 +38,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = array();
$compression_options = $this->_backup_migrate_get_compression_form_item_options();
$form['file']['compression'] = array(
@@ -54,7 +53,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Return a list of backup filetypes.
*/
- function file_types() {
+ public function file_types() {
return array(
"gzip" => array(
"extension" => "gz",
@@ -86,7 +85,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Get the compression options as an options array for a form item.
*/
- function _backup_migrate_get_compression_form_item_options() {
+ public function _backup_migrate_get_compression_form_item_options() {
$compression_options = array("none" => t("No Compression"));
if (@function_exists("gzencode")) {
$compression_options['gzip'] = t("GZip");
@@ -103,10 +102,14 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Gzip encode a file.
*/
- function _backup_migrate_gzip_encode($source, $dest, $level = 9) {
+ public function _backup_migrate_gzip_encode($source, $dest, $level = 9, $settings) {
$success = FALSE;
- if (@function_exists("gzopen")) {
- if (($fp_out = gzopen($dest, 'wb'. $level)) && ($fp_in = fopen($source, 'rb'))) {
+ // Try command line gzip first.
+ if (!empty($settings->filters['use_cli'])) {
+ $success = backup_migrate_exec("gzip -c -$level %input > %dest", array('%input' => $source, '%dest' => $dest, '%level' => $level));
+ }
+ if (!$success && @function_exists("gzopen")) {
+ if (($fp_out = gzopen($dest, 'wb' . $level)) && ($fp_in = fopen($source, 'rb'))) {
while (!feof($fp_in)) {
gzwrite($fp_out, fread($fp_in, 1024 * 512));
}
@@ -121,9 +124,14 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Gzip decode a file.
*/
- function _backup_migrate_gzip_decode($source, $dest) {
+ public function _backup_migrate_gzip_decode($source, $dest, $settings) {
$success = FALSE;
- if (@function_exists("gzopen")) {
+
+ if (!empty($settings->filters['use_cli'])) {
+ $success = backup_migrate_exec("gzip -d -c %input > %dest", array('%input' => $source, '%dest' => $dest));
+ }
+
+ if (!$success && @function_exists("gzopen")) {
if (($fp_out = fopen($dest, 'wb')) && ($fp_in = gzopen($source, 'rb'))) {
while (!feof($fp_in)) {
fwrite($fp_out, gzread($fp_in, 1024 * 512));
@@ -139,7 +147,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Bzip encode a file.
*/
- function _backup_migrate_bzip_encode($source, $dest) {
+ public function _backup_migrate_bzip_encode($source, $dest) {
$success = FALSE;
if (@function_exists("bzopen")) {
if (($fp_out = bzopen($dest, 'w')) && ($fp_in = fopen($source, 'rb'))) {
@@ -160,7 +168,7 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Bzip decode a file.
*/
- function _backup_migrate_bzip_decode($source, $dest) {
+ public function _backup_migrate_bzip_decode($source, $dest) {
$success = FALSE;
if (@function_exists("bzopen")) {
if (($fp_out = fopen($dest, 'w')) && ($fp_in = bzopen($source, 'r'))) {
@@ -181,10 +189,10 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Zip encode a file.
*/
- function _backup_migrate_zip_encode($source, $dest, $filename) {
+ public function _backup_migrate_zip_encode($source, $dest, $filename) {
$success = FALSE;
if (class_exists('ZipArchive')) {
- $zip = new ZipArchive;
+ $zip = new ZipArchive();
$res = $zip->open($dest, constant("ZipArchive::CREATE"));
if ($res === TRUE) {
$zip->addFile($source, $filename);
@@ -197,10 +205,10 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
/**
* Zip decode a file.
*/
- function _backup_migrate_zip_decode($source, $dest) {
+ public function _backup_migrate_zip_decode($source, $dest) {
$success = FALSE;
if (class_exists('ZipArchive')) {
- $zip = new ZipArchive;
+ $zip = new ZipArchive();
if (($fp_out = fopen($dest, "w")) && ($zip->open($source))) {
$filename = ($zip->getNameIndex(0));
if ($fp_in = $zip->getStream($filename)) {
@@ -220,11 +228,11 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
* Compress a file with the given settings.
* Also updates settings to reflect new file mime and file extension.
*/
- function _backup_migrate_file_compress($file, $settings) {
+ public function _backup_migrate_file_compress($file, $settings) {
switch ($settings->filters['compression']) {
case "gzip":
$from = $file->push_type('gzip');
- if (!$success = $this->_backup_migrate_gzip_encode($from, $file->filepath(), 9)) {
+ if (!$success = $this->_backup_migrate_gzip_encode($from, $file->filepath(), 9, $settings)) {
$file = NULL;
}
break;
@@ -247,7 +255,6 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
if (!$file) {
_backup_migrate_message("Could not compress backup file. Try backing up without compression.", array(), 'error');
}
-
return $file;
}
@@ -255,13 +262,13 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
* Decompress a file with the given settings.
* Also updates settings to reflect new file mime and file extension.
*/
- function _backup_migrate_file_decompress($file) {
+ public function _backup_migrate_file_decompress($file, $settings) {
$success = FALSE;
switch ($file->type_id()) {
case "gzip":
$from = $file->pop_type();
- $success = $this->_backup_migrate_gzip_decode($from->filepath(), $file->filepath());
+ $success = $this->_backup_migrate_gzip_decode($from->filepath(), $file->filepath(), $settings);
break;
case "bzip":
@@ -285,5 +292,5 @@ class backup_migrate_filter_compression extends backup_migrate_filter {
}
return $success ? $file : NULL;
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.encryption.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.encryption.inc
index 46f01c2..61b0dec 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.encryption.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.encryption.inc
@@ -1,6 +1,5 @@
170, 'restore' => -170);
+ public $op_weights = array('backup' => 170, 'restore' => -170);
/**
- * This function is called on a backup file after the backup has been completed.
+ * Called on a backup file after the backup has been completed.
*/
- function backup($file, &$settings) {
+ public function backup($file, $settings) {
return $this->file_encrypt($file, $settings);
}
/**
- * This function is called on a backup file before importing it.
+ * Called on a backup file before importing it.
*/
- function restore($file, &$settings) {
+ public function restore($file, $settings) {
return $this->file_decrypt($file);
}
/**
- * Get the form for the settings for this filter.
+ * Gets the form for the settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
return array('encryption' => 'none');
}
/**
- * Get the form for the settings for this filter.
+ * Gets the form for the settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = array();
$options = $this->_backup_migrate_get_encryption_form_item_options();
- if (count($options) > 1) {
+
+ if (array_intersect_key($options, array_flip(array('aes', 'encrypt')))) {
$form['file']['encryption'] = array(
"#type" => "select",
- "#title" => t("File Encryption (EXPERIMENTAL)"),
+ "#title" => t("File Encryption"),
"#options" => $options,
"#default_value" => @$settings['encryption'],
- '#description' => t('Encrypted files can only be restored by Backup and Migrate and only on sites with the same encryption key. This functionality is experimental, and should only be used for testing.'),
+ '#description' => t('Encrypted files can only be restored by Backup and Migrate and only on sites with the same encryption key.'),
);
}
else {
$form['file']['encryption'] = array(
"#type" => 'item',
"#title" => t("File Encryption"),
- "#markup" => t('Install the !link to enable backup file encryption.', array('!link' => l(t('AES Encryption Module'), 'http://drupal.org/project/aes'))),
+ "#markup" => t('Install the !link to enable backup file encryption.', array('!link' => l(t('Encrypt module'), 'http://drupal.org/project/encrypt'))),
);
}
+ // If the Encrypt method is available add a configuration field.
+ if (array_key_exists('encrypt', $options)) {
+ $form['file']['encrypt_config'] = array(
+ '#type' => 'select',
+ '#title' => t('Encryption Configuration'),
+ '#options' => encrypt_get_configs_as_options(),
+ '#default_value' => @$settings['encrypt_config'],
+ '#description' => t('Select a configuration to use for encryption.'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="filters[encryption]"]' => array('value' => 'encrypt'),
+ ),
+ ),
+ );
+
+ }
+
return $form;
}
/**
- * Return a list of backup filetypes.
+ * Returns a list of backup filetypes.
*/
- function file_types() {
+ public function file_types() {
return array(
"aes" => array(
"extension" => "aes",
@@ -72,29 +89,39 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
"backup" => TRUE,
"restore" => TRUE,
),
+ "encrypt" => array(
+ "extension" => "encrypt",
+ "filemime" => "application/octet-stream",
+ "backup" => TRUE,
+ "restore" => TRUE,
+ ),
);
}
/**
- * Get the compression options as an options array for a form item.
+ * Gets the compression options as an options array for a form item.
*/
- function _backup_migrate_get_encryption_form_item_options() {
+ public function _backup_migrate_get_encryption_form_item_options() {
$options = array();
$options = array('' => t('No Encryption'));
if (@function_exists("aes_encrypt")) {
$options['aes'] = t("AES Encryption");
}
+ if (@function_exists("encrypt")) {
+ $options['encrypt'] = t("Encryption With Encrypt Module");
+ }
return $options;
}
/**
- * AES encrypt a file.
+ * AES encrypts a file.
*/
- function aes_encrypt($source, $dest) {
+ public function aes_encrypt($source, $dest) {
$success = FALSE;
if (function_exists('aes_encrypt')) {
if ($data = $source->get_contents()) {
- // Add a marker to the end of the data so we can trim the padding on decrpypt.
+ // Add a marker to the end of the data so we can trim the padding on
+ // decrpypt.
$data = pack("a*H2", $data, "80");
if ($data = aes_encrypt($data, FALSE)) {
$dest->put_contents($data);
@@ -106,9 +133,9 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
/**
- * Gzip decode a file.
+ * AES decodes a file.
*/
- function aes_decrypt($source, $dest) {
+ public function aes_decrypt($source, $dest) {
$success = FALSE;
if (function_exists('aes_decrypt')) {
if ($data = $source->get_contents()) {
@@ -124,10 +151,54 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
/**
- * Compress a file with the given settings.
- * Also updates settings to reflect new file mime and file extension.
+ * Encrypts a file with the Encrypt module.
*/
- function file_encrypt($file, $settings) {
+ public function encrypt($source, $dest, $settings) {
+ $success = FALSE;
+ if (function_exists('encrypt')) {
+ if (!empty($settings->filters['encrypt_config'])) {
+ $config_name = $settings->filters['encrypt_config'];
+ }
+ else {
+ $config = encrypt_get_default_config();
+ $config_name = $config['name'];
+ }
+ if ($data = $source->get_contents()) {
+ // Add a marker to the end of the data so we can trim the padding on decrypt.
+ $data = pack("a*H2", $data, "80");
+ if ($data = encrypt($data, array('base64' => FALSE), NULL, NULL, $config_name)) {
+ $dest->put_contents($data);
+ $success = TRUE;
+ }
+ }
+ }
+ return $success;
+ }
+
+ /**
+ * Decrypts a file with the Encrypt module.
+ */
+ public function decrypt($source, $dest) {
+ $success = FALSE;
+ if (function_exists('decrypt')) {
+ if ($data = $source->get_contents()) {
+ if ($data = decrypt($data)) {
+ // Trim all the padding zeros plus our non-zero marker.
+ $data = substr(rtrim($data, "\0"), 0, -1);
+ $dest->put_contents($data);
+ $success = TRUE;
+ }
+ }
+ }
+ return $success;
+ }
+
+ /**
+ * Encrypts a file with the given settings.
+ *
+ * Also updates settings to reflect new file mime and file extension.
+ */
+ public function file_encrypt($file, $settings) {
if (!empty($settings->filters['encryption'])) {
switch ($settings->filters['encryption']) {
case "aes":
@@ -137,6 +208,14 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
$file = NULL;
}
break;
+
+ case "encrypt":
+ $from = $file->push_type('encrypt');
+ $from = new backup_file(array('filepath' => $from));
+ if (!$success = $this->encrypt($from, $file, $settings)) {
+ $file = NULL;
+ }
+ break;
}
if (!$file) {
_backup_migrate_message("Could not encrypt backup file. Try backing up without encryption.", array(), 'error');
@@ -146,10 +225,11 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
}
/**
- * Decompress a file with the given settings.
- * Also updates settings to reflect new file mime and file extension.
+ * Decrypts a file with the given settings.
+ *
+ * Also updates settings to reflect new file mime and file extension.
*/
- function file_decrypt($file) {
+ public function file_decrypt($file) {
$success = FALSE;
if ($file) {
switch ($file->type_id()) {
@@ -157,21 +237,39 @@ class backup_migrate_filter_encryption extends backup_migrate_filter {
$from = $file->pop_type();
$success = $this->aes_decrypt($from, $file);
break;
+
+ case "encrypt":
+ $from = $file->pop_type();
+ $success = $this->decrypt($from, $file);
+ break;
+
default:
return $file;
- break;
- }
-
+ }
+
if (!$success) {
- if (function_exists('aes_decrypt')) {
- _backup_migrate_message("Could not decrpyt backup file. Please check that the file is valid and that the encryption key of the server matches the server that created the backup.", array(), 'error');
- }
- else {
- _backup_migrate_message('You must install the !link to restore encrypted backkups.', array('!link' => l(t('AES Encryption Module'), 'http://drupal.org/project/aes')), 'error');
+ switch ($file->type_id()) {
+ case 'aes':
+ if (function_exists('aes_decrypt')) {
+ _backup_migrate_message("Could not decrpyt backup file. Please check that the file is valid and that the encryption key of the server matches the server that created the backup.", array(), 'error');
+ }
+ else {
+ _backup_migrate_message('You must install the !link to restore encrypted backkups.', array('!link' => l(t('AES Encryption Module'), 'http://drupal.org/project/aes')), 'error');
+ }
+ break;
+
+ case 'encrypt':
+ if (function_exists('decrypt')) {
+ _backup_migrate_message("Could not decrypt backup file. Please check that the file is valid and that the encryption key of the server matches the server that created the backup.", array(), 'error');
+ }
+ else {
+ _backup_migrate_message('You must install the !link to restore encrypted backups.', array('!link' => l(t('Encrypt module'), 'http://drupal.org/project/encrypt')), 'error');
+ }
+ break;
}
}
}
return $success ? $file : NULL;
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.inc
index 679a25c..4b55f5d 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.inc
@@ -1,25 +1,24 @@
array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.backup_restore.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.backup_restore.inc',
'class' => 'backup_migrate_filter_backup_restore',
),
'compression' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.compression.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.compression.inc',
'class' => 'backup_migrate_filter_compression',
),
'encryption' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.encryption.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.encryption.inc',
'class' => 'backup_migrate_filter_encryption',
),
'statusnotify' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.statusnotify.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.statusnotify.inc',
'class' => 'backup_migrate_filter_statusnotify',
),
'utils' => array(
- 'file' => drupal_get_path('module', 'backup_migrate') .'/includes/filters.utils.inc',
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/filters.utils.inc',
'class' => 'backup_migrate_filter_utils',
),
);
}
/**
- * Invoke the given method on all of the available filters.
+ * Invokes the given method on all of the available filters.
*/
function backup_migrate_filters_invoke_all() {
$args = func_get_args();
@@ -96,42 +95,47 @@ function backup_migrate_filters_invoke_all() {
}
/**
- * Filter a backup file before sending it to the destination.
+ * Filters a backup file before sending it to the destination.
*/
function backup_migrate_filters_backup($file, &$settings) {
+ backup_migrate_filters_invoke_all('pre_backup', $file, $settings);
$filters = backup_migrate_get_filters('backup');
foreach ($filters as $filter) {
if ($file) {
$file = $filter->backup($file, $settings);
}
}
+ backup_migrate_filters_invoke_all('post_backup', $file, $settings);
+
return $file;
}
/**
- * Filter a backup file before sending it to the destination.
+ * Filters a backup file before sending it to the destination.
*/
function backup_migrate_filters_restore($file, &$settings) {
+ backup_migrate_filters_invoke_all('pre_restore', $file, $settings);
$filters = backup_migrate_get_filters('restore');
foreach ($filters as $filter) {
if ($file) {
$file = $filter->restore($file, $settings);
}
}
+ backup_migrate_filters_invoke_all('post_restore', $file, $settings);
return $file;
}
/**
- * Get the backup settings for all of the filters.
+ * Gets the backup settings for all of the filters.
*/
function backup_migrate_filters_settings_form($settings, $op) {
- $out = backup_migrate_filters_invoke_all($op .'_settings_form', $settings);
+ $out = backup_migrate_filters_invoke_all($op . '_settings_form', $settings);
$out = backup_migrate_filters_settings_form_set_parents($out);
return $out;
}
/**
- * Add a form parent to the filter settings so that the filter values are saved in the right table.
+ * Adds form parent to filter settings so the values are saved in correct table.
*/
function backup_migrate_filters_settings_form_set_parents($form) {
foreach (element_children($form) as $key) {
@@ -143,27 +147,51 @@ function backup_migrate_filters_settings_form_set_parents($form) {
return $form;
}
-
/**
- * Validate all the filters.
+ * Validates all the filters.
*/
function backup_migrate_filters_settings_form_validate($op, $form, &$form_state) {
- //backup_migrate_filters_invoke_all($op .'_settings_form_validate', $form, $form_state);
+ backup_migrate_filters_invoke_all($op . '_settings_form_validate', $form, $form_state);
}
/**
- * Submit all of the filters.
+ * Submits all of the filters.
*/
function backup_migrate_filters_settings_form_submit($op, $form, &$form_state) {
- //backup_migrate_filters_invoke_all($op .'_settings_form_submit', $form, $form_state);
+ backup_migrate_filters_invoke_all($op . '_settings_form_submit', $form, $form_state);
}
-
/**
- * Get the default settings for the filters.
+ * Gets the default settings for the filters.
*/
function backup_migrate_filters_settings_default($op) {
- return backup_migrate_filters_invoke_all($op .'_settings_default');
+ return backup_migrate_filters_invoke_all($op . '_settings_default');
+}
+
+/**
+ * Get the backup settings for all of the filters.
+ */
+function backup_migrate_filters_before_action_form($settings, $op) {
+ $out = array();
+ $out += backup_migrate_filters_invoke_all('before_action_form', $op, $settings);
+ $out += backup_migrate_filters_invoke_all('before_' . $op . '_form', $settings);
+ return $out;
+}
+
+/**
+ * Get the backup settings for all of the filters.
+ */
+function backup_migrate_filters_before_action_form_validate($settings, $op, $form, &$form_state) {
+ backup_migrate_filters_invoke_all('before_action_form_validate', $op, $settings, $form, $form_state);
+ backup_migrate_filters_invoke_all('before_' . $op . '_form_validate', $settings, $form, $form_state);
+}
+
+/**
+ * Get the backup settings for all of the filters.
+ */
+function backup_migrate_filters_before_action_form_submit($settings, $op, $form, &$form_state) {
+ backup_migrate_filters_invoke_all('before_action_form_submit', $op, $settings, $form, $form_state);
+ backup_migrate_filters_invoke_all('before_' . $op . '_form_submit', $settings, $form, $form_state);
}
/**
@@ -177,13 +205,13 @@ function backup_migrate_filters_file_types() {
* A base class for basing filters on.
*/
class backup_migrate_filter {
- var $weight = 0;
- var $op_weights = array();
+ public $weight = 0;
+ public $op_weights = array();
/**
* Get the weight of the filter for the given op.
*/
- function weight($op = NULL) {
+ public function weight($op = NULL) {
if ($op && isset($this->op_weights[$op])) {
return $this->op_weights[$op];
}
@@ -193,98 +221,110 @@ class backup_migrate_filter {
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form_validate($form, &$form_state) {
+ public function backup_settings_form_validate($form, &$form_state) {
}
/**
* Submit the settings form. Any values returned will be saved.
*/
- function backup_settings_form_submit($form, &$form_state) {
- return $form_state['values'];
+ public function backup_settings_form_submit($form, &$form_state) {
}
/**
* Get the form for the settings for this filter.
*/
- function restore_settings_default() {
+ public function restore_settings_default() {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function restore_settings_form($settings) {
+ public function restore_settings_form($settings) {
return array();
}
/**
* Get the form for the settings for this filter.
*/
- function restore_settings_form_validate($form, &$form_state) {
+ public function restore_settings_form_validate($form, &$form_state) {
}
/**
* Submit the settings form. Any values returned will be saved.
*/
- function restore_settings_form_submit($form, &$form_state) {
+ public function restore_settings_form_submit($form, &$form_state) {
return $form_state['values'];
}
/**
* Get a list of file types handled by this filter.
*/
- function file_types() {
+ public function file_types() {
return array();
}
/**
* Declare any default destinations for this filter.
*/
- function destinations() {
+ public function destinations() {
return array();
}
-
/**
- * This function is called on a backup file after the backup has been completed.
+ * Called on a backup file after the backup has been completed.
*/
- function backup($file, &$settings) {
- return $file;
- }
-
- /**
- * This function is called on a backup file before importing it.
- */
- function restore($file, &$settings) {
+ public function backup($file, $settings) {
return $file;
}
/**
* This function is called immediately prior to backup.
*/
- function pre_backup($source, $file, $settings) {
+ public function pre_backup($file, $settings) {
}
/**
* This function is called immediately post backup.
*/
- function post_backup($source, $file, $settings) {
+ public function post_backup($file, $settings) {
}
-}
+ /**
+ * This function is called on a backup file before importing it.
+ */
+ public function restore($file, $settings) {
+ return $file;
+ }
+
+ /**
+ * This function is called immediately prior to restore.
+ */
+ public function pre_restore($file, $settings) {
+
+ }
+
+ /**
+ * This function is called immediately post restore.
+ */
+ public function post_restore($file, $settings) {
+
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.statusnotify.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.statusnotify.inc
index 3371d6c..6101349 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.statusnotify.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.statusnotify.inc
@@ -1,6 +1,5 @@
FALSE,
'notify_failure_enable' => FALSE,
@@ -28,14 +27,20 @@ class backup_migrate_filter_statusnotify extends backup_migrate_filter {
/**
* Get the form for the settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = array();
$form['advanced']['notify_success_enable'] = array(
"#type" => 'checkbox',
"#title" => t("Send an email if backup succeeds"),
"#default_value" => @$settings['notify_success_enable'],
);
- $form['advanced']['notify_success_email'] = array(
+ $form['advanced']['notify_success_email_wrapper'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'filters[notify_success_enable]' => TRUE,
+ ),
+ );
+ $form['advanced']['notify_success_email_wrapper']['notify_success_email'] = array(
"#type" => "textfield",
"#title" => t("Email Address for Success Notices"),
"#default_value" => @$settings['notify_success_email'],
@@ -45,7 +50,13 @@ class backup_migrate_filter_statusnotify extends backup_migrate_filter {
"#title" => t("Send an email if backup fails"),
"#default_value" => @$settings['notify_failure_enable'],
);
- $form['advanced']['notify_failure_email'] = array(
+ $form['advanced']['notify_failure_email_wrapper'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'filters[notify_failure_enable]' => TRUE,
+ ),
+ );
+ $form['advanced']['notify_failure_email_wrapper']['notify_failure_email'] = array(
"#type" => "textfield",
"#title" => t("Email Address for Failure Notices"),
"#default_value" => @$settings['notify_failure_email'],
@@ -56,41 +67,39 @@ class backup_migrate_filter_statusnotify extends backup_migrate_filter {
/**
* Send the success email.
*/
- function backup_succeed($settings) {
+ public function backup_succeed($settings) {
if (@$settings->filters['notify_success_enable'] && $to = @$settings->filters['notify_success_email']) {
$messages = $this->get_messages();
- $subject = t('!site backup succeeded', array('!site' => variable_get('site_name', 'Drupal site')));
if ($messages = $this->get_messages()) {
$body = t("The site backup has completed successfully with the following messages:\n!messages", array('!messages' => $messages));
}
else {
$body = t("The site backup has completed successfully.\n");
}
- mail($settings->filters['notify_success_email'], $subject, $body);
+ drupal_mail('backup_migrate', 'backup_succeed', $settings->filters['notify_success_email'], language_default(), array('body' => $body));
}
}
/**
* Send the failure email.
*/
- function backup_fail($settings) {
+ public function backup_fail($settings) {
if (@$settings->filters['notify_failure_enable'] && $to = @$settings->filters['notify_failure_email']) {
$messages = $this->get_messages();
- $subject = t('!site backup failed', array('!site' => variable_get('site_name', 'Drupal site')));
if ($messages = $this->get_messages()) {
$body = t("The site backup has failed with the following messages:\n!messages", array('!messages' => $messages));
}
else {
$body = t("The site backup has failed for an unknown reason.");
}
- mail($settings->filters['notify_failure_email'], $subject, $body);
+ drupal_mail('backup_migrate', 'backup_fail', $settings->filters['notify_failure_email'], language_default(), array('body' => $body));
}
}
/**
* Render the messages and errors for the email.
*/
- function get_messages() {
+ public function get_messages() {
$out = "";
$messages = _backup_migrate_messages();
foreach ($messages as $message) {
@@ -98,5 +107,5 @@ class backup_migrate_filter_statusnotify extends backup_migrate_filter {
}
return $out;
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.utils.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.utils.inc
index c4dce95..34b47d5 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/filters.utils.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/filters.utils.inc
@@ -1,23 +1,23 @@
-1000, 'post_backup' => 1000);
+ public $saved_devel_query = NULL;
/**
* Get the default backup settings for this filter.
*/
- function backup_settings_default() {
+ public function backup_settings_default() {
return array(
'utils_disable_query_log' => TRUE,
'utils_site_offline' => FALSE,
@@ -28,7 +28,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Get the default restore settings for this filter.
*/
- function restore_settings_default() {
+ public function restore_settings_default() {
return array(
'utils_disable_query_log' => TRUE,
'utils_site_offline' => FALSE,
@@ -38,7 +38,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Get the form for the backup settings for this filter.
*/
- function backup_settings_form($settings) {
+ public function backup_settings_form($settings) {
$form = array();
if (module_exists('devel') && variable_get('dev_query', 0)) {
$form['database']['utils_disable_query_log'] = array(
@@ -54,17 +54,35 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
'#default_value' => !empty($settings['utils_site_offline']) ? $settings['utils_site_offline'] : NULL,
'#description' => t('Take the site offline during backup and show a maintenance message. Site will be taken back online once the backup is complete.'),
);
- $form['advanced']['utils_site_offline_message'] = array(
+ $form['advanced']['utils_site_offline_message_wrapper'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'filters[utils_site_offline]' => TRUE,
+ ),
+ );
+ $form['advanced']['utils_site_offline_message_wrapper']['utils_site_offline_message'] = array(
'#type' => 'textarea',
'#title' => t('Site off-line message'),
- '#default_value' => !empty($settings['utils_site_offline_message']) ? $settings['utils_site_offline_message'] : variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
- '#description' => t('Message to show visitors when the site is in off-line mode.')
+ '#default_value' => !empty($settings['utils_site_offline_message']) ? $settings['utils_site_offline_message'] : variable_get('site_offline_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
+ '#description' => t('Message to show visitors when the site is in off-line mode.'),
);
$form['advanced']['utils_description'] = array(
'#type' => 'textarea',
- '#title' => t('Description'),
+ '#title' => t('Add a note'),
'#default_value' => !empty($settings['utils_description']) ? $settings['utils_description'] : NULL,
- '#description' => t('Add a short description to the backup file.'),
+ '#description' => t('Add a short note to the backup file.'),
+ );
+ $form['advanced']['use_cli'] = array(
+ "#type" => "checkbox",
+ "#title" => t("Use cli commands"),
+ "#default_value" => !empty($settings['use_cli']),
+ "#description" => t("Use the command line tools (mysqldump, tar, gzip etc.) if available. This can be faster for large sites but will not work on all servers. EXPERIMENTAL"),
+ );
+ $form['advanced']['ignore_errors'] = array(
+ "#type" => "checkbox",
+ "#title" => t("Ignore errors"),
+ "#default_value" => !empty($settings['ignore_errors']),
+ "#description" => t("Will attempt to complete backup even if certain recoverable errors occur. This may make the backup files invalid. Enable this if you have unreadable files that you want to ignore during backup."),
);
return $form;
@@ -73,7 +91,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Get the form for the restore settings for this filter.
*/
- function restore_settings_form($settings) {
+ public function restore_settings_form($settings) {
$form = array();
if (module_exists('devel') && variable_get('dev_query', 0)) {
$form['advanced']['utils_disable_query_log'] = array(
@@ -89,32 +107,70 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
'#default_value' => !empty($settings['utils_site_offline']) ? $settings['utils_site_offline'] : NULL,
'#description' => t('Take the site offline during restore and show a maintenance message. Site will be taken back online once the restore is complete.'),
);
- $form['advanced']['utils_site_offline_message'] = array(
+ $form['advanced']['utils_site_offline_message_wrapper'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'filters[utils_site_offline]' => TRUE,
+ ),
+ );
+ $form['advanced']['utils_site_offline_message_wrapper']['utils_site_offline_message'] = array(
'#type' => 'textarea',
'#title' => t('Site off-line message'),
- '#default_value' => !empty($settings['utils_site_offline_message']) ? $settings['utils_site_offline_message'] : variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
- '#description' => t('Message to show visitors when the site is in off-line mode.')
+ '#default_value' => !empty($settings['utils_site_offline_message']) ? $settings['utils_site_offline_message'] : variable_get('site_offline_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
+ '#description' => t('Message to show visitors when the site is in off-line mode.'),
);
+ $form['advanced']['utils_drop_all_tables'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Drop all tables before import (MySQL only)'),
+ '#default_value' => !empty($settings['utils_drop_all_tables']) ? $settings['utils_drop_all_tables'] : NULL,
+ '#description' => t('Drop all existing database tables before restoring the backup. This option is currently available on MySQL servers only.'),
+ );
+ $form['advanced']['use_cli'] = array(
+ "#type" => "checkbox",
+ "#title" => t("Use cli commands"),
+ "#default_value" => !empty($settings['use_cli']),
+ "#description" => t("Use the command line tools (mysqldump, tar, gzip etc.) if available. This can be faster for large sites but will not work on all servers. EXPERIMENTAL"),
+ );
+ // $form['advanced']['ignore_errors'] = array(
+ // "#type" => "checkbox",
+ // "#title" => t("Ignore errors"),
+ // "#default_value" => !empty($settings['ignore_errors']),
+ // "#description" => t("Will attempt to complete restore even if certain recoverable errors occur. This may could corrupt your site."),
+ // );
return $form;
}
- function pre_backup($source, $file, $settings) {
+ /**
+ *
+ */
+ public function pre_backup($file, $settings) {
$this->take_site_offline($settings);
$this->disable_devel_query($settings);
}
- function post_backup($source, $file, $settings) {
+ /**
+ *
+ */
+ public function post_backup($file, $settings) {
$this->enable_devel_query($settings);
$this->take_site_online($settings);
- $this->add_file_info($file, $settings);
+ if ($file) {
+ $this->add_file_info($file, $settings);
+ }
}
- function pre_restore($file, $settings) {
+ /**
+ *
+ */
+ public function pre_restore($file, $settings) {
$this->disable_devel_query($settings);
$this->take_site_offline($settings);
}
- function post_restore($file, $settings) {
+ /**
+ *
+ */
+ public function post_restore($file, $settings) {
$this->enable_devel_query($settings);
$this->take_site_online($settings);
}
@@ -122,7 +178,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Disable devel query logging if it's active and the user has chosen to do so.
*/
- function disable_devel_query($settings) {
+ public function disable_devel_query($settings) {
$this->saved_devel_query = variable_get('dev_query', 0);
if (module_exists('devel') && variable_get('dev_query', 0) && !empty($settings->filters['utils_disable_query_log'])) {
variable_set('dev_query', 0);
@@ -132,7 +188,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Restore devel query to previous state.
*/
- function enable_devel_query($settings) {
+ public function enable_devel_query($settings) {
if (module_exists('devel')) {
variable_set('dev_query', $this->saved_devel_query);
}
@@ -141,49 +197,61 @@ class backup_migrate_filter_utils extends backup_migrate_filter {
/**
* Add the backup metadata to the file.
*/
- function add_file_info($file, $settings) {
- $file->file_info['description'] = $settings->filters['utils_description'];
- $file->file_info['datestamp'] = time();
- $file->file_info['generator'] = 'Backup and Migrate (http://drupal.org/project/backup_migrate)';
- $file->file_info['generatorversion'] = BACKUP_MIGRATE_VERSION;
- $file->file_info['sites'] = array(
- '0' => array(
- 'version' => VERSION,
- 'name' => variable_get('site_name', ''),
- 'url' => url('', array('absolute' => TRUE)),
- ),
- );
-
+ public function add_file_info($file, $settings) {
+ $file->file_info['description'] = $settings->filters['utils_description'];
+ $file->file_info['datestamp'] = time();
+ $file->file_info['generator'] = 'Backup and Migrate (http://drupal.org/project/backup_migrate)';
+ $file->file_info['generatorversion'] = BACKUP_MIGRATE_VERSION;
+ $file->file_info['siteurl'] = url('', array('absolute' => TRUE));
+ $file->file_info['sitename'] = variable_get('site_name', '');
+ $file->file_info['drupalversion'] = VERSION;
+ $file->calculate_filesize();
+
+ $source = $settings->get('source');
+ $file->file_info['bam_sourceid'] = $source->get('id');
+ $file->file_info['bam_sourcetype'] = $source->get('subtype');
+ $file->file_info['bam_sourcename'] = $source->get('name');
+
+ // Add any additional info that has been added to the settings by other plugins.
+ if (!empty($settings->file_info)) {
+ $file->file_info += $settings->file_info;
+ }
}
/**
* Take the site offline if configured to do so.
*/
- function take_site_offline($settings) {
- // Save the current state of the site in case a restore overwrites it.
- $this->saved_site_offline = variable_get('maintenance_mode', 0);
- if (@$settings->filters['utils_site_offline']) {
- $this->saved_site_offline_message = variable_get('maintenance_mode_message', NULL);
- if (!empty($settings->filters['utils_site_offline_message'])) {
+ public function take_site_offline($settings) {
+ // If the site is already offline then don't do anything.
+ if (!variable_get('maintenance_mode', 0)) {
+ // Save the current state of the site in case a restore overwrites it.
+ if (!empty($settings->filters['utils_site_offline'])) {
+ $this->saved_site_offline = TRUE;
$this->saved_site_offline_message = variable_get('maintenance_mode_message', NULL);
- variable_set('maintenance_mode_message', $settings->filters['utils_site_offline_message']);
+ if (!empty($settings->filters['utils_site_offline_message'])) {
+ $this->saved_site_offline_message = variable_get('maintenance_mode_message', NULL);
+ variable_set('maintenance_mode_message', $settings->filters['utils_site_offline_message']);
+ }
+ variable_set('maintenance_mode', 1);
+ _backup_migrate_message('Site was taken offline.');
}
- variable_set('maintenance_mode', 1);
- _backup_migrate_message('Site was taken offline.');
}
}
/**
* Take the site online again after backup or restore.
*/
- function take_site_online($settings) {
+ public function take_site_online($settings) {
// Take the site back off/online because the restored db may have changed that setting.
- variable_set('maintenance_mode', $this->saved_site_offline);
- if ($settings->filters['utils_site_offline']) {
- if (!empty($this->saved_site_offline_message)) {
- variable_set('maintenance_mode_message', $this->saved_site_offline_message);
+ if (variable_get('maintenance_mode', 0) && !empty($this->saved_site_offline)) {
+ variable_set('maintenance_mode', 0);
+ if ($settings->filters['utils_site_offline']) {
+ if (!empty($this->saved_site_offline_message)) {
+ variable_set('maintenance_mode_message', $this->saved_site_offline_message);
+ }
+ _backup_migrate_message('Site was taken online.');
}
- _backup_migrate_message('Site was taken online.');
}
}
-}
\ No newline at end of file
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/locations.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/locations.inc
new file mode 100644
index 0000000..2072e32
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/locations.inc
@@ -0,0 +1,529 @@
+ $location) {
+ if ($location->op($op)) {
+ $out[$key] = $location;
+ }
+ }
+ }
+ return $out;
+}
+
+/**
+ * Get the location of the given id.
+ */
+function backup_migrate_get_location($id) {
+ $locations = backup_migrate_get_locations('all');
+ return empty($locations[$id]) ? NULL : $locations[$id];
+}
+
+/**
+ * A base class for creating locations.
+ */
+class backup_migrate_location extends backup_migrate_item {
+ public $db_table = "backup_migrate_destinations";
+ public $type_name = "location";
+ public $default_values = array('settings' => array());
+ public $singular = 'location';
+ public $plural = 'locations';
+ public $title_plural = 'Locations';
+ public $title_singular = 'Location';
+
+ public $subtype = "";
+ public $supported_ops = array();
+
+ /**
+ * This function is not supposed to be called. It is just here to help the po extractor out.
+ */
+ public function strings() {
+ // Help the pot extractor find these strings.
+ t('location');
+ t('locations');
+ t('Location');
+ t('Locations');
+ }
+
+ /**
+ *
+ */
+ public function ops() {
+ return $this->supported_ops;
+ }
+
+ /**
+ * Does this location support the given operation.
+ */
+ public function op($op) {
+ $ops = (array) $this->ops();
+ return in_array($op, $ops);
+ }
+
+ /**
+ * Remove the given op from the support list.
+ */
+ public function remove_op($op) {
+ $key = array_search($op, $this->supported_ops);
+ if ($key !== FALSE) {
+ unset($this->supported_ops[$key]);
+ }
+ }
+
+ /**
+ *
+ */
+ public function get_name() {
+ return @$this->name;
+ }
+
+ /**
+ *
+ */
+ public function set_name($name) {
+ return $this->name = $name;
+ }
+
+ /**
+ *
+ */
+ public function set_location($location) {
+ $this->location = $location;
+ }
+
+ /**
+ *
+ */
+ public function get_location() {
+ return @$this->location;
+ }
+
+ /**
+ *
+ */
+ public function get_display_location() {
+ return $this->get_location();
+ }
+
+ /**
+ *
+ */
+ public function settings($key = NULL) {
+ $out = $this->settings;
+ if ($key) {
+ $out = isset($out[$key]) ? $out[$key] : NULL;
+ }
+ return $out;
+ }
+
+ /**
+ * Get the type name of this location for display to the user.
+ */
+ public function get_subtype_name() {
+ if ($type = $this->get('subtype')) {
+ $types = $this->location_types();
+ return isset($types[$type]['type_name']) ? $types[$type]['type_name'] : $type;
+ }
+ }
+
+ /**
+ * Get the edit form for the item.
+ */
+ public function edit_form() {
+ if (!empty($this->supported_ops)) {
+ $form = parent::edit_form();
+ $form['subtype'] = array(
+ "#type" => "value",
+ "#default_value" => $this->get('subtype'),
+ );
+ }
+ else {
+ $types = $this->location_types();
+ $items = array();
+ // If no (valid) node type has been provided, display a node type overview.
+ foreach ($types as $key => $type) {
+ if (@$type['can_create']) {
+ $type_url_str = str_replace('_', '-', $key);
+ $out = '
' . l($type['type_name'], BACKUP_MIGRATE_MENU_PATH . "/settings/$this->type_name/add/$type_url_str", array('attributes' => array('title' => t('Add a new @s location.', array('@s' => $type['type_name']))))) . '
';
+ $out .= '
' . filter_xss_admin($type['description']) . '
';
+ $items[] = $out;
+ }
+ }
+ if (count($items)) {
+ $output = t('Choose the type of location you would like to create:') . '
' . implode('', $items) . '
';
+ }
+ else {
+ $output = t('No types available.');
+ }
+ $form['select_type'] = array(
+ '#type' => 'markup',
+ '#markup' => $output,
+ );
+ }
+ return $form;
+ }
+
+ /**
+ * Get the available location types.
+ */
+ public function location_types() {
+ return backup_migrate_get_location_subtypes();
+ }
+
+ /**
+ * Get the message to send to the user when confirming the deletion of the item.
+ */
+ public function delete_confirm_message() {
+ return t('Are you sure you want to delete the %name?', array('%name' => $this->get_name()));
+ }
+
+ /**
+ * Get the columns needed to list the type.
+ */
+ public function get_list_column_info() {
+ $out = parent::get_list_column_info();
+ $out = array(
+ 'name' => array('title' => t('Name')),
+ 'subtype_name' => array('title' => t('Type')),
+ 'display_location' => array('title' => t('Location')),
+ ) + $out;
+ return $out;
+ }
+
+ /**
+ * Get a row of data to be used in a list of items of this type.
+ */
+ public function get_list_row() {
+ $out = parent::get_list_row();
+
+ // Suppress locations with no actions as there's no value in showing them (and they may confuse new users).
+ if (empty($out['actions'])) {
+ return NULL;
+ }
+ return $out;
+ }
+
+ /**
+ * Get the action links for a location.
+ */
+ public function get_action_links() {
+ $out = parent::get_action_links();
+ $item_id = $this->get_id();
+
+ // Don't display the download/delete/restore ops if they are not available for this location.
+ if ($this->op('list files') && user_access("access backup files")) {
+ $out = array('list files' => l(t("list files"), BACKUP_MIGRATE_MENU_PATH . "/$this->type_name/list/files/" . $item_id)) + $out;
+ }
+ if (!$this->op('configure') || !user_access('administer backup and migrate')) {
+ unset($out['edit']);
+ }
+ return $out;
+ }
+
+ /**
+ * Determine if we can read the given file.
+ */
+ public function can_read_file($file_id) {
+ return $this->op('restore');
+ }
+
+ /**
+ * Get the form for the settings for this location type.
+ */
+ public function settings_default() {
+ return array();
+ }
+
+ /**
+ * Get the form for the settings for this location.
+ */
+ public function settings_form($form) {
+ return $form;
+ }
+
+ /**
+ * Validate the form for the settings for this location.
+ */
+ public function settings_form_validate($form_values) {
+ }
+
+ /**
+ * Submit the settings form. Any values returned will be saved.
+ */
+ public function settings_form_submit($form_values) {
+ return $form_values;
+ }
+
+ /**
+ * Get the form for the settings for this filter.
+ */
+ public function backup_settings_default() {
+ return array();
+ }
+
+ /**
+ * Get the form for the settings for this filter.
+ */
+ public function backup_settings_form($settings) {
+ return array();
+ }
+
+ /**
+ * Get the form for the settings for this filter.
+ */
+ public function backup_settings_form_validate($form, &$form_state) {
+ }
+
+ /**
+ * Submit the settings form. Any values returned will be saved.
+ */
+ public function backup_settings_form_submit($form, &$form_state) {
+ }
+
+ /**
+ * Get the form for the settings for this filter.
+ */
+ public function restore_settings_default() {
+ return array();
+ }
+
+ /**
+ * Get the form for the settings for this filter.
+ */
+ public function restore_settings_form($settings) {
+ return array();
+ }
+
+ /**
+ * Get the form for the settings for this filter.
+ */
+ public function restore_settings_form_validate($form_values) {
+ }
+
+ /**
+ * Submit the settings form. Any values returned will be saved.
+ */
+ public function restore_settings_form_submit($form_values) {
+ return $form_values;
+ }
+
+ /**
+ * Create a new location of the correct type.
+ */
+ public function create($params = array()) {
+ $out = NULL;
+ $types = backup_migrate_get_location_subtypes();
+ // Get the type passed in in the params, or if none, check the url for a valid type name.
+ // This is to allow new location type to be specified in the path.
+ $location_type = !empty($params['subtype']) ? $params['subtype'] : NULL;
+
+ if ($location_type && ($type = @$types[$location_type])) {
+ // Include the necessary file if specified by the type.
+ if (!empty($type['file'])) {
+ require_once './' . $type['file'];
+ }
+ $out = new $type['class']($params + array('subtype' => $location_type));
+ }
+
+ if (empty($out)) {
+ $out = parent::create($params);
+ }
+ return $out;
+ }
+
+ /**
+ * Get a url from the parts.
+ */
+ public function url($hide_password = TRUE) {
+ return $this->glue_url($this->dest_url, $hide_password);
+ }
+
+ /**
+ * Glue a URLs component parts back into a URL.
+ */
+ public function glue_url($parts, $hide_password = TRUE) {
+ // Obscure the password if we need to.
+ $parts['pass'] = $hide_password ? "" : $parts['pass'];
+
+ // Assemble the URL.
+ $out = "";
+ $out .= $parts['scheme'] . '://';
+ $out .= $parts['user'] ? urlencode($parts['user']) : '';
+ $out .= ($parts['user'] && $parts['pass']) ? ":" . urlencode($parts['pass']) : '';
+ $out .= ($parts['user'] || $parts['pass']) ? "@" : "";
+ $out .= $parts['host'];
+ $out .= !empty($parts['port']) ? ':' . $parts['port'] : '';
+ $out .= "/" . $parts['path'];
+ return $out;
+ }
+
+ /**
+ * Break a URL into it's component parts.
+ */
+ public function set_url($url) {
+ $parts = (array) parse_url($url);
+ $parts['user'] = urldecode(@$parts['user']);
+ $parts['pass'] = urldecode(@$parts['pass']);
+ $parts['path'] = urldecode(@$parts['path']);
+ $parts['path'] = ltrim(@$parts['path'], "/");
+ $this->dest_url = $parts;
+ }
+
+ /**
+ * Retrieve a list of filetypes supported by this source/destination.
+ */
+ public function file_types() {
+ return array();
+ }
+
+}
+
+/**
+ * A base class for creating locations.
+ */
+class backup_migrate_location_remote extends backup_migrate_location {
+
+ /**
+ * The location is a URI so parse it and store the parts.
+ */
+ public function get_location() {
+ return $this->url(FALSE);
+ }
+
+ /**
+ * The location to display is the url without the password.
+ */
+ public function get_display_location() {
+ return $this->url(TRUE);
+ }
+
+ /**
+ * Return the location with the password.
+ */
+ public function set_location($location) {
+ $this->location = $location;
+ $this->set_url($location);
+ }
+
+ /**
+ * Location configuration callback.
+ */
+ public function edit_form() {
+ $form = parent::edit_form();
+ $form['scheme'] = array(
+ "#type" => "select",
+ "#title" => t("Scheme"),
+ "#default_value" => @$this->dest_url['scheme'] ? $this->dest_url['scheme'] : 'mysql',
+ "#required" => TRUE,
+ "#options" => array($GLOBALS['db_type'] => $GLOBALS['db_type']),
+ "#weight" => 0,
+ );
+ $form['host'] = array(
+ "#type" => "textfield",
+ "#title" => t("Host"),
+ "#default_value" => @$this->dest_url['host'] ? $this->dest_url['host'] : 'localhost',
+ "#required" => TRUE,
+ "#weight" => 10,
+ );
+ $form['path'] = array(
+ "#type" => "textfield",
+ "#title" => t("Path"),
+ "#default_value" => @$this->dest_url['path'],
+ "#required" => TRUE,
+ "#weight" => 20,
+ );
+ $form['user'] = array(
+ "#type" => "textfield",
+ "#title" => t("Username"),
+ "#default_value" => @$this->dest_url['user'],
+ "#required" => TRUE,
+ "#weight" => 30,
+ );
+ $form['pass'] = array(
+ "#type" => "password",
+ "#title" => t("Password"),
+ "#default_value" => @$this->dest_url['pass'],
+ '#description' => '',
+ "#weight" => 40,
+ );
+ if (@$this->dest_url['pass']) {
+ $form['old_password'] = array(
+ "#type" => "value",
+ "#value" => @$this->dest_url['pass'],
+ );
+ $form['pass']["#description"] .= t(' You do not need to enter a password unless you wish to change the currently saved password.');
+ }
+ return $form;
+ }
+
+ /**
+ * Submit the configuration form. Glue the url together and add the old password back if a new one was not specified.
+ */
+ public function edit_form_submit($form, &$form_state) {
+ $form_state['values']['pass'] = $form_state['values']['pass'] ? $form_state['values']['pass'] : $form_state['values']['old_password'];
+ $form_state['values']['location'] = $this->glue_url($form_state['values'], FALSE);
+ parent::edit_form_submit($form, $form_state);
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/profiles.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/profiles.inc
index da49b21..ba37321 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/profiles.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/profiles.inc
@@ -1,19 +1,35 @@
array(
+ 'include' => 'profiles',
+ 'type_name' => t('Backup Settings Profile'),
+ 'class' => 'backup_migrate_profile',
+ ),
+ );
+ return $out;
+}
/**
* Get all the available backup profiles.
*/
function backup_migrate_get_profiles() {
- backup_migrate_include('filters');
- static $profiles = NULL;
+ require_once dirname(__FILE__) . '/filters.inc';
+
+ $profiles = &drupal_static('backup_migrate_get_profiles', NULL);
// Get the list of profiles and cache them locally.
if ($profiles === NULL) {
@@ -23,14 +39,14 @@ function backup_migrate_get_profiles() {
}
/**
- * Implementation of hook_backup_migrate_profiles_alter().
+ * Implements hook_backup_migrate_profiles_alter().
*
* Add default settings for any plugins which didn't exist when the profile was saved.
*/
function backup_migrate_backup_migrate_profiles_alter(&$profiles) {
foreach ($profiles as $id => $profile) {
// Set the default values for filter setting which don't exist in the profile.
- $profiles[$id]->filters = (array)@$profile->filters + (array)backup_migrate_filters_settings_default('backup');
+ $profiles[$id]->filters = (array) @$profile->filters + (array) backup_migrate_filters_settings_default('backup');
}
}
@@ -43,13 +59,13 @@ function backup_migrate_get_profile($profile_id) {
}
/**
- * Implementation of hook_backup_migrate_profiles().
+ * Implements hook_backup_migrate_profiles().
*/
function backup_migrate_backup_migrate_profiles() {
$out = array();
// Get the module default profile.
- $out['default'] = backup_migrate_crud_create_item('profile', array('name' => t("Default Settings"), 'profile_id' => 'default'));
+ $out['default'] = backup_migrate_crud_create_item('profile', array('name' => t("Default Settings"), 'machine_name' => 'default'));
return $out;
}
@@ -61,7 +77,7 @@ function backup_migrate_backup_migrate_profiles() {
*/
function _backup_migrate_get_profile_form_item_options() {
$out = array();
- foreach ((array)backup_migrate_get_profiles() as $key => $profile) {
+ foreach ((array) backup_migrate_get_profiles() as $key => $profile) {
$out[$key] = $profile->get('name');
}
return $out;
@@ -71,13 +87,15 @@ function _backup_migrate_get_profile_form_item_options() {
* Get a form to configure the profile.
*/
function _backup_migrate_ui_backup_settings_form($profile) {
+ require_once dirname(__FILE__) . '/destinations.inc';
+ require_once dirname(__FILE__) . '/files.inc';
+ require_once dirname(__FILE__) . '/filters.inc';
+
drupal_add_js(array('backup_migrate' => array('checkboxLinkText' => t('View as checkboxes'))), array('type' => 'setting'));
- drupal_add_js(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.js', array('type' => 'file', 'scope' => 'footer'));
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ drupal_add_js(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.js', array('type' => 'file', 'scope' => 'footer'));
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
- backup_migrate_include('files', 'destinations', 'filters');
-
- $form = array();
+ $form = array();
$form['file'] = array(
"#type" => "fieldset",
@@ -92,8 +110,6 @@ function _backup_migrate_ui_backup_settings_form($profile) {
"#default_value" => $profile->filename,
);
if (module_exists('token')) {
- $form['file']['filename']['#description'] = t('You can use tokens in the file name.');
-
$form['file']['token_help'] = array(
'#title' => t('Replacement patterns'),
'#type' => 'fieldset',
@@ -105,14 +121,26 @@ function _backup_migrate_ui_backup_settings_form($profile) {
'#token_types' => array('current-date', 'site'),
'#global_types' => FALSE,
);
+ $form['file']['filename']['#description'] = t('You can use tokens in the file name.');
}
$form['file']['append_timestamp'] = array(
- "#type" => "checkbox",
- "#title" => t("Append a timestamp."),
+ "#type" => "radios",
+ '#options' => array(
+ 0 => t('Create separate backups if `Backup file name` already exists'),
+ 2 => t('Overwrite the existing backup file'),
+ 1 => t('Append the timestamp'),
+ ),
+ "#title" => t("Save mode"),
"#default_value" => $profile->append_timestamp,
);
- $form['file']['timestamp_format'] = array(
+ $form['file']['timestamp_format_wrapper'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'append_timestamp' => 1,
+ ),
+ );
+ $form['file']['timestamp_format_wrapper']['timestamp_format'] = array(
"#type" => "textfield",
"#title" => t("Timestamp format"),
"#default_value" => $profile->timestamp_format,
@@ -126,12 +154,12 @@ function _backup_migrate_ui_backup_settings_form($profile) {
if ($form['advanced']) {
$form['advanced']['#type'] = 'fieldset';
$form['advanced']['#title'] = t('Advanced Options');
- $form['advanced']['#collapsed'] = true;
- $form['advanced']['#collapsible'] = true;
+ $form['advanced']['#collapsed'] = TRUE;
+ $form['advanced']['#collapsible'] = TRUE;
}
- $form['#validate'][] = '_backup_migrate_ui_backup_settings_form_validate';
- $form['#submit'][] = '_backup_migrate_ui_backup_settings_form_submit';
+ $form['#validate'][] = '_backup_migrate_ui_backup_settings_form_validate';
+ $form['#submit'][] = '_backup_migrate_ui_backup_settings_form_submit';
return $form;
}
@@ -149,12 +177,14 @@ function _backup_migrate_ui_backup_settings_form_validate($form, &$form_state) {
function _backup_migrate_ui_backup_settings_form_submit($form, &$form_state) {
backup_migrate_filters_settings_form_submit('backup', $form, $form_state);
}
-
+
/**
* Get the default profile.
*/
function _backup_migrate_profile_default_profile() {
- backup_migrate_include('files', 'filters');
+ require_once dirname(__FILE__) . '/files.inc';
+ require_once dirname(__FILE__) . '/filters.inc';
+
return array(
'source_id' => 'db',
'filename' => _backup_migrate_default_filename(),
@@ -183,41 +213,62 @@ function _backup_migrate_profile_saved_default_profile($profile_id = NULL) {
* A profile class for crud operations.
*/
class backup_migrate_profile extends backup_migrate_item {
- var $db_table = "backup_migrate_profiles";
- var $type_name = "profile";
- var $singular = 'profile';
- var $plural = 'profiles';
+ public $db_table = "backup_migrate_profiles";
+ public $type_name = "profile";
+ public $singular = 'settings profile';
+ public $plural = 'settings profiles';
+ public $title_plural = 'Settings Profiles';
+ public $title_singular = 'Settings Profile';
+
+ /**
+ * Perform a shallow merge of the defaults and the parameters.
+ *
+ * This is needed because otherwise it will *combine* the nested arrays and
+ * make it impossible to deselect database tables from the 'nodata' setting.
+ *
+ * @param array $params
+ */
+ public function __construct(array $params = array()) {
+ $params = (array) $params;
+ $defaults = (array) $this->get_default_values();
+ foreach ($defaults as $key => $val) {
+ if (!isset($params[$key])) {
+ $params[$key] = $val;
+ }
+ }
+ $this->from_array($params);
+ }
/**
* This function is not supposed to be called. It is just here to help the po extractor out.
*/
- function strings() {
+ public function strings() {
// Help the pot extractor find these strings.
- t('Profile');
- t('Profiles');
- t('profile');
- t('profiles');
+ t('Settings Profile');
+ t('Settings Profiles');
+ t('settings profile');
+ t('settings profiles');
}
/**
* Get the default values for standard parameters.
*/
- function get_default_values() {
+ public function get_default_values() {
return _backup_migrate_profile_default_profile() + array('name' => t("Untitled Profile"));
}
/**
* Get a table of all items of this type.
- */
- function get_list() {
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ */
+ public function get_list() {
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
return parent::get_list();
}
/**
* Get the columns needed to list the type.
- */
- function get_list_column_info() {
+ */
+ public function get_list_column_info() {
$out = parent::get_list_column_info();
$out = array(
'name' => array('title' => t('Name')),
@@ -227,23 +278,10 @@ class backup_migrate_profile extends backup_migrate_item {
return $out;
}
- /**
- * Get a row of data to be used in a list of items of this type.
- */
- function get_list_row() {
- $row = parent::get_list_row();
- if (empty($this->enabled)) {
- foreach ($row as $key => $field) {
- $row[$key] = array('data' => $field, 'class' => 'profile-list-disabled');
- }
- }
- return $row;
- }
-
/**
* Set the source of this setings profile. Takes either a source object or source id.
*/
- function set_source($source) {
+ public function set_source($source) {
if (is_object($source)) {
$this->source = $source;
$this->source_id = $source->get_id();
@@ -257,10 +295,11 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the source of the profile.
*/
- function get_source() {
- backup_migrate_include('destinations');
- if (!empty($this->source_id) && (empty($this->source) || $this->source->destination_id !== $this->source_id)) {
- $this->source = backup_migrate_get_destination($this->source_id);
+ public function get_source() {
+ require_once dirname(__FILE__) . '/locations.inc';
+
+ if (!empty($this->source_id) && (empty($this->source) || $this->source->get_id() !== $this->source_id)) {
+ $this->source = backup_migrate_get_source($this->source_id);
}
return empty($this->source) ? NULL : $this->source;
}
@@ -268,7 +307,7 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the name of the source.
*/
- function get_source_name() {
+ public function get_source_name() {
if ($source = $this->get_source()) {
return $source->get_name();
}
@@ -278,28 +317,64 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the destination of the profile.
*/
- function get_destination() {
- backup_migrate_include('destinations');
- if (!empty($this->destination_id) && (empty($this->destination) || $this->destination->destination_id !== $this->destination_id)) {
- $this->destination = backup_migrate_get_destination($this->destination_id);
+ public function get_destination() {
+ $destinations = (array) $this->get_destinations();
+ return reset($destinations);
+ }
+
+ /**
+ * Get the destination of the profile.
+ */
+ public function get_destinations() {
+ require_once dirname(__FILE__) . '/destinations.inc';
+
+ if (empty($this->destinations)) {
+ $this->destinations = array();
+ $ids = $weights = array();
+ if (!empty($this->destination_id)) {
+ foreach ((array) $this->destination_id as $destination_id) {
+ if (!in_array($destination_id, $ids) && $destination = backup_migrate_get_destination($destination_id)) {
+ $this->destinations[] = $destination;
+ $weights[] = $destination->get('weight');
+ $ids[] = $destination_id;
+ }
+ }
+ }
+ // Sort the destinations by weight.
+ array_multisort($weights, SORT_NUMERIC, $this->destinations);
}
- return empty($this->destination) ? NULL : $this->destination;
+
+ return $this->destinations;
}
/**
* Get the name of the destination.
*/
- function get_destination_name() {
- if ($destination = $this->get_destination()) {
- return $destination->get_name();
+ public function get_destination_name() {
+ $out = array();
+ foreach ($this->get_destinations() as $destination) {
+ $out[] = $destination->get_name();
+ }
+ if ($out) {
+ return implode(', ', $out);
}
return t("Missing");
}
+ /**
+ * Get the source and destinations specified in the given settings profile.
+ */
+ public function get_all_locations() {
+ $out = array();
+ $out += $this->get('destinations');
+ $out[] = $this->get('source');
+ return $out;
+ }
+
/**
* Get the edit form.
*/
- function edit_form() {
+ public function edit_form() {
$form = parent::edit_form();
$form['name'] = array(
"#type" => "textfield",
@@ -314,8 +389,8 @@ class backup_migrate_profile extends backup_migrate_item {
/**
* Get the message to send to the user when confirming the deletion of the item.
*/
- function delete_confirm_message() {
+ public function delete_confirm_message() {
return t('Are you sure you want to delete the profile %name? Any schedules using this profile will be disabled.', array('%name' => $this->get('name')));
}
-}
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/schedules.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/schedules.inc
index 456a149..0415894 100644
--- a/sites/all/modules/contrib/admin/backup_migrate/includes/schedules.inc
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/schedules.inc
@@ -5,24 +5,82 @@
* All of the schedule handling code needed for Backup and Migrate.
*/
-backup_migrate_include('crud');
+define('BACKUP_MIGRATE_KEEP_ALL', 0);
+define('BACKUP_MIGRATE_STANDARD_DELETE', -1);
+define('BACKUP_MIGRATE_SMART_DELETE', -2);
+
+define('BACKUP_MIGRATE_CRON_BUILTIN', 'builtin');
+define('BACKUP_MIGRATE_CRON_ELYSIA', 'elysia');
+define('BACKUP_MIGRATE_CRON_NONE', 'none');
+
+
+define('BACKUP_MIGRATE_SMART_KEEP_SUBHOURLY', 3600);
+define('BACKUP_MIGRATE_SMART_KEEP_HOURLY', 24);
+define('BACKUP_MIGRATE_SMART_KEEP_DAILY', 30);
+define('BACKUP_MIGRATE_SMART_KEEP_WEEKLY', PHP_INT_MAX);
+
+define('BACKUP_MIGRATE_KEEP_DEFAULT', 100);
+
+require_once dirname(__FILE__) . '/crud.inc';
+
+/**
+ * Implements hook_backup_migrate_destination_types().
+ *
+ * Get the built in Backup and Migrate destination types.
+ */
+function backup_migrate_backup_migrate_schedule_types() {
+ $out = array();
+ $out += array(
+ 'backup' => array(
+ 'include' => 'schedule',
+ 'type_name' => t('Backup Schedule'),
+ 'class' => 'backup_migrate_schedule',
+ ),
+ );
+ return $out;
+}
/**
* Run the preconfigured schedules. Called on cron.
*/
-function backup_migrate_schedules_run() {
- backup_migrate_include('profiles');
+function backup_migrate_schedules_cron() {
+ require_once dirname(__FILE__) . '/profiles.inc';
+
foreach (backup_migrate_get_schedules() as $schedule) {
$schedule->cron();
}
backup_migrate_cleanup();
}
+/**
+ * Run the preconfigured schedules regardless of scheduled time settings.
+ */
+function backup_migrate_schedules_run() {
+ require_once dirname(__FILE__) . '/profiles.inc';
+
+ foreach (backup_migrate_get_schedules() as $schedule) {
+ $schedule->run();
+ }
+ backup_migrate_cleanup();
+}
+
+/**
+ * Run the preconfigured schedules. Called on cron.
+ */
+function backup_migrate_schedule_run($schedule_id) {
+ require_once dirname(__FILE__) . '/profiles.inc';
+
+ if (($schedule = backup_migrate_get_schedule($schedule_id)) && $schedule->is_enabled()) {
+ $schedule->run();
+ }
+ backup_migrate_cleanup();
+}
+
/**
* Get all the available backup schedules.
*/
function backup_migrate_get_schedules() {
- static $schedules = NULL;
+ $schedules = &drupal_static('backup_migrate_get_schedules');
// Get the list of schedules and cache them locally.
if ($schedules === NULL) {
$schedules = backup_migrate_crud_get_items('schedule');
@@ -42,16 +100,18 @@ function backup_migrate_get_schedule($schedule_id) {
* A schedule class for crud operations.
*/
class backup_migrate_schedule extends backup_migrate_item {
- var $db_table = "backup_migrate_schedules";
- var $type_name = 'schedule';
- var $singular = 'schedule';
- var $plural = 'schedules';
- var $default_values = array();
+ public $db_table = "backup_migrate_schedules";
+ public $type_name = 'schedule';
+ public $singular = 'schedule';
+ public $plural = 'schedules';
+ public $title_plural = 'Schedules';
+ public $title_singular = 'Schedule';
+ public $default_values = array();
/**
* This function is not supposed to be called. It is just here to help the po extractor out.
*/
- function strings() {
+ public function strings() {
// Help the pot extractor find these strings.
t('Schedule');
t('Schedules');
@@ -62,25 +122,36 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the default values for this item.
*/
- function get_default_values() {
+ public function get_default_values() {
return array(
- 'name' => t("Untitled Schedule"),
- 'source_id' => 'db',
- 'enabled' => 1,
- 'keep' => 0,
- 'period' => 60 * 60 * 24,
- 'storage' => BACKUP_MIGRATE_STORAGE_NONE
- );
+ 'name' => t("Untitled Schedule"),
+ 'source_id' => 'db',
+ 'enabled' => 1,
+ 'keep' => BACKUP_MIGRATE_KEEP_ALL,
+ 'period' => 60 * 60 * 24,
+ 'storage' => BACKUP_MIGRATE_STORAGE_NONE,
+ 'cron' => BACKUP_MIGRATE_CRON_BUILTIN,
+ 'cron_schedule' => '0 4 * * *',
+ );
+ }
+
+ /**
+ * Return as an array of values.
+ */
+ public function to_array() {
+ $out = parent::to_array();
+ unset($out['last_run']);
+ return $out;
}
/**
* Get the columns needed to list the type.
- */
- function get_list_column_info() {
+ */
+ public function get_list_column_info() {
$out = parent::get_list_column_info();
$out = array(
'name' => array('title' => t('Name')),
- 'destination_name' => array('title' => t('Destination'), 'html' => TRUE),
+ 'destination_name' => array('title' => t('Destinations'), 'html' => TRUE),
'profile_name' => array('title' => t('Profile'), 'html' => TRUE),
'frequency_description' => array('title' => t('Frequency')),
'keep_description' => array('title' => t('Keep')),
@@ -90,15 +161,40 @@ class backup_migrate_schedule extends backup_migrate_item {
return $out;
}
+ /**
+ * Get the columns needed to list the type.
+ */
+ public function get_settings_path() {
+ // Pull the schedules tab up a level to the top.
+ return BACKUP_MIGRATE_MENU_PATH . '/' . $this->type_name;
+ }
+
+ /**
+ * Get the menu items for manipulating this type.
+ */
+ public function get_menu_items() {
+ $items = parent::get_menu_items();
+ $path = $this->get_settings_path();
+ return $items;
+ }
+
/**
* Get a row of data to be used in a list of items of this type.
*/
- function get_list_row() {
- drupal_add_css(drupal_get_path('module', 'backup_migrate') .'/backup_migrate.css');
+ public function get_list_row() {
+ drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
$row = parent::get_list_row();
if (!$this->is_enabled()) {
foreach ($row as $key => $field) {
- $row[$key] = array('data' => $field, 'class' => 'schedule-list-disabled');
+ if (!is_array($field)) {
+ $row[$key] = array('data' => $field, 'class' => 'schedule-list-disabled');
+ }
+ elseif (isset($row[$key]['class'])) {
+ $row[$key]['class'] .= ' schedule-list-disabled';
+ }
+ else {
+ $row[$key]['class'] = 'schedule-list-disabled';
+ }
}
}
return $row;
@@ -107,7 +203,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Is the schedule enabled and valid.
*/
- function is_enabled() {
+ public function is_enabled() {
$destination = $this->get_destination();
$profile = $this->get_profile();
return (!empty($this->enabled) && !empty($destination) && !empty($profile));
@@ -116,66 +212,167 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the destination object of the schedule.
*/
- function get_destination() {
- backup_migrate_include('destinations');
- return backup_migrate_get_destination($this->get('destination_id'));
+ public function get_destination() {
+ $destinations = (array) $this->get_destinations();
+ return reset($destinations);
+ }
+
+ /**
+ * Get the destination object of the schedule.
+ */
+ public function get_destination_ids() {
+ $out = array();
+ foreach (array('destination_id', 'copy_destination_id') as $key) {
+ if ($id = $this->get($key)) {
+ $out[$key] = $id;
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Get the destination object of the schedule.
+ */
+ public function get_destinations() {
+ require_once dirname(__FILE__) . '/destinations.inc';
+
+ $out = array();
+ foreach ($this->get_destination_ids() as $id) {
+ if ($dest = backup_migrate_get_destination($id)) {
+ $out[$id] = $dest;
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Get the destination object of the schedule.
+ */
+ public function get_destination_remote() {
+ require_once dirname(__FILE__) . '/destinations.inc';
+
+ return backup_migrate_get_destination($this->get('destination_remote_id'));
+ }
+
+ /**
+ * Get the destination object of the schedule.
+ */
+ public function get_destination_local() {
+ require_once dirname(__FILE__) . '/destinations.inc';
+
+ return backup_migrate_get_destination($this->get('destination_local_id'));
}
/**
* Get the name of the destination.
*/
- function get_destination_name() {
- if ($destination = $this->get_destination()) {
- return check_plain($destination->get_name());
+ public function get_destination_name() {
+ if ($destinations = $this->get_destinations()) {
+ $out = array();
+ foreach ((array) $destinations as $destination) {
+ $out[] = check_plain($destination->get_name());
+ }
+ return implode(', ', $out);
}
- return '
'. t("Missing") .'
';
+ return '
' . t("Missing") . '
';
}
/**
* Get the destination of the schedule.
*/
- function get_profile() {
- backup_migrate_include('profiles');
- return backup_migrate_get_profile($this->get('profile_id'));
+ public function get_profile() {
+ require_once dirname(__FILE__) . '/profiles.inc';
+
+ if ($settings = backup_migrate_get_profile($this->get('profile_id'))) {
+ $settings->file_info = empty($settings->file_info) ? array() : $settings->file_info;
+ $settings->file_info += array(
+ 'schedule_id' => $this->get_id(),
+ 'schedule_name' => $this->get('name'),
+ );
+ }
+ return $settings;
+
}
/**
* Get the name of the source.
*/
- function get_profile_name() {
+ public function get_profile_name() {
if ($profile = $this->get_profile()) {
return check_plain($profile->get_name());
}
- return '
'. t("Missing") .'
';
+ return '
' . t("Missing") . '
';
}
/**
* Format a frequency in human-readable form.
*/
- function get_frequency_description() {
+ public function get_frequency_description() {
$period = $this->get_frequency_period();
- $out = format_plural(($this->period / $period['seconds']), $period['singular'], $period['plural']);
+ $cron = $this->get('cron');
+ if ($cron == BACKUP_MIGRATE_CRON_BUILTIN) {
+ $out = format_plural(($this->period / $period['seconds']), $period['singular'], $period['plural']);
+ }
+ elseif ($cron == BACKUP_MIGRATE_CRON_ELYSIA) {
+ $out = $this->get('cron_schedule');
+ }
+ else {
+ $out = t('None');
+ }
return $out;
}
/**
* Format the number to keep in human-readable form.
*/
- function get_keep_description() {
- return !empty($this->keep) ? $this->keep : t('All');
+ public function get_keep_description() {
+ return $this->generate_keep_description($this->keep);
+ }
+
+ /**
+ * Format a number to keep in human readable from.
+ */
+ public function generate_keep_description($keep, $terse = TRUE) {
+ if ($keep == BACKUP_MIGRATE_KEEP_ALL) {
+ return t('all backups');
+ }
+ elseif ($keep == BACKUP_MIGRATE_SMART_DELETE) {
+ $keep_hourly = variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY);
+ $keep_daily = variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY);
+ $keep_weekly = variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY);
+ if ($terse) {
+ return t('!hours hourly, !days daily, !weeks weekly backups',
+ array(
+ '!hours' => $keep_hourly == PHP_INT_MAX ? t('all') : $keep_hourly,
+ '!days' => $keep_daily == PHP_INT_MAX ? t('all') : $keep_daily,
+ '!weeks' => $keep_weekly == PHP_INT_MAX ? t('all') : $keep_weekly,
+ ));
+ }
+ else {
+ return t('hourly backups !hours, daily backups !days and weekly backups !weeks',
+ array(
+ '!hours' => $keep_hourly == PHP_INT_MAX ? t('forever') : format_plural($keep_hourly, 'for 1 hour', 'for the past @count hours'),
+ '!days' => $keep_daily == PHP_INT_MAX ? t('forever') : format_plural($keep_daily, 'for 1 day', 'for the past @count days'),
+ '!weeks' => $keep_weekly == PHP_INT_MAX ? t('forever') : format_plural($keep_weekly, 'for 1 week', 'for the past @count weeks'),
+ )
+ );
+ }
+ }
+
+ return format_plural($keep, 'last 1 backup', 'last @count backups');
}
/**
* Format the enabled status in human-readable form.
*/
- function get_enabled_description() {
+ public function get_enabled_description() {
return !empty($this->enabled) ? t('Enabled') : t('Disabled');
}
/**
* Format the enabled status in human-readable form.
*/
- function get_last_run_description() {
+ public function get_last_run_description() {
$last_run = $this->get('last_run');
return !empty($last_run) ? format_date($last_run, 'small') : t('Never');
}
@@ -183,29 +380,27 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the number of excluded tables.
*/
- function get_exclude_tables_count() {
+ public function get_exclude_tables_count() {
return count($this->exclude_tables) ? count($this->exclude_tables) : t("No tables excluded");
}
/**
* Get the number of excluded tables.
*/
- function get_nodata_tables_count() {
+ public function get_nodata_tables_count() {
return count($this->nodata_tables) ? count($this->nodata_tables) : t("No data omitted");
}
/**
* Get the edit form.
*/
- function edit_form() {
- $form = parent::edit_form();
- backup_migrate_include('destinations', 'profiles');
+ public function edit_form() {
+ require_once dirname(__FILE__) . '/destinations.inc';
+ require_once dirname(__FILE__) . '/sources.inc';
+ require_once dirname(__FILE__) . '/profiles.inc';
+
+ $form = parent::edit_form();
- $form['enabled'] = array(
- "#type" => "checkbox",
- "#title" => t("Enabled"),
- "#default_value" => $this->get('enabled'),
- );
$form['name'] = array(
"#type" => "textfield",
"#title" => t("Schedule Name"),
@@ -220,7 +415,7 @@ class backup_migrate_schedule extends backup_migrate_item {
"#options" => _backup_migrate_get_profile_form_item_options(),
"#default_value" => $this->get('profile_id'),
);
- $form['profile_id']['#description'] = ' '. l(t("Create new profile"), BACKUP_MIGRATE_MENU_PATH . "/profile/add");
+ $form['profile_id']['#description'] = ' ' . l(t('Create new profile'), BACKUP_MIGRATE_MENU_PATH . '/settings/profile/add');
if (!$form['profile_id']['#options']) {
$form['profile_id']['#options'] = array('0' => t('-- None Available --'));
}
@@ -232,40 +427,138 @@ class backup_migrate_schedule extends backup_migrate_item {
$default_period = $this->get_frequency_period();
$default_period_num = $this->get('period') / $default_period['seconds'];
- $form['period'] = array(
+ $form['enabled'] = array(
+ '#type' => "checkbox",
+ '#title' => t('Enabled'),
+ '#default_value' => $this->get('enabled'),
+ );
+ $form['cron_settings'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'enabled' => TRUE,
+ ),
+ );
+
+ $cron = $this->get('cron');
+ $form['cron_settings']['cron_builtin'] = array(
+ "#type" => "radio",
+ "#title" => t('Run using Drupal\'s cron'),
+ '#return_value' => BACKUP_MIGRATE_CRON_BUILTIN,
+ "#description" => t('Run this schedule when !cron runs.', array('!cron' => l(t('your cron task'), 'http://drupal.org/cron'))),
+ "#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
+ '#parents' => array('cron'),
+ );
+
+ $form['cron_settings']['period_settings'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'cron' => BACKUP_MIGRATE_CRON_BUILTIN,
+ ),
+ );
+ $form['cron_settings']['period_settings']['period'] = array(
"#type" => "item",
"#title" => t("Backup every"),
"#prefix" => '
',
"#suffix" => '
',
"#tree" => TRUE,
+ '#parents' => array('period'),
);
- $form['period']['number'] = array(
+ $form['cron_settings']['period_settings']['period']['number'] = array(
"#type" => "textfield",
"#size" => 6,
"#default_value" => $default_period_num,
+ '#parents' => array('period', 'number'),
);
- $form['period']['type'] = array(
+ $form['cron_settings']['period_settings']['period']['type'] = array(
"#type" => "select",
"#options" => $period_options,
"#default_value" => $default_period['type'],
+ '#parents' => array('period', 'type'),
);
- $form['keep'] = array(
+ $form['cron_settings']['cron_elysia'] = array(
+ "#type" => "radio",
+ "#title" => t('Run using Elysia cron'),
+ '#return_value' => BACKUP_MIGRATE_CRON_ELYSIA,
+ "#description" => t('You can specify exactly when this schedule should run using !elysia.', array('!elysia' => l(t('the Elysia Cron module'), 'http://drupal.org/project/elysia_cron'))),
+ "#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
+ '#parents' => array('cron'),
+ );
+ if (!module_exists('elysia_cron') && !module_exists('ultimate_cron')) {
+ $form['cron_settings']['cron_elysia']['#disabled'] = TRUE;
+ $form['cron_settings']['cron_elysia']['#description'] .= ' ' . t('Install !elysia to enable this option.', array('!elysia' => l(t('Elysia Cron'), 'http://drupal.org/project/elysia_cron')));
+ }
+ $form['cron_settings']['cron_schedule_settings'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'cron' => BACKUP_MIGRATE_CRON_ELYSIA,
+ ),
+ );
+ $form['cron_settings']['cron_schedule_settings']['cron_schedule'] = array(
+ "#type" => "textfield",
+ "#title" => t('Cron Schedule'),
+ '#length' => 10,
+ "#description" => t('Specify the frequency of the schedule using standard cron notation. For more information see the !elysiareadme.', array('!elysiareadme' => l(t('the Elysia Cron README'), 'http://drupalcode.org/project/elysia_cron.git/blob/refs/heads/7.x-1.x:/README.txt'))),
+ "#default_value" => $this->get('cron_schedule'),
+ '#parents' => array('cron_schedule'),
+ );
+
+ $form['cron_settings']['cron_none'] = array(
+ "#type" => "radio",
+ "#title" => t('Do not run automatically'),
+ '#return_value' => 'none',
+ "#description" => t('Do not run this schedule automatically. You can still run it using !drush.', array('!drush' => l(t('Drush'), 'http://drupal.org/project/drush'))),
+ "#default_value" => $cron ? $cron : BACKUP_MIGRATE_CRON_BUILTIN,
+ '#parents' => array('cron'),
+ );
+
+ $keep = $this->get('keep');
+ $form['delete'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => $keep != 0,
+ '#title' => t('Automatically delete old backups'),
+ );
+ $form['delete_settings'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'delete' => TRUE,
+ ),
+ );
+
+ $keep_hourly = variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY);
+ $keep_daily = variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY);
+ $keep_weekly = variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY);
+ $form['delete_settings']['smartdelete'] = array(
+ "#type" => "radio",
+ "#title" => t('Smart Delete'),
+ '#return_value' => BACKUP_MIGRATE_SMART_DELETE,
+ "#description" => t('Keep !keep. Recommended', array('!keep' => $this->generate_keep_description(BACKUP_MIGRATE_SMART_DELETE, FALSE))),
+ "#default_value" => $keep ? $keep : BACKUP_MIGRATE_SMART_DELETE,
+ '#parents' => array('deletetype'),
+ );
+ $form['delete_settings']['standarddelete'] = array(
+ "#type" => "radio",
+ "#title" => t('Simple Delete'),
+ '#return_value' => BACKUP_MIGRATE_STANDARD_DELETE,
+ "#description" => t("Keep a specified number of files deleting the oldest ones first."),
+ "#default_value" => $keep > 0 ? BACKUP_MIGRATE_STANDARD_DELETE : 0,
+ '#parents' => array('deletetype'),
+ );
+ $form['delete_settings']['keep-settings'] = array(
+ '#type' => 'backup_migrate_dependent',
+ '#dependencies' => array(
+ 'deletetype' => BACKUP_MIGRATE_STANDARD_DELETE,
+ ),
+ );
+ $form['delete_settings']['keep-settings']['keep'] = array(
"#type" => "textfield",
"#size" => 6,
"#title" => t("Number of Backup files to keep"),
- "#description" => t("The number of backup files to keep before deleting old ones. Use 0 to never delete backups. Other files in the destination directory will get deleted if you specify a limit."),
- "#default_value" => $this->get('keep'),
+ "#description" => t("The number of backup files to keep before deleting old ones."),
+ "#default_value" => $keep > 0 ? $keep : BACKUP_MIGRATE_KEEP_DEFAULT,
);
- $destination_options = _backup_migrate_get_destination_form_item_options('scheduled backup');
- $form['destination_id'] = array(
- "#type" => "select",
- "#title" => t("Destination"),
- "#description" => t("Choose where the backup file will be saved. Backup files contain sensitive data, so be careful where you save them."),
- "#options" => $destination_options,
- "#default_value" => $this->get('destination_id'),
- );
- $form['destination_id']['#description'] .= ' '. l(t("Create new destination"), BACKUP_MIGRATE_MENU_PATH . "/destination/add");
+
+ $form['destination'] = _backup_migrate_get_destination_pulldown('scheduled backup', $this->get('destination_id'), $this->get('copy_destination_id'));
return $form;
}
@@ -273,12 +566,19 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Submit the edit form.
*/
- function edit_form_validate($form, &$form_state) {
+ public function edit_form_validate($form, &$form_state) {
if (!is_numeric($form_state['values']['period']['number']) || $form_state['values']['period']['number'] <= 0) {
form_set_error('period][number', t('Backup period must be a number greater than 0.'));
}
- if (!is_numeric($form_state['values']['keep']) || $form_state['values']['keep'] < 0) {
- form_set_error('keep', t('Number to keep must be an integer greater than or equal to 0.'));
+
+ if (!$form_state['values']['delete']) {
+ $form_state['values']['keep'] = 0;
+ }
+ elseif ($form_state['values']['deletetype'] == BACKUP_MIGRATE_SMART_DELETE) {
+ $form_state['values']['keep'] = BACKUP_MIGRATE_SMART_DELETE;
+ }
+ elseif (!is_numeric($form_state['values']['keep']) || $form_state['values']['keep'] <= 0) {
+ form_set_error('keep', t('Number to keep must be a number greater than 0.'));
}
parent::edit_form_validate($form, $form_state);
}
@@ -286,7 +586,7 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Submit the edit form.
*/
- function edit_form_submit($form, &$form_state) {
+ public function edit_form_submit($form, &$form_state) {
$periods = $this->frequency_periods();
$period = $periods[$form_state['values']['period']['type']];
$form_state['values']['period'] = $form_state['values']['period']['number'] * $period['seconds'];
@@ -294,9 +594,9 @@ class backup_migrate_schedule extends backup_migrate_item {
}
/**
- * Get the period of the frequency (ie: seconds, minutes etc.)
+ * Get the period of the frequency (ie: seconds, minutes etc.).
*/
- function get_frequency_period() {
+ public function get_frequency_period() {
foreach (array_reverse($this->frequency_periods()) as $period) {
if ($period['seconds'] && ($this->period % $period['seconds']) === 0) {
return $period;
@@ -308,7 +608,7 @@ class backup_migrate_schedule extends backup_migrate_item {
* Get a list of available backup periods. Only returns time periods which have a
* (reasonably) consistent number of seconds (ie: no months).
*/
- function frequency_periods() {
+ public function frequency_periods() {
return array(
'seconds' => array('type' => 'seconds', 'seconds' => 1, 'title' => t('Seconds'), 'singular' => t('Once a second'), 'plural' => t('Every @count seconds')),
'minutes' => array('type' => 'minutes', 'seconds' => 60, 'title' => t('Minutes'), 'singular' => t('Once a minute'), 'plural' => t('Every @count minutes')),
@@ -321,83 +621,242 @@ class backup_migrate_schedule extends backup_migrate_item {
/**
* Get the message to send to the user when confirming the deletion of the item.
*/
- function delete_confirm_message() {
- return t('Are you sure you want to delete the profile %name? Any schedules using this profile will be disabled.', array('%name' => $this->get('name')));
+ public function delete_confirm_message() {
+ return t('Are you sure you want to delete the schedule %name? Backups made with this schedule will not be deleted.', array('%name' => $this->get('name')));
}
/**
* Perform the cron action. Run the backup if enough time has elapsed.
*/
- function cron() {
+ public function cron() {
$now = time();
// Add a small negative buffer (1% of the entire period) to the time to account for slight difference in cron run length.
- $wait_time = $this->period - ($this->period * variable_get('backup_migrate_schedule_buffer', 0.01));
+ $wait_time = $this->period - ($this->period * variable_get('backup_migrate_schedule_buffer', BACKUP_MIGRATE_SCHEDULE_BUFFER));
- if ($this->is_enabled() && ($now - $this->get('last_run')) >= $wait_time) {
- if ($settings = $this->get_profile()) {
- $settings->destination_id = $this->destination_id;
- $settings->source_id = $this->source_id;
- backup_migrate_perform_backup($settings);
- $this->update_last_run($now);
- $this->remove_expired_backups();
- }
- else {
- backup_migrate_backup_fail("Schedule '%schedule' could not be run because requires a profile which is missing.", array('%schedule' => $schedule->get_name()), $settings);
- }
+ $cron = $this->get('cron');
+ if ($cron == BACKUP_MIGRATE_CRON_BUILTIN && $this->is_enabled() && ($now - $this->get('last_run')) >= $wait_time) {
+ $this->run();
+ }
+ }
+
+ /**
+ * Run the actual schedule.
+ */
+ public function run() {
+ // Clear cached profile data as it could have been altered by a previous
+ // schedule run.
+ drupal_static_reset('backup_migrate_get_profiles');
+
+ if ($settings = $this->get_profile()) {
+ $settings->source_id = $this->get('source_id');
+ $settings->destination_id = $this->get('destination_ids');
+
+ $this->update_last_run(time());
+ backup_migrate_perform_backup($settings);
+ $this->remove_expired_backups();
+ }
+ else {
+ backup_migrate_backup_fail("Schedule '%schedule' could not be run because requires a profile which is missing.", array('%schedule' => $schedule->get_name()), $settings);
}
}
/**
* Set the last run time of a schedule to the given timestamp, or now if none specified.
*/
- function update_last_run($timestamp = NULL) {
+ public function update_last_run($timestamp = NULL) {
if ($timestamp === NULL) {
$timestamp = time();
}
variable_set('backup_migrate_schedule_last_run_' . $this->get('id'), $timestamp);
}
-/**
+ /**
* Set the last run time of a schedule to the given timestamp, or now if none specified.
*/
- function get_last_run($timestamp = NULL) {
+ public function get_last_run() {
return variable_get('backup_migrate_schedule_last_run_' . $this->get('id'), 0);
}
-
/**
* Remove older backups keeping only the number specified by the aministrator.
*/
- function remove_expired_backups() {
- backup_migrate_include('destinations');
+ public function remove_expired_backups() {
+ require_once dirname(__FILE__) . '/destinations.inc';
$num_to_keep = $this->keep;
// If num to keep is not 0 (0 is infinity).
- if ($num_to_keep && ($destination = $this->get_destination())) {
- $i = 0;
- if ($destination->op('delete') && $destination_files = $destination->list_files()) {
- // Sort the files by modified time.
- foreach ($destination_files as $file) {
- if ($file->is_recognized_type() && $destination->can_delete_file($file->file_id())) {
- $files[str_pad($file->info('filetime'), 10, "0", STR_PAD_LEFT) ."-". $i++] = $file;
- }
+ foreach ((array) $this->get_destinations() as $destination) {
+ if ($destination && $destination->op('delete') && $destination_files = $destination->list_files()) {
+ if ($num_to_keep == BACKUP_MIGRATE_SMART_DELETE) {
+ $this->smart_delete_backups(
+ $destination,
+ $destination_files,
+ variable_get('backup_migrate_smart_keep_subhourly', BACKUP_MIGRATE_SMART_KEEP_SUBHOURLY),
+ variable_get('backup_migrate_smart_keep_hourly', BACKUP_MIGRATE_SMART_KEEP_HOURLY),
+ variable_get('backup_migrate_smart_keep_daily', BACKUP_MIGRATE_SMART_KEEP_DAILY),
+ variable_get('backup_migrate_smart_keep_weekly', BACKUP_MIGRATE_SMART_KEEP_WEEKLY)
+ );
}
-
- // If we are beyond our limit, remove as many as we need.
- $num_files = count($files);
-
- if ($num_files > $num_to_keep) {
- $num_to_delete = $num_files - $num_to_keep;
- // Sort by date.
- ksort($files);
- // Delete from the start of the list (earliest).
- for ($i = 0; $i < $num_to_delete; $i++) {
- $file = array_shift($files);
- $destination->delete_file($file->file_id());
- }
+ elseif ($num_to_keep != BACKUP_MIGRATE_KEEP_ALL) {
+ $this->delete_backups($destination, $destination_files, $num_to_keep);
}
}
}
}
+
+ /**
+ * Remove older backups keeping only the number specified by the aministrator.
+ */
+ public function delete_backups($destination, $files, $num_to_keep) {
+ require_once dirname(__FILE__) . '/destinations.inc';
+
+ $num_to_keep = $this->keep;
+
+ // Sort the files by modified time.
+ $i = 0;
+ foreach ($files as $id => $file) {
+ if ($file->is_recognized_type()) {
+ $time = $file->info('filetime');
+ $sorted[$id] = $time;
+ }
+ }
+ asort($sorted);
+
+ // If we are beyond our limit, remove as many as we need.
+ $num_files = count($files);
+
+ if ($num_files > $num_to_keep) {
+ $num_to_delete = $num_files - $num_to_keep;
+ // Delete from the start of the list (earliest).
+ foreach ($sorted as $id => $time) {
+ if (!$num_to_delete--) {
+ break;
+ }
+ $destination->delete_file($id);
+ }
+ }
+ }
+
+ /**
+ * Delete files keeping the specified number of hourly, daily, weekly and monthly backups.
+ */
+ public function smart_delete_backups($destination, $files, $keep_subhourly = 3600, $keep_hourly = 24, $keep_daily = 14, $keep_weekly = PHP_INT_MAX, $keep_monthly = PHP_INT_MAX) {
+ // Each period must be an exact multiple of the next smallest period.
+ $now = time();
+ $periods = array(
+ 'subhourly' => array(
+ 'delta' => 1,
+ 'keep' => $keep_subhourly,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ 'hourly' => array(
+ 'delta' => 60 * 60,
+ 'keep' => $keep_hourly,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ 'daily' => array(
+ 'delta' => 60 * 60 * 24,
+ 'keep' => $keep_daily,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ 'weekly' => array(
+ 'delta' => 60 * 60 * 24 * 7,
+ 'keep' => $keep_weekly,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ /*
+ 'monthly' => array(
+ 'delta' => 60*60*24*7*4,
+ 'keep' => $keep_monthly,
+ 'last_time' => 0,
+ 'files' => array(),
+ ),
+ */
+ );
+
+ $keep_files = $filetimes = $times = $groups = $sorted = $saved = array();
+ foreach ($files as $id => $file) {
+ if ($file->is_recognized_type()) {
+ $time = $file->info('filetime');
+ $sorted[$id] = $time;
+ }
+ }
+ // Sort files, oldest first.
+ asort($sorted);
+
+ // Reset internal pointer and get the oldest file time.
+ $oldest_file_time = reset($sorted);
+ // Save the oldest file.
+ $keep_files[key($sorted)] = key($sorted);
+
+ foreach ($periods as $i => $period) {
+ $period_keep_files = array();
+ $time = $oldest_file_time;
+
+ // Set time from which we start saving files.
+ $period_start_time = $now - (($period['keep'] + 1) * $period['delta']);
+
+ // Increase time to within one period time span of the period start
+ // time. This keeps all the different period starts aligned.
+ if ($time < $period_start_time) {
+ $time += ((int) ceil(($period_start_time - $time) / $period['delta'])) * $period['delta'];
+ }
+
+ $file_id = $this->find_nearest_file($sorted, $time);
+
+ do {
+ $period_keep_files[$file_id] = $file_id;
+ $last_file_id = $file_id;
+ $time += $period['delta'];
+ $file_id = $this->find_nearest_file($sorted, $time);
+ } while ($time < $now);
+
+ $keep_files = array_merge($keep_files, $period_keep_files);
+ }
+
+ // Do the delete.
+ foreach ($files as $id => $file) {
+ if (!isset($keep_files[$id])) {
+ $destination->delete_file($file->file_id());
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected function find_nearest_file($files, $time) {
+ $last_file_id = NULL;
+ $last_file_time = NULL;
+
+ foreach ($files as $id => $file_time) {
+ if ($file_time >= $time) {
+ if ($last_file_time == NULL) {
+ return $id;
+ }
+ if ($file_time == $time) {
+ return $id;
+ }
+ $time_to_prev = $time - $last_file_time;
+ $time_to_next = $file_time - $time;
+ if ($time_to_prev >= $time_to_next) {
+ return $id;
+ }
+ else {
+ return $last_file_id;
+ }
+
+ // Shouldn't hit this but you never know.
+ break;
+ }
+ $last_file_id = $id;
+ $last_file_time = $file_time;
+ }
+ }
+
}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.archivesource.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.archivesource.inc
new file mode 100644
index 0000000..e6c5f17
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.archivesource.inc
@@ -0,0 +1,314 @@
+ 'archive',
+ 'location' => '.',
+ 'name' => t('Entire Site (code, files & DB)'),
+ 'show_in_list' => FALSE,
+ ));
+ return $out;
+ }
+
+ /**
+ * Returns a list of backup filetypes.
+ */
+ public function file_types() {
+ return array(
+ "sitearchive" => array(
+ "extension" => "sitearchive.tar",
+ "filemime" => "application/x-tar",
+ "backup" => TRUE,
+ "restore" => FALSE,
+ ),
+ );
+ }
+
+ /**
+ * Gets the form for the settings for this destination.
+ */
+ public function backup_settings_default() {
+ $out = parent::backup_settings_default();
+ $excludes = explode("\n", $out['exclude_filepaths']);
+ foreach ($excludes as $i => $exclude) {
+ $excludes[$i] = 'public://' . $exclude;
+ }
+ $excludes[] = 'private://backup_migrate';
+ $excludes[] = conf_path() . '/settings.php';
+ $excludes[] = file_directory_temp();
+
+ return array(
+ 'exclude_filepaths' => implode("\n", $excludes),
+ );
+ }
+
+ /**
+ * Backup from this source.
+ */
+ public function _backup_to_file_php($file, $settings) {
+ if ($this->check_libs()) {
+ $base_dir = $this->get_realpath();
+
+ $excluded_paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
+ $exclude = $this->get_excluded_paths($settings);
+ $files = $this->get_files_to_backup($this->get_realpath(), $settings, $exclude);
+ if ($files) {
+ $manifest = $this->generate_manifest();
+ $db = $this->get_db();
+
+ $file->push_type('sitearchive');
+ $gz = new Archive_Tar($file->filepath(), FALSE);
+
+ $gz->addModify(array($manifest), $file->name . '/', dirname($manifest));
+ $gz->addModify($files, $file->name . '/docroot', $base_dir);
+ $gz->addModify($db, $file->name . '/', dirname($db));
+
+ unlink($manifest);
+ rmdir(dirname($manifest));
+ unlink($db);
+ rmdir(dirname($db));
+
+ return $file;
+ }
+ backup_migrate_backup_fail('No files available.', array(), $settings);
+ return FALSE;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Backup from this source.
+ */
+ public function _backup_to_file_cli($file, $settings) {
+ if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec') && function_exists('escapeshellarg')) {
+ $excluded_paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
+ foreach ($this->get_excluded_paths($excluded_paths) as $path) {
+ $exclude[] = '--exclude=' . escapeshellarg($path);
+ }
+ $exclude = implode(' ', $exclude);
+
+ // Create a symlink in a temp directory so we can rename the file in the
+ // archive.
+ $temp = backup_migrate_temp_directory();
+
+ $manifest = $this->generate_manifest();
+ $db = $this->get_db();
+ rename($db, $temp . '/database.sql');
+ rename($manifest, $temp . '/MANIFEST.ini');
+
+ $file->push_type('sitearchive');
+ $link = $temp . '/docroot';
+ $input = realpath($this->get_location());
+ backup_migrate_exec("ln -s %input %link; tar --dereference -C %temp -rf %output $exclude .", array(
+ '%output' => $file->filepath(),
+ '%input' => $input,
+ '%temp' => $temp,
+ '%link' => $link,
+ ));
+
+ return $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Generates a manifest file.
+ */
+ public function generate_manifest() {
+ $info = array(
+ 'Global' => array(
+ 'datestamp' => time(),
+ 'formatversion' => '2011-07-02',
+ 'generator' => 'Backup and Migrate (http://drupal.org/project/backup_migrate)',
+ 'generatorversion' => BACKUP_MIGRATE_VERSION,
+ ),
+ 'Site 0' => array(
+ 'version' => VERSION,
+ 'name' => variable_get('site_name', ''),
+ 'docroot' => 'docroot',
+ 'sitedir' => 'docroot/' . conf_path(),
+ 'database-file-default' => 'database.sql',
+ 'database-file-driver' => 'mysql',
+ ),
+ );
+ if ($private = variable_get('file_private_path', FALSE)) {
+ $info['Site 0']['files-private'] = 'docroot/' . $private;
+ }
+ $info['Site 0']['files-public'] = 'docroot/' . variable_get('file_public_path', FALSE);
+ $ini = $this->_array_to_ini($info);
+
+ $tmpdir = backup_migrate_temp_directory();
+ $filepath = $tmpdir . '/MANIFEST.ini';
+ file_put_contents($filepath, $ini);
+ return $filepath;
+ }
+
+ /**
+ * Gets a database dump to add to the archive.
+ */
+ public function get_db() {
+ require_once dirname(__FILE__) . '/destinations.inc';
+ require_once dirname(__FILE__) . '/files.inc';
+ require_once dirname(__FILE__) . '/filters.inc';
+ require_once dirname(__FILE__) . '/profiles.inc';
+
+ $file = new backup_file();
+ // Clone the default settings so we can make changes without them leaking
+ // out of this function.
+ $settings = clone _backup_migrate_profile_saved_default_profile();
+ $settings->source_id = 'db';
+ $settings->filters['compression'] = 'none';
+
+ // Execute the backup on the db with the default settings.
+ $file = backup_migrate_filters_backup($file, $settings);
+
+ // Generate a tmp file with the correct final title (because ArchiveTar
+ // doesn't seem to allow renaming).
+ $tmpdir = backup_migrate_temp_directory();
+ $filepath = $tmpdir . '/database.sql';
+ rename($file->filepath(), $filepath);
+
+ return $filepath;
+ }
+
+ /**
+ * Restores to this source.
+ */
+ public function _restore_from_file_php($file, &$settings) {
+ $success = FALSE;
+ if ($this->check_libs()) {
+ $from = $file->pop_type();
+ $temp = backup_migrate_temp_directory();
+
+ $tar = new Archive_Tar($from->filepath());
+ $tar->extractModify($temp, $file->name);
+
+ // Parse the manifest.
+ $manifest = $this->read_manifest($temp);
+
+ // Currently only the first site in the archive is supported.
+ $site = $manifest['Site 0'];
+
+ $docroot = $temp . '/' . $site['docroot'];
+ $sqlfile = $temp . '/' . $site['database-file-default'];
+ $filepath = NULL;
+ if (isset($site['files-private'])) {
+ $filepath = $temp . '/' . $site['files-private'];
+ }
+ elseif (isset($site['files-public'])) {
+ $filepath = $temp . '/' . $site['files-public'];
+ }
+
+ // Move the files from the temp directory.
+ if ($filepath && file_exists($filepath)) {
+ _backup_migrate_move_files($filepath, variable_get('file_public_path', conf_path() . '/files'));
+ }
+ else {
+ _backup_migrate_message('Files were not restored because the archive did not seem to contain a files directory or was in a format that Backup and Migrate couldn\'t read', array(), 'warning');
+ }
+
+ // Restore the sql db.
+ if ($sqlfile && file_exists($sqlfile)) {
+ $db_settings = clone $settings;
+ $db_settings->source_id = 'db';
+ $file = new backup_file(array('filepath' => $sqlfile));
+ $success = backup_migrate_filters_restore($file, $db_settings);
+ }
+ else {
+ _backup_migrate_message('The database was not restored because the archive did not seem to contain a database backup or was in a format that Backup and Migrate couldn\'t read', array(), 'warning');
+ }
+
+ if ($docroot) {
+ _backup_migrate_message('Backup and Migrate cannot restore the php code of the site for security reasons. You will have to copy the code to the server by hand if you wish to restore the full site.', array(), 'warning');
+ }
+
+ return $success && $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Restores to this source.
+ */
+ public function _restore_from_file_cli($file, &$settings) {
+ // @todo implement the cli version of the restore.
+ return FALSE;
+ }
+
+ /**
+ * Generates a manifest file.
+ */
+ public function read_manifest($directory) {
+ // Assume some defaults if values ore the manifest is missing.
+ $defaults = array(
+ 'docroot' => 'docroot',
+ 'database-file-default' => 'database.sql',
+ 'database-file-driver' => 'mysql',
+ );
+
+ $out = $this->_ini_to_array($directory . '/MANIFEST.ini');
+
+ // Set the defaults.
+ $out['Site 0'] = isset($out['Site 0']) ? $out['Site 0'] : array();
+ $out['Site 0'] += $defaults;
+
+ return $out;
+ }
+
+ /**
+ * Converts an associated array to an ini format string.
+ *
+ * Only allows 2 levels of depth to allow parse_ini_file to parse.
+ */
+ public function _array_to_ini($sections) {
+ $content = "";
+ foreach ($sections as $section => $data) {
+ $content .= '[' . $section . ']' . "\n";
+ foreach ($data as $key => $val) {
+ $content .= $key . " = \"" . $val . "\"\n";
+ }
+ $content .= "\n";
+ }
+ return $content;
+ }
+
+ /**
+ * Converts an associated array to an ini format string.
+ *
+ * Only allows 2 levels of depth to allow parse_ini_file to parse.
+ */
+ public function _ini_to_array($path) {
+ return parse_ini_file($path, TRUE);
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.inc
new file mode 100644
index 0000000..ee7b543
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.inc
@@ -0,0 +1,330 @@
+set_source($this->get_id());
+
+ // Restore the file to the source database.
+ $file = backup_migrate_perform_restore($this->get_id(), $file, $settings);
+
+ return $file;
+ }
+
+ /**
+ * Destination configuration callback.
+ */
+ public function edit_form() {
+ $form = parent::edit_form();
+ $form['scheme']['#default_value'] = $this->default_scheme();
+ $form['scheme']['#access'] = FALSE;
+ $form['path']['#title'] = t('Database name');
+ $form['path']['#description'] = t('The name of the database. The database must exist, it will not be created for you.');
+ $form['user']['#description'] = t('Enter the name of a user who has write access to the database.');
+ return $form;
+ }
+
+ /**
+ * Validate the configuration form. Make sure the db info is valid.
+ */
+ public function edit_form_validate($form, &$form_state) {
+ if (!preg_match('/[a-zA-Z0-9_\$]+/', $form_state['values']['path'])) {
+ form_set_error('path', t('The database name is not valid.'));
+ }
+ parent::edit_form_validate($form, $form_state);
+ }
+
+ /**
+ * Get the default settings for this object.
+ *
+ * @return array
+ * The default tables whose data can be ignored. These tables mostly
+ * contain info which can be easily reproducted (such as cache or search
+ * index) but also tables which can become quite bloated but are not
+ * necessarily extremely important to back up or migrate during development
+ * (such as access log and watchdog).
+ */
+ public function backup_settings_default() {
+ $all_tables = $this->_get_table_names();
+
+ // Basic modules that should be excluded.
+ $basic = array(
+ // Default core tables.
+ 'accesslog',
+ 'sessions',
+ 'watchdog',
+ // Search module.
+ 'search_dataset',
+ 'search_index',
+ 'search_keywords_log',
+ 'search_total',
+ // Devel module.
+ 'devel_queries',
+ 'devel_times',
+ );
+
+ // Identify all cache tables.
+ $cache = array('cache');
+ foreach ($all_tables as $table_name) {
+ if (strpos($table_name, 'cache_') === 0) {
+ $cache[] = $table_name;
+ }
+ }
+
+ // Simpletest can create a lot of tables that do not need to be backed up,
+ // but all of them start with the string 'simpletest' so they can be easily
+ // excluded.
+ $simpletest = array();
+ foreach ($all_tables as $table_name) {
+ if (strpos($table_name, 'simpletest') === 0) {
+ $simpletest[] = $table_name;
+ }
+ }
+
+ return array(
+ 'nodata_tables' => drupal_map_assoc(array_merge($basic, $cache, module_invoke_all('devel_caches'))),
+ 'exclude_tables' => $simpletest,
+ 'utils_lock_tables' => FALSE,
+ );
+ }
+
+ /**
+ * Get the form for the backup settings for this destination.
+ */
+ public function backup_settings_form($settings) {
+ $objects = $this->get_object_names();
+ $form['#description'] = t("You may omit specific tables, or specific table data from the backup file. Only omit data that you know you will not need such as cache data, or tables from other applications. Excluding tables can break your Drupal install, so do not change these settings unless you know what you're doing.");
+ $form['exclude_tables'] = array(
+ "#type" => "select",
+ "#multiple" => TRUE,
+ "#title" => t("Exclude the following tables altogether"),
+ "#options" => $objects,
+ "#default_value" => $settings['exclude_tables'],
+ "#description" => t("The selected tables will not be added to the backup file."),
+ );
+ $form['nodata_tables'] = array(
+ "#type" => "select",
+ "#multiple" => TRUE,
+ "#title" => t("Exclude the data from the following tables"),
+ "#options" => $objects,
+ "#default_value" => $settings['nodata_tables'],
+ "#description" => t("The selected tables will have their structure backed up but not their contents. This is useful for excluding cache data to reduce file size."),
+ );
+ $form['utils_lock_tables'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Lock tables during backup'),
+ '#default_value' => !empty($settings['utils_lock_tables']) ? $settings['utils_lock_tables'] : NULL,
+ '#description' => t('This can help reduce data corruption, but will make your site unresponsive.'),
+ );
+ return $form;
+ }
+
+ /**
+ * Backup from this source.
+ */
+ public function backup_to_file($file, $settings) {
+ $file->push_type($this->get_file_type_id());
+
+ // $this->lock_tables($settings);
+ // Switch to a different db if specified.
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Start peak memory usage: %mem', array('%mem' => backup_migrate_get_peak_memory_usage() . 'MB'), 'success');
+ }
+ $success = $this->_backup_db_to_file($file, $settings);
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Finish peak memory usage: %mem', array('%mem' => backup_migrate_get_peak_memory_usage() . 'MB'), 'success');
+ }
+
+ // $this->unlock_tables($settings);
+ return $success ? $file : FALSE;
+ }
+
+ /**
+ * Restore to this source.
+ */
+ public function restore_from_file($file, &$settings) {
+ $num = 0;
+ $type = $this->get_file_type_id();
+ // Open the file using the file wrapper. Check that the dump is of the right type (allow .sql for legacy reasons).
+ if ($file->type_id() !== $this->get_file_type_id() && $file->type_id() !== 'sql') {
+ _backup_migrate_message("Unable to restore from file %file because a %type file can't be restored to this database.", array("%file" => $file->filepath(), '%type' => $file->type_id()), 'error');
+ }
+ else {
+ backup_migrate_filters_invoke_all('pre_restore', $file, $settings);
+
+ // Restore the database.
+ $num = $this->_restore_db_from_file($file, $settings);
+ $settings->performed_action = $num ? t('%num SQL commands executed.', array('%num' => $num)) : '';
+
+ backup_migrate_filters_invoke_all('post_restore', $file, $settings, $num);
+ }
+ return $num;
+ }
+
+ /**
+ * Get the db connection for the specified db.
+ */
+ public function _get_db_connection() {
+ if (!$this->connection) {
+ $target = $key = '';
+ $parts = explode(':', $this->get_id());
+ // One of the predefined databases (set in settings.php)
+ if ($parts[0] == 'db') {
+ $key = empty($parts[1]) ? 'default' : $parts[1];
+ $target = empty($parts[2]) ? 'default' : $parts[2];
+ }
+ // Another db url.
+ else {
+ // If the url is specified build it into a connection info array.
+ if (!empty($this->dest_url)) {
+ $info = array(
+ 'driver' => empty($this->dest_url['scheme']) ? NULL : $this->dest_url['scheme'],
+ 'host' => empty($this->dest_url['host']) ? NULL : $this->dest_url['host'],
+ 'port' => empty($this->dest_url['port']) ? NULL : $this->dest_url['port'],
+ 'username' => empty($this->dest_url['user']) ? NULL : $this->dest_url['user'],
+ 'password' => empty($this->dest_url['pass']) ? NULL : $this->dest_url['pass'],
+ 'database' => empty($this->dest_url['path']) ? NULL : $this->dest_url['path'],
+ );
+ $key = uniqid('backup_migrate_tmp_');
+ $target = 'default';
+ Database::addConnectionInfo($key, $target, $info);
+ }
+ // No database selected. Assume the default.
+ else {
+ $key = $target = 'default';
+ }
+ }
+ if ($target && $key) {
+ $this->connection = Database::getConnection($target, $key);
+ }
+ }
+ return $this->connection;
+ }
+
+ /**
+ * Backup the databases to a file.
+ */
+ public function _backup_db_to_file($file, $settings) {
+ // Must be overridden.
+ }
+
+ /**
+ * Backup the databases to a file.
+ */
+ public function _restore_db_from_file($file, $settings) {
+ // Must be overridden.
+ }
+
+ /**
+ * Get a list of objects in the database.
+ */
+ public function get_object_names() {
+ // Must be overridden.
+ $out = $this->_get_table_names();
+ if (method_exists($this, '_get_view_names')) {
+ $out += $this->_get_view_names();
+ }
+ return $out;
+ }
+
+ /**
+ * Get a list of tables in the database.
+ */
+ public function get_table_names() {
+ // Must be overridden.
+ $out = $this->_get_table_names();
+ return $out;
+ }
+
+ /**
+ * Get a list of tables in the database.
+ */
+ public function _get_table_names() {
+ // Must be overridden.
+ return array();
+ }
+
+ /**
+ * Lock the database in anticipation of a backup.
+ */
+ public function lock_tables($settings) {
+ if ($settings->filters['utils_lock_tables']) {
+ $tables = array();
+ foreach ($this->get_table_names() as $table) {
+ // There's no need to lock excluded or structure only tables because it doesn't matter if they change.
+ if (empty($settings->filters['exclude_tables']) || !in_array($table, (array) $settings->filters['exclude_tables'])) {
+ $tables[] = $table;
+ }
+ }
+ $this->_lock_tables($tables);
+ }
+ }
+
+ /**
+ * Lock the list of given tables in the database.
+ */
+ public function _lock_tables($tables) {
+ // Must be overridden.
+ }
+
+ /**
+ * Unlock any tables that have been locked.
+ */
+ public function unlock_tables($settings) {
+ if ($settings->filters['utils_lock_tables']) {
+ $this->_unlock_tables();
+ }
+ }
+
+ /**
+ * Unlock the list of given tables in the database.
+ */
+ public function _unlock_tables($tables) {
+ // Must be overridden.
+ }
+
+ /**
+ * Get the file type for to backup this destination to.
+ */
+ public function get_file_type_id() {
+ return 'sql';
+ }
+
+ /**
+ * Get the version info for the given DB.
+ */
+ public function _db_info() {
+ return array(
+ 'type' => FALSE,
+ 'version' => t('Unknown'),
+ );
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.mysql.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.mysql.inc
new file mode 100644
index 0000000..677e3a1
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.db.mysql.inc
@@ -0,0 +1,593 @@
+ array(
+ "extension" => "sql",
+ "filemime" => "text/x-sql",
+ "backup" => TRUE,
+ "restore" => TRUE,
+ ),
+ "mysql" => array(
+ "extension" => "mysql",
+ "filemime" => "text/x-sql",
+ "backup" => TRUE,
+ "restore" => TRUE,
+ ),
+ );
+ }
+
+ /**
+ * Return the scheme for this db type.
+ */
+ public function default_scheme() {
+ return 'mysql';
+ }
+
+ /**
+ * Declare any mysql databases defined in the settings.php file as a possible source.
+ */
+ public function sources() {
+ $out = array();
+ global $databases;
+ foreach ((array) $databases as $db_key => $target) {
+ foreach ((array) $target as $tgt_key => $info) {
+ // Only mysql/mysqli supported by this source.
+ $key = $db_key . ':' . $tgt_key;
+ if ($info['driver'] === 'mysql') {
+ // Compile the database connection string.
+ $url = 'mysql://';
+ $url .= urlencode($info['username']) . ':' . urlencode($info['password']);
+ $url .= '@';
+ $url .= urlencode($info['host']);
+ if (!empty($info['port'])) {
+ $url .= ':' . $info['port'];
+ }
+ $url .= '/' . urlencode($info['database']);
+
+ if ($source = backup_migrate_create_destination('mysql', array('url' => $url))) {
+ // Treat the default database differently because it is probably
+ // the only one available.
+ if ($key == 'default:default') {
+ $source->set_id('db');
+ $source->set_name(t('Default Database'));
+ // Dissalow backing up to the default database because that's confusing and potentially dangerous.
+ $source->remove_op('scheduled backup');
+ $source->remove_op('manual backup');
+ }
+ else {
+ $source->set_id('db:' . $key);
+ $source->set_name($key . ": " . $source->get_display_location());
+ }
+ $out[$source->get_id()] = $source;
+ }
+ }
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Get the file type for to backup this source to.
+ */
+ public function get_file_type_id() {
+ return 'mysql';
+ }
+
+ /**
+ * Backup the databases to a file.
+ *
+ * Returns a list of sql commands, one command per line.
+ * That makes it easier to import without loading the whole file into memory.
+ * The files are a little harder to read, but human-readability is not a priority.
+ */
+ public function _backup_db_to_file($file, $settings) {
+ if (!empty($settings->filters['use_cli']) && $this->_backup_db_to_file_mysqldump($file, $settings)) {
+ return TRUE;
+ }
+
+ $lines = 0;
+ $exclude = !empty($settings->filters['exclude_tables']) ? $settings->filters['exclude_tables'] : array();
+ $nodata = !empty($settings->filters['nodata_tables']) ? $settings->filters['nodata_tables'] : array();
+ if ($file->open(TRUE)) {
+ $file->write($this->_get_sql_file_header());
+ $alltables = $this->_get_tables();
+ $allviews = $this->_get_views();
+
+ foreach ($alltables as $table) {
+ if (_backup_migrate_check_timeout()) {
+ return FALSE;
+ }
+ if ($table['name'] && !isset($exclude[$table['name']])) {
+ $file->write($this->_get_table_structure_sql($table));
+ $lines++;
+ if (!in_array($table['name'], $nodata)) {
+ $lines += $this->_dump_table_data_sql_to_file($file, $table);
+ }
+ }
+ }
+ foreach ($allviews as $view) {
+ if (_backup_migrate_check_timeout()) {
+ return FALSE;
+ }
+ if ($view['name'] && !isset($exclude[$view['name']])) {
+ $file->write($this->_get_view_create_sql($view));
+ }
+ }
+ $file->write($this->_get_sql_file_footer());
+ $file->close();
+ return $lines;
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+ /**
+ * Backup the databases to a file using the mysqldump command.
+ */
+ public function _backup_db_to_file_mysqldump($file, $settings) {
+ $success = FALSE;
+ $nodata_tables = array();
+ $alltables = $this->_get_tables();
+
+ $command = 'mysqldump --result-file=%file --opt -Q --host=%host --port=%port --user=%user --password=%pass %db';
+ $args = array(
+ '%file' => $file->filepath(),
+ '%host' => $this->dest_url['host'],
+ '%port' => isset($this->dest_url['port']) ? $this->dest_url['port'] : '3306',
+ '%user' => $this->dest_url['user'],
+ '%pass' => $this->dest_url['pass'],
+ '%db' => $this->dest_url['path'],
+ );
+
+ // Ignore the excluded and no-data tables.
+ $db = $this->dest_url['path'];
+ if (!empty($settings->filters['exclude_tables'])) {
+ foreach ((array) $settings->filters['exclude_tables'] as $table) {
+ if (isset($alltables[$table])) {
+ $command .= ' --ignore-table=' . $db . '.' . $table;
+ }
+ }
+ }
+ if (!empty($settings->filters['nodata_tables'])) {
+ foreach ((array) $settings->filters['nodata_tables'] as $table) {
+ if (isset($alltables[$table])) {
+ $nodata_tables[] = $table;
+ $command .= ' --ignore-table=' . $db . '.' . $table;
+ }
+ }
+ }
+ $success = backup_migrate_exec($command, $args);
+
+ // Get the nodata tables.
+ if ($success && !empty($nodata_tables)) {
+ $tables = implode(' ', array_unique($nodata_tables));
+ $command = "mysqldump --no-data --opt -Q --host=%host --port=%port --user=%user --password=%pass %db $tables >> %file";
+ $success = backup_migrate_exec($command, $args);
+ }
+ return $success;
+ }
+
+ /**
+ * Backup the databases to a file.
+ */
+ public function _restore_db_from_file($file, $settings) {
+ $num = 0;
+
+ if ($file->open() && $conn = $this->_get_db_connection()) {
+ // Optionally drop all existing tables.
+ if (!empty($settings->filters['utils_drop_all_tables'])) {
+ $all_tables = $this->_get_tables();
+ $table_names = array_map('backup_migrate_array_name_value', $all_tables);
+ $table_list = join(', ', $table_names);
+ $stmt = $conn->prepare("DROP TABLE IF EXISTS $table_list;\n");
+ $stmt->execute();
+ }
+
+ // Read one line at a time and run the query.
+ while ($line = $this->_read_sql_command_from_file($file)) {
+ if (_backup_migrate_check_timeout()) {
+ return FALSE;
+ }
+ if ($line) {
+ // Prepeare and exexute the statement instead of the api function to avoid substitution of '{' etc.
+ $stmt = $conn->prepare($line);
+ $stmt->execute();
+ $num++;
+ }
+ }
+ // Close the file with fclose/gzclose.
+ $file->close();
+ }
+ else {
+ drupal_set_message(t("Unable to open file %file to restore database", array("%file" => $file->filepath())), 'error');
+ $num = FALSE;
+ }
+ return $num;
+ }
+
+ /**
+ * Read a multiline sql command from a file.
+ *
+ * Supports the formatting created by mysqldump, but won't handle multiline comments.
+ */
+ public function _read_sql_command_from_file($file) {
+ $out = '';
+ while ($line = $file->read()) {
+ $first2 = substr($line, 0, 2);
+ $first3 = substr($line, 0, 3);
+
+ // Ignore single line comments. This function doesn't support multiline comments or inline comments.
+ if ($first2 != '--' && ($first2 != '/*' || $first3 == '/*!')) {
+ $out .= ' ' . trim($line);
+ // If a line ends in ; or */ it is a sql command.
+ if (substr($out, strlen($out) - 1, 1) == ';') {
+ return trim($out);
+ }
+ }
+ }
+ return trim($out);
+ }
+
+ /**
+ * Get a list of tables in the database.
+ */
+ public function _get_table_names() {
+ if (empty(static::$tableNames)) {
+ static::$tableNames = $this->query("SHOW FULL TABLES WHERE Table_Type = 'BASE TABLE'")
+ ->fetchAllKeyed(0, 0);
+ }
+
+ return static::$tableNames;
+ }
+
+ /**
+ * Get a list of views in the database.
+ */
+ public function _get_view_names() {
+ if (empty(static::$viewNames)) {
+ static::$viewNames = $this->query("SHOW FULL TABLES WHERE Table_Type = 'VIEW'")
+ ->fetchAllKeyed(0, 0);
+ }
+
+ return static::$viewNames;
+ }
+
+ /**
+ * Lock the list of given tables in the database.
+ */
+ public function _lock_tables($tables) {
+ if ($tables) {
+ $tables_escaped = array();
+ foreach ($tables as $table) {
+ $tables_escaped[] = '`' . db_escape_table($table) . '` WRITE';
+ }
+ $this->query('LOCK TABLES ' . implode(', ', $tables_escaped));
+ }
+ }
+
+ /**
+ * Unlock all tables in the database.
+ */
+ public function _unlock_tables($settings) {
+ $this->query('UNLOCK TABLES');
+ }
+
+ /**
+ * Get a list of table and view data in the db.
+ */
+ protected function get_table_data() {
+ if (empty(static::$tableData)) {
+ $tables = $this->query('SHOW TABLE STATUS')->fetchAll(PDO::FETCH_ASSOC);
+
+ foreach ($tables as $table) {
+ // Lowercase the keys because between Drupal 7.12 and 7.13/14 the
+ // default query behavior was changed.
+ // See: http://drupal.org/node/1171866
+ $table = array_change_key_case($table);
+ static::$tableData[$table['name']] = $table;
+ }
+ }
+
+ return static::$tableData;
+ }
+
+ /**
+ * Get a list of tables in the db.
+ */
+ public function _get_tables() {
+ $out = array();
+ foreach ($this->get_table_data() as $table) {
+ if (!empty($table['engine'])) {
+ $out[$table['name']] = $table;
+ }
+ }
+
+ return $out;
+ }
+
+ /**
+ * Get a list of views in the db.
+ */
+ public function _get_views() {
+ $out = array();
+ foreach ($this->get_table_data() as $table) {
+ if (empty($table['engine'])) {
+ $out[$table['name']] = $table;
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Get the sql for the structure of the given view.
+ */
+ public function _get_view_create_sql($view) {
+ $out = "";
+ // Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more permissions + troubles with the DEFINER user.
+ $sql_mode = $this->query("SELECT @@SESSION.sql_mode")->fetchField();
+ $this->query("SET sql_mode = 'ANSI'");
+ $result = $this->query("SHOW CREATE VIEW `" . $view['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
+ $this->query("SET SQL_mode = :mode", array(':mode' => $sql_mode));
+ foreach ($result as $create) {
+ // Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
+ // See: http://drupal.org/node/1171866
+ $create = array_change_key_case($create);
+ $out .= "DROP VIEW IF EXISTS `" . $view['name'] . "`;\n";
+ $out .= "SET sql_mode = 'ANSI';\n";
+ $out .= strtr($create['create view'], "\n", " ") . ";\n";
+ $out .= "SET sql_mode = '$sql_mode';\n";
+ }
+ return $out;
+ }
+
+ /**
+ * Get the sql for the structure of the given table.
+ */
+ public function _get_table_structure_sql($table) {
+ $out = "";
+ $result = $this->query("SHOW CREATE TABLE `" . $table['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $create) {
+ // Lowercase the keys because between Drupal 7.12 and 7.13/14 the default query behavior was changed.
+ // See: http://drupal.org/node/1171866
+ $create = array_change_key_case($create);
+ $out .= "DROP TABLE IF EXISTS `" . $table['name'] . "`;\n";
+ // Remove newlines and convert " to ` because PDO seems to convert those for some reason.
+ $out .= strtr($create['create table'], array("\n" => ' ', '"' => '`'));
+ if ($table['auto_increment']) {
+ $out .= " AUTO_INCREMENT=" . $table['auto_increment'];
+ }
+ $out .= ";\n";
+ }
+ return $out;
+ }
+
+ /**
+ * Get the sql to insert the data for a given table.
+ */
+ public function _dump_table_data_sql_to_file($file, $table) {
+ $rows_per_query = variable_get('backup_migrate_data_rows_per_query', BACKUP_MIGRATE_DATA_ROWS_PER_QUERY);
+ $rows_per_line = variable_get('backup_migrate_data_rows_per_line', BACKUP_MIGRATE_DATA_ROWS_PER_LINE);
+ $bytes_per_line = variable_get('backup_migrate_data_bytes_per_line', BACKUP_MIGRATE_DATA_BYTES_PER_LINE);
+
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Table: %table', array('%table' => $table['name']), 'success');
+ }
+
+ // Escape backslashes, PHP code, special chars.
+ $search = array('\\', "'", "\x00", "\x0a", "\x0d", "\x1a");
+ $replace = array('\\\\', "''", '\0', '\n', '\r', '\Z');
+
+ $lines = 0;
+ $from = 0;
+ $args = array('fetch' => PDO::FETCH_ASSOC);
+ while ($data = $this->query("SELECT * FROM `" . $table['name'] . "`", array(), $args, $from, $rows_per_query)) {
+ if ($data->rowCount() == 0) {
+ break;
+ }
+
+ $rows = $bytes = 0;
+
+ $line = array();
+ foreach ($data as $row) {
+ $from++;
+
+ // DB Escape the values.
+ $items = array();
+ foreach ($row as $key => $value) {
+ $items[] = is_null($value) ? "null" : "'" . str_replace($search, $replace, $value) . "'";
+ }
+
+ // If there is a row to be added.
+ if ($items) {
+ // Start a new line if we need to.
+ if ($rows == 0) {
+ $file->write("INSERT INTO `" . $table['name'] . "` VALUES ");
+ $bytes = $rows = 0;
+ }
+ // Otherwise add a comma to end the previous entry.
+ else {
+ $file->write(",");
+ }
+
+ // Write the data itself.
+ $sql = implode(',', $items);
+ $file->write('(' . $sql . ')');
+ $bytes += strlen($sql);
+ $rows++;
+
+ // Finish the last line if we've added enough items.
+ if ($rows >= $rows_per_line || $bytes >= $bytes_per_line) {
+ $file->write(";\n");
+ $lines++;
+ $bytes = $rows = 0;
+ }
+ }
+ }
+
+ // Finish any unfinished insert statements.
+ if ($rows > 0) {
+ $file->write(";\n");
+ $lines++;
+ }
+ }
+
+ if (variable_get('backup_migrate_verbose')) {
+ _backup_migrate_message('Peak memory usage: %mem', array('%mem' => backup_migrate_get_peak_memory_usage() . 'MB'), 'success');
+ }
+
+ return $lines;
+ }
+
+ /**
+ * Get the db connection for the specified db.
+ */
+ public function _get_db_connection() {
+ if (!$this->connection) {
+ $this->connection = parent::_get_db_connection();
+ // Set the sql mode because the default is ANSI,TRADITIONAL which is not aware of collation or storage engine.
+ $this->connection->exec("SET sql_mode=''");
+ }
+ return $this->connection;
+ }
+
+ /**
+ * Run a query on this source's database using Drupal's MySQL engine.
+ *
+ * @param string $query
+ * The query string.
+ * @param array $args
+ * Arguments for the query.
+ * @param array $options
+ * Options to pass to the query.
+ * @param int|null $from
+ * The starting point for the query; when passed will perform a queryRange()
+ * method instead of a regular query().
+ * @param int|null $count
+ * The number of records to obtain from this query. Will be ignored if the
+ * $from argument is empty.
+ *
+ * @see DatabaseConnection_mysql::query()
+ * @see DatabaseConnection_mysql::queryRange()
+ */
+ public function query($query, array $args = array(), array $options = array(), $from = NULL, $count = NULL) {
+ if ($conn = $this->_get_db_connection()) {
+ // If no $from is passed in, just do a basic query.
+ if (is_null($from)) {
+ return $conn->query($query, $args, $options);
+ }
+ // The $from variable was passed in, so do a ranged query.
+ else {
+ return $conn->queryRange($query, $from, $count, $args, $options);
+ }
+ }
+ }
+
+ /**
+ * The header for the top of the sql dump file. These commands set the connection
+ * character encoding to help prevent encoding conversion issues.
+ */
+ public function _get_sql_file_header() {
+ $info = $this->_db_info();
+
+ return "-- Backup and Migrate (Drupal) MySQL Dump
+-- Backup and Migrate Version: " . BACKUP_MIGRATE_VERSION . "
+-- http://drupal.org/project/backup_migrate
+-- Drupal Version: " . VERSION . "
+-- http://drupal.org/
+--
+-- Host: " . url('', array('absolute' => TRUE)) . "
+-- Site Name: " . url('', array('absolute' => TRUE)) . "
+-- Generation Time: " . format_date(time(), 'custom', 'r') . "
+-- MySQL Version: " . $info['version'] . "
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
+
+SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";
+SET NAMES utf8mb4;
+
+";
+ }
+
+ /**
+ * The footer of the sql dump file.
+ */
+ public function _get_sql_file_footer() {
+ return "
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+";
+ }
+
+ /**
+ * Get the version info for the given DB.
+ */
+ public function _db_info() {
+ $db = $this->_get_db_connection();
+ return array(
+ 'type' => 'mysql',
+ 'version' => $db ? $db->version() : t('Unknown'),
+ );
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.filesource.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.filesource.inc
new file mode 100644
index 0000000..a6dfa64
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.filesource.inc
@@ -0,0 +1,335 @@
+ 'files',
+ 'location' => 'public://',
+ 'name' => t('Public Files Directory'),
+ 'show_in_list' => FALSE,
+ ));
+ if (variable_get('file_private_path', FALSE)) {
+ $out['files_private'] = backup_migrate_create_destination('filesource', array(
+ 'machine_name' => 'files',
+ 'location' => 'private://',
+ 'name' => t('Private Files Directory'),
+ 'show_in_list' => FALSE,
+ ));
+ }
+ return $out;
+ }
+
+ /**
+ * Gets the form for the settings for the files destination.
+ */
+ public function edit_form() {
+ $form = parent::edit_form();
+ $form['location'] = array(
+ "#type" => "textfield",
+ "#title" => t("Directory path"),
+ "#default_value" => $this->get_location(),
+ "#required" => TRUE,
+ "#description" => t('Enter the path to the directory to back up. Use a relative path to pick a path relative to your Drupal root directory. The web server must be able to read from this path.'),
+ );
+ return $form;
+ }
+
+ /**
+ * Returns a list of backup filetypes.
+ */
+ public function file_types() {
+ return array(
+ "tar" => array(
+ "extension" => "tar",
+ "filemime" => "application/x-tar",
+ "backup" => TRUE,
+ "restore" => TRUE,
+ ),
+ );
+ }
+
+ /**
+ * Gets the form for the settings for this destination.
+ *
+ * Return the default directories whose data can be ignored. These directories
+ * contain info which can be easily reproducted. Also exclude the backup and
+ * migrate folder to prevent exponential bloat.
+ */
+ public function backup_settings_default() {
+ return array(
+ 'exclude_filepaths' => "backup_migrate\nstyles\ncss\njs\nctools\nless\nlanguages\nadvagg_css\nadvagg_js",
+ );
+ }
+
+ /**
+ * Get the form for the backup settings for this destination.
+ */
+ public function backup_settings_form($settings) {
+ $form['exclude_filepaths'] = array(
+ "#type" => "textarea",
+ "#multiple" => TRUE,
+ "#title" => t("Exclude the following files or directories"),
+ "#default_value" => isset($settings['exclude_filepaths']) ? $settings['exclude_filepaths'] : '',
+ "#description" => t("A list of files or directories to be excluded from backups. Add one path per line relative to the directory being backed up."),
+ );
+ return $form;
+ }
+
+ /**
+ * Backup from this source.
+ */
+ public function backup_to_file($file, $settings) {
+ if ($out = $this->_backup_to_file_cli($file, $settings)) {
+ return $out;
+ }
+ else {
+ return $this->_backup_to_file_php($file, $settings);
+ }
+ }
+
+ /**
+ * Backup from this source.
+ */
+ public function _backup_to_file_php($file, $settings) {
+ if ($this->check_libs()) {
+ $excluded = $this->get_excluded_paths($settings);
+ $files = $this->get_files_to_backup($this->get_realpath(), $settings, $excluded);
+ if ($files) {
+ $file->push_type('tar');
+ $gz = new Archive_Tar($file->filepath(), FALSE);
+ $gz->addModify($files, '', $this->get_realpath());
+ return $file;
+ }
+ backup_migrate_backup_fail('No files available.', array(), $settings);
+ return FALSE;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Backup from this source.
+ */
+ public function _backup_to_file_cli($file, $settings) {
+ if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec') && function_exists('escapeshellarg')) {
+ $excluded = $this->get_excluded_paths($settings);
+ $exclude = array();
+ foreach ($excluded as $path) {
+ $exclude[] = '--exclude=' . escapeshellarg($path);
+ }
+ $exclude = implode(' ', $exclude);
+
+ // Create a symlink in a temp directory so we can rename the file in the
+ // archive.
+ $temp = backup_migrate_temp_directory();
+
+ $file->push_type('tar');
+ backup_migrate_exec("tar --dereference -C %input -rf %output $exclude .", array(
+ '%output' => $file->filepath(),
+ '%input' => $this->get_realpath(),
+ '%temp' => $temp,
+ ));
+ return $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Restore to this source.
+ */
+ public function restore_from_file($file, &$settings) {
+ if ($out = $this->_restore_from_file_cli($file, $settings)) {
+ return $out;
+ }
+ else {
+ return $this->_restore_from_file_php($file, $settings);
+ }
+ }
+
+ /**
+ * Restore to this source.
+ */
+ public function _restore_from_file_php($file, &$settings) {
+ if ($this->check_libs()) {
+ $from = $file->pop_type();
+ $temp = backup_migrate_temp_directory();
+
+ $tar = new Archive_Tar($from->filepath());
+ $tar->extractModify($temp, $file->name);
+
+ // Older B&M Files format included a base 'files' directory.
+ if (file_exists($temp . '/files')) {
+ $temp = $temp . '/files';
+ }
+ if (file_exists($temp . '/' . $file->name . '/files')) {
+ $temp = $temp . '/files';
+ }
+
+ // Move the files from the temp directory.
+ _backup_migrate_move_files($temp, $this->get_realpath());
+
+ return $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Restore to this source.
+ */
+ public function _restore_from_file_cli($file, &$settings) {
+ if (!empty($settings->filters['use_cli']) && function_exists('backup_migrate_exec')) {
+ $temp = backup_migrate_temp_directory();
+ backup_migrate_exec("tar -C %temp -xf %input", array('%input' => $file->filepath(), '%temp' => $temp));
+
+ // Older B&M Files format included a base 'files' directory.
+ if (file_exists($temp . '/files')) {
+ $temp = $temp . '/files';
+ }
+ if (file_exists($temp . '/' . $file->name . '/files')) {
+ $temp = $temp . '/files';
+ }
+
+ // Move the files from the temp directory.
+ backup_migrate_exec("mv -rf %temp/* %output", array('%output' => $this->get_realpath(), '%temp' => $temp));
+ return $file;
+ }
+ return FALSE;
+ }
+
+ /**
+ * Gets a list of files to backup from the given set if dirs.
+ *
+ * Exclude any that match the array $exclude.
+ */
+ public function get_files_to_backup($dir, $settings, $exclude = array()) {
+ $out = $errors = array();
+
+ if (!file_exists($dir)) {
+ backup_migrate_backup_fail('Directory %dir does not exist.', array('%dir' => $dir), $settings);
+ return FALSE;
+ }
+ if ($handle = @opendir($dir)) {
+ while (($file = readdir($handle)) !== FALSE) {
+ if ($file != '.' && $file != '..' && !in_array($file, $exclude)) {
+ $real = realpath($dir . '/' . $file);
+ // If the path is not excluded.
+ if (!in_array($real, $exclude)) {
+ if (is_dir($real)) {
+ $subdir = $this->get_files_to_backup($real, $settings, $exclude);
+ // If there was an error reading the subdirectory then abort the
+ // backup.
+ if ($subdir === FALSE) {
+ closedir($handle);
+ return FALSE;
+ }
+ // If the directory is empty, add an empty directory.
+ if (count($subdir) == 0) {
+ $out[] = $real;
+ }
+ $out = array_merge($out, $subdir);
+ }
+ else {
+ if (is_readable($real)) {
+ $out[] = $real;
+ }
+ else {
+ $errors[] = $dir . '/' . $file;
+ }
+ }
+ }
+ }
+ }
+ closedir($handle);
+ }
+ else {
+ backup_migrate_backup_fail('Could not open directory %dir', array('%dir' => $dir), $settings);
+ return FALSE;
+ }
+
+ // Alert the user to any errors there might have been.
+ if ($errors) {
+ if (count($errors < 5)) {
+ $filesmsg = t('The following files: !files', array('!files' => theme('item_list', array('items' => $errors))));
+ }
+ else {
+ $filesmsg = t('!count files', array('!count' => count($errors)));
+ }
+
+ if (empty($settings->filters['ignore_errors'])) {
+ backup_migrate_backup_fail('The backup could not be completed because !files could not be read. If you want to skip unreadable files use the \'Ignore Errors\' setting under \'Advanced Options\' in \'Advanced Backup\' or in your schedule settings profile.', array('!files' => $filesmsg), 'error');
+ $out = FALSE;
+ }
+ else {
+ backup_migrate_backup_fail('!files could not be read and were skipped', array('!files' => $filesmsg), 'error');
+ }
+ }
+
+ return $out;
+ }
+
+ /**
+ * Breaks the excluded paths string into a usable list of paths.
+ */
+ public function get_excluded_paths($settings) {
+ $base_dir = $this->get_realpath() . '/';
+ $paths = empty($settings->filters['exclude_filepaths']) ? '' : $settings->filters['exclude_filepaths'];
+ $out = explode("\n", $paths);
+ foreach ($out as $key => $val) {
+ $path = trim($val, "/ \t\r\n");
+ // If the path specified is a stream url or absolute path add the
+ // normalized version.
+ if ($real = drupal_realpath($path)) {
+ $out[$key] = $real;
+ }
+ // If the path is a relative path add it.
+ elseif ($real = drupal_realpath($base_dir . $path)) {
+ $out[$key] = $real;
+ }
+ // Otherwise add it as is even though it probably won't match any files.
+ else {
+ $out[$key] = $path;
+ }
+ }
+ return $out;
+ }
+
+ /**
+ * Checks that the required libraries are installed.
+ */
+ public function check_libs() {
+ $result = TRUE;
+ // Drupal 7 has Archive_Tar built in so there should be no need to include
+ // anything here.
+ return $result;
+ }
+
+ /**
+ * Get the file location.
+ */
+ public function get_realpath() {
+ return drupal_realpath($this->get_location());
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/includes/sources.inc b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.inc
new file mode 100644
index 0000000..902c5b4
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/includes/sources.inc
@@ -0,0 +1,274 @@
+ array(
+ 'type_name' => t('Database'),
+ 'description' => t('Import the backup directly into another database. Database sources can also be used as a source to backup from.'),
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/sources.db.inc',
+ 'class' => 'backup_migrate_source_db',
+ 'can_create' => FALSE,
+ ),
+ 'mysql' => array(
+ 'type_name' => t('MySQL Database'),
+ 'description' => t('Import the backup directly into another MySQL database. Database sources can also be used as a source to backup from.'),
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/sources.db.mysql.inc',
+ 'class' => 'backup_migrate_source_db_mysql',
+ 'can_create' => TRUE,
+ ),
+ 'filesource' => array(
+ 'description' => t('A files directory which can be backed up from.'),
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/sources.filesource.inc',
+ 'class' => 'backup_migrate_destination_filesource',
+ 'type_name' => t('File Directory'),
+ 'can_create' => TRUE,
+ ),
+ 'archive' => array(
+ 'description' => t('Create an archive of your entire site.'),
+ 'file' => drupal_get_path('module', 'backup_migrate') . '/includes/sources.archivesource.inc',
+ 'class' => 'backup_migrate_files_destination_archivesource',
+ 'type_name' => t('Site Archive'),
+ 'can_create' => FALSE,
+ ),
+ );
+
+ return $out;
+}
+
+/**
+ * Implements hook_backup_migrate_sources().
+ *
+ * Get the built in backup sources and those in the db.
+ */
+function backup_migrate_backup_migrate_sources() {
+ require_once dirname(__FILE__) . '/filters.inc';
+
+ // Expose the configured databases as sources.
+ $out = backup_migrate_filters_invoke_all('sources');
+
+ return $out;
+}
+
+/**
+ * Get the source options as a form element.
+ */
+function _backup_migrate_get_source_form($source_id = 'db') {
+ require_once dirname(__FILE__) . '/destinations.inc';
+
+ $form = array();
+ $sources = _backup_migrate_get_source_pulldown($source_id);
+ if (count($sources['#options']) > 1) {
+ $form['source'] = array(
+ "#type" => "fieldset",
+ "#title" => t("Backup Source"),
+ "#collapsible" => TRUE,
+ "#collapsed" => FALSE,
+ "#tree" => FALSE,
+ );
+ $sources['#description'] = t("Choose the database to backup. Any database destinations you have created and any databases specified in your settings.php can be backed up.");
+
+ $form['source']['source_id'] = $sources;
+ }
+ else {
+ $form = array();
+ $form['source']['source_id'] = array(
+ "#type" => "value",
+ "#value" => $source_id,
+ );
+ }
+ return $form;
+}
+
+/**
+ * Get pulldown to select existing source options.
+ */
+function _backup_migrate_get_source_pulldown($source_id = NULL) {
+ $sources = _backup_migrate_get_source_form_item_options();
+ $form = array(
+ "#type" => "select",
+ "#title" => t("Backup Source"),
+ "#options" => _backup_migrate_get_source_form_item_options(),
+ "#default_value" => $source_id,
+ );
+ return $form;
+}
+
+/**
+ * Get the location options as an options array for a form item.
+ */
+function _backup_migrate_get_source_form_item_options() {
+ $out = array();
+ foreach (backup_migrate_get_sources() as $key => $location) {
+ $out[$key] = $location->get_name();
+ }
+ return $out;
+}
+
+/**
+ * A base class for creating sources.
+ */
+class backup_migrate_source extends backup_migrate_location {
+ public $db_table = "backup_migrate_sources";
+ public $type_name = 'source';
+ public $singular = 'source';
+ public $plural = 'sources';
+ public $title_plural = 'Sources';
+ public $title_singular = 'Source';
+
+ /**
+ * This function is not supposed to be called.
+ *
+ * It is just here to help out the po extractor.
+ */
+ public function strings() {
+ // Help the pot extractor find these strings.
+ t('source');
+ t('sources');
+ t('Sources');
+ t('Source');
+ }
+
+ /**
+ * Get the available location types.
+ */
+ public function location_types() {
+ return backup_migrate_get_source_subtypes();
+ }
+
+}
+
+/**
+ * A base class for creating sources.
+ */
+class backup_migrate_source_remote extends backup_migrate_source {
+
+ /**
+ * The location is a URI so parse it and store the parts.
+ */
+ public function get_location() {
+ return $this->url(FALSE);
+ }
+
+ /**
+ * The location to display is the url without the password.
+ */
+ public function get_display_location() {
+ return $this->url(TRUE);
+ }
+
+ /**
+ * Returns the location with the password.
+ */
+ public function set_location($location) {
+ $this->location = $location;
+ $this->set_url($location);
+ }
+
+ /**
+ * Source configuration callback.
+ */
+ public function edit_form() {
+ $form = parent::edit_form();
+ $form['scheme'] = array(
+ "#type" => "textfield",
+ "#title" => t("Scheme"),
+ "#default_value" => @$this->dest_url['scheme'] ? $this->dest_url['scheme'] : '',
+ "#required" => TRUE,
+ "#weight" => 0,
+ );
+ $form['host'] = array(
+ "#type" => "textfield",
+ "#title" => t("Host"),
+ "#default_value" => @$this->dest_url['host'] ? $this->dest_url['host'] : 'localhost',
+ "#required" => TRUE,
+ "#weight" => 10,
+ );
+ $form['path'] = array(
+ "#type" => "textfield",
+ "#title" => t("Path"),
+ "#default_value" => @$this->dest_url['path'],
+ "#required" => TRUE,
+ "#weight" => 20,
+ );
+ $form['user'] = array(
+ "#type" => "textfield",
+ "#title" => t("Username"),
+ "#default_value" => @$this->dest_url['user'],
+ "#required" => TRUE,
+ "#weight" => 30,
+ );
+ $form['pass'] = array(
+ "#type" => "password",
+ "#title" => t("Password"),
+ "#default_value" => @$this->dest_url['pass'],
+ '#description' => '',
+ "#weight" => 40,
+ );
+ if (@$this->dest_url['pass']) {
+ $form['old_password'] = array(
+ "#type" => "value",
+ "#value" => @$this->dest_url['pass'],
+ );
+ $form['pass']["#description"] .= t('You do not need to enter a password unless you wish to change the currently saved password.');
+ }
+ return $form;
+ }
+
+ /**
+ * Submits the configuration form.
+ *
+ * Glue the url together and add the old password back if a new one was not
+ * specified.
+ */
+ public function edit_form_submit($form, &$form_state) {
+ $form_state['values']['pass'] = $form_state['values']['pass'] ? $form_state['values']['pass'] : $form_state['values']['old_password'];
+ $form_state['values']['location'] = $this->glue_url($form_state['values'], FALSE);
+ parent::edit_form_submit($form, $form_state);
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBase.test b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBase.test
new file mode 100644
index 0000000..6d50b6f
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBase.test
@@ -0,0 +1,301 @@
+ $password,
+ );
+ user_save($account, $edit);
+ $account->pass_raw = $password;
+
+ // Login.
+ $this->drupalLogin($account);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function verbose($message, $title = NULL) {
+ // Handle arrays, objects, etc.
+ if (!is_string($message)) {
+ $message = "
\n" . print_r($message, TRUE) . "\n
\n";
+ }
+
+ // Optional title to go before the output.
+ if (!empty($title)) {
+ $title = '
' . check_plain($title) . "
\n";
+ }
+
+ parent::verbose($title . $message);
+ }
+
+ /**
+ * Confirm that a selector has the expected items.
+ */
+ protected function assertSelectOptions($select_id, array $options, $message = '') {
+ $elements = $this
+ ->xpath('//select[@id=:id]//option', array(
+ ':id' => $select_id,
+ ));
+ $results = $this->assertEqual(count($elements), count($options), t('The same number of items were found as were requested'));
+ $this->verbose($elements);
+
+ foreach ($options as $option) {
+ $elements = $this
+ ->xpath('//select[@id=:id]//option[@value=:option]', array(
+ ':id' => $select_id,
+ ':option' => $option,
+ ));
+ $this->verbose($elements);
+ $results *= $this->assertTrue(isset($elements[0]), $message ? $message : t('Option @option for field @id is present.', array(
+ '@option' => $option,
+ '@id' => $select_id,
+ )), t('Browser'));
+ }
+
+ return $results;
+ }
+
+ /**
+ * Confirm that a specific selector does not have items selected.
+ */
+ protected function assertNoOptionsSelected($id, $message = '') {
+ $elements = $this
+ ->xpath('//select[@id=:id]//option[@selected="selected"]', array(
+ ':id' => $id,
+ ));
+ return $this
+ ->assertTrue(!isset($elements[0]), $message ? $message : t('Field @id does not have any selected items.', array(
+ '@id' => $id,
+ )), t('Browser'));
+ }
+
+ /**
+ * Work out which compressor systems are supported by PHP.
+ *
+ * @return array
+ * The list of supported compressors. Will always include the item 'none'.
+ */
+ protected function supportedCompressors() {
+ $items = array('none');
+
+ // Work out which systems are supported.
+ if (@function_exists("gzencode")) {
+ $items[] = 'gzip';
+ }
+ if (@function_exists("bzcompress")) {
+ $items[] = 'bzip';
+ }
+ if (class_exists('ZipArchive')) {
+ $items[] = 'zip';
+ }
+
+ return $items;
+ }
+
+ /**
+ * Get a list of the files in a specific destination.
+ *
+ * @param string $destination_id
+ * The ID of the destination to check. Defaults to the manual file path.
+ *
+ * @return array
+ * The backup files found in the requested backup destination.
+ */
+ protected function listBackupFiles($destination_id = 'manual') {
+ require_once dirname(__FILE__) . '/../includes/destinations.inc';
+
+ $items = array();
+
+ // Load the destination object.
+ $destination = backup_migrate_get_destination($destination_id);
+ if (!empty($destination)) {
+ $items = $destination->list_files();
+ }
+
+ return $items;
+ }
+
+ /**
+ * Run a specific backup.
+ *
+ * @param string $destination_id
+ * The ID of the destination to check. Defaults to the manual file path.
+ * @param string $source_id
+ * The ID of the source to check. Defaults to the database.
+ */
+ protected function runBackup($destination_id = 'manual', $source_id = 'db') {
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH);
+ $this->assertResponse(200);
+ $edit = array(
+ 'destination_id' => $destination_id,
+ 'source_id' => $source_id,
+ );
+ $this->drupalPost(NULL, $edit, 'Backup now');
+ $this->assertResponse(200);
+ // Confirm the response is as expected. This is split up into separate
+ // pieces because it'd be more effort than is necessary right now to confirm
+ // what the exact filename is.
+ if ($source_id === 'db') {
+ $this->assertText('Default Database backed up successfully');
+ }
+ else {
+ $this->assertText(' backed up successfully');
+ }
+ $this->assertText('in destination');
+ if ($source_id === 'db') {
+ $this->assertLink('download');
+ $this->assertLink('restore');
+ $this->assertLink('delete');
+ }
+ }
+
+ /**
+ * Delete all of the files in a specific backup destination.
+ *
+ * @param string $destination_id
+ * The ID of the destination to check. Defaults to the manual file path.
+ */
+ protected function deleteBackups($destination_id = 'manual') {
+ $destination = backup_migrate_get_destination($destination_id);
+ $files = $this->listBackupFiles($destination_id);
+ if (!empty($files)) {
+ foreach ($files as $file_id => $file) {
+ $destination->delete_file($file_id);
+ }
+ }
+ }
+
+ /**
+ * Work out whether a backup filename includes a timestamp.
+ *
+ * @param object $file
+ * The backup file to examine.
+ *
+ * @return mixed
+ * Returns 1 if found, 0 if not found, FALSE if an error occurs.
+ */
+ protected function fileHasTimestamp($file) {
+ require_once dirname(__FILE__) . '/../includes/files.inc';
+
+ // Get the default filename, this is used later.
+ $default_filename = _backup_migrate_default_filename();
+ $ext = implode('.', $file->ext);
+ $pattern = "/{$default_filename}-(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d)-(\d\d)-(\d\d).{$ext}/";
+
+ return preg_match($pattern, $file->file_info['filename']);
+ }
+
+ /**
+ * Confirm that a backup filename includes a timestamp.
+ *
+ * @param object $file
+ * The backup file to examine.
+ *
+ * @return bool
+ * Indicates whether the file includes a timestamp.
+ */
+ protected function assertFileTimestamp($file) {
+ return $this->assertTrue($this->fileHasTimestamp($file));
+ }
+
+ /**
+ * Confirm that a backup filename does not include a timestamp.
+ *
+ * @param object $file
+ * The backup file to examine.
+ *
+ * @return bool
+ * Indicates whether the file does not include a timestamp.
+ */
+ protected function assertNoFileTimestamp($file) {
+ return !$this->assertFalse($this->fileHasTimestamp($file));
+ }
+
+ /**
+ * Get a profile.
+ *
+ * @param string $profile_id
+ * The name of the profile to load. Defaults to 'default'.
+ *
+ * @return object
+ * The profile object.
+ */
+ protected function getProfile($profile_id = 'default') {
+ require_once dirname(__FILE__) . '/../includes/profiles.inc';
+
+ return backup_migrate_get_profile($profile_id);
+ }
+
+ /**
+ * Confirm the most recently sent e-mail(s) contain the expected string.
+ *
+ * @param string $field_name
+ * Name of field or message property to assert: subject, body, id, etc.
+ * @param string $string
+ * String to search for.
+ * @param int $expected
+ * Number of times $string should occur in the field.
+ * @param int $email_depth
+ * Number of emails to search for string, starting with most recent.
+ *
+ * @return bool
+ * TRUE on pass, FALSE on fail.
+ *
+ * @see DrupalWebTestCase::assertMailString()
+ */
+ protected function assertMailStringCount($field_name, $string, $expected, $email_depth) {
+ $mails = $this->drupalGetMails();
+ $number_of_mails = count($mails);
+ $string_count = 0;
+
+ for ($i = $number_of_mails - 1; $i >= $number_of_mails - $email_depth && $i >= 0; $i--) {
+ $mail = $mails[$i];
+
+ // Normalize whitespace, as it isn't eacy to know what the mail system
+ // might have done. Any run of whitespace becomes a single space.
+ $normalized_mail = preg_replace('/\\s+/', ' ', $mail[$field_name]);
+ $normalized_string = preg_replace('/\\s+/', ' ', $string);
+ $string_count += substr_count($normalized_mail, $normalized_string);
+ }
+
+ $mail_count = min($number_of_mails, $email_depth);
+ $message = format_plural($mail_count, 'Text "@needle" was found @stringcount times in field "@field" of the most recent email message.', 'Text "@needle" was found @stringcount times in field "@field" of the @mailcount most recent email messages.', array(
+ '@needle' => $string,
+ '@stringcount' => $string_count,
+ '@field' => $field_name,
+ '@mailcount' => $mail_count,
+ ));
+
+ return $this->assertTrue(($string_count === $expected), $message);
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBasics.test b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBasics.test
new file mode 100644
index 0000000..c222418
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestBasics.test
@@ -0,0 +1,276 @@
+ 'Basic tests',
+ 'description' => 'Run through basic scenarios and functionality.',
+ 'group' => 'backup_migrate',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp(array $modules = array()) {
+ parent::setUp($modules);
+
+ // Log in as user 1, so that permissions are irrelevant.
+ $this->loginUser1();
+ }
+
+ /**
+ * Verify the main page has the expected form, then run a basic backup.
+ */
+ public function testQuickBackup() {
+ // Ensure that the private file system is working correctly.
+ $this->drupalGet('admin/config/media/file-system');
+ $this->assertResponse(200);
+ $edit = array();
+ $this->drupalPost(NULL, $edit, 'Save configuration');
+ $this->assertResponse(200);
+ $this->assertText('The configuration options have been saved.');
+
+ // Load the main B&M page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH);
+ $this->assertResponse(200);
+
+ // @todo Confirm each of the tabs are present.
+ // @todo Confirm each of the local tasks are present.
+ // Confirm the form has the expected fields.
+ $this->assertFieldByName('source_id');
+ $this->assertFieldByName('destination_id');
+ $this->assertFieldByName('profile_id');
+ $this->assertFieldByName('copy');
+ $this->assertFieldByName('copy_destination_id');
+ $this->assertFieldByName('description_enabled');
+ // This item should not have a value "selected", it just defaults to the
+ // first item being the active item.
+ $items = array('db', 'files', 'archive');
+ $this->assertSelectOptions('edit-source-id', $items);
+ $this->assertNoOptionsSelected('edit-source-id');
+ // This item should have a value "selected", not just the first item. Note:
+ // if the 'manual' backup option isn't available then the private directory
+ // path is not set correctly.
+ $items = array('manual', 'download');
+ $this->assertSelectOptions('edit-destination-id', $items);
+ $this->assertOptionSelected('edit-destination-id', 'download');
+ // This item should not have a value "selected", it just defaults to the
+ // first item being the active item.
+ $items = array('default');
+ $this->assertSelectOptions('edit-profile-id', $items);
+ $this->assertNoOptionsSelected('edit-profile-id');
+ // This item should not have a value "selected", it just defaults to the
+ // first item being the active item.
+ $items = array('manual', 'download');
+ $this->assertSelectOptions('edit-copy-destination-id', $items);
+ $this->assertNoOptionsSelected('edit-copy-destination-id');
+
+ // Generate a backup and confirm it was created correctly.
+ $edit = array(
+ 'destination_id' => 'manual',
+ );
+ $this->drupalPost(NULL, $edit, 'Backup now');
+ $this->assertResponse(200);
+ // Confirm the response is as expected. This is split up into separate
+ // pieces because it'd be more effort than is necessary right now to confirm
+ // what the exact filename is.
+ $this->assertText('Default Database backed up successfully');
+ $this->assertText('in destination Manual Backups Directory');
+ $this->assertLink('download');
+ $this->assertLink('restore');
+ $this->assertLink('delete');
+
+ // Try requesting the backup file.
+ $xpath = $this
+ ->xpath('//a[normalize-space(text())=:label]', array(
+ ':label' => 'download',
+ ));
+ $this->verbose($xpath);
+ $this->assertTrue(isset($xpath[0]['href']));
+ $this->assertNotNull($xpath[0]['href']);
+ // @todo This doesn't work on drupalci, so work out how to fix it.
+ // $this->drupalGet($xpath[0]['href']);
+ $this->assertResponse(200);
+ }
+
+ /**
+ * Test the custom validators.
+ */
+ public function testFieldValidators() {
+ // Need this file loaded for the custom validators.
+ module_load_include('advanced_settings.inc', 'backup_migrate');
+
+ $field = 'mock_field';
+
+ $element = array(
+ '#value' => 'a',
+ '#title' => '',
+ '#parents' => array($field),
+ );
+
+ // Test the memory limit validator.
+ $element['#title'] = 'Mock Field (Memory Limit)';
+ $test_values = array(
+ // Value to be tested => validity.
+ // Special meaning: no limit.
+ '-1' => TRUE,
+ '50' => TRUE,
+ // 5 megabytes.
+ '5M' => TRUE,
+ // 500 kilobytes.
+ '.5M' => TRUE,
+ // 5 gigabytes.
+ '5G' => TRUE,
+ '.5G' => TRUE,
+ '1.5G' => TRUE,
+ '0' => TRUE,
+ 'a' => FALSE,
+ '-2' => FALSE,
+ // You cannot have half a byte.
+ '1.5' => FALSE,
+ '5T' => FALSE,
+ '5 G' => FALSE,
+ '.5.5G' => FALSE,
+ );
+ foreach ($test_values as $value => $valid) {
+ $this->assertValidFieldValue('backup_migrate_memory_limit_validate', $element, $value, $valid, 'memory limit value');
+ }
+
+ // Test the positive non-zero integer validator.
+ $element['#title'] = 'Mock Field (Unsigned Integer)';
+ $test_values = array(
+ '0' => TRUE,
+ '1' => TRUE,
+ '10000' => TRUE,
+ // NaN.
+ 'a' => FALSE,
+ // Not an integer.
+ '.5' => FALSE,
+ // Not positive.
+ '-1' => FALSE,
+ // Largest integer.
+ // @code
+ // PHP_INT_MAX => TRUE,
+ // @endcode
+ // Resolves to a decimal.
+ // @code
+ // (PHP_INT_MAX + 1) => FALSE,
+ // @endcode
+ );
+ foreach ($test_values as $value => $valid) {
+ $this->assertValidFieldValue('backup_migrate_unsigned_integer_validate', $element, $value, $valid, 'zero or a positive integer');
+ }
+
+ // Test the validator for decimals ranging from 0 to 1.
+ $element['#title'] = 'Mock Field (Decimal between 0 and 1)';
+ $test_values = array(
+ '0' => TRUE,
+ '1' => TRUE,
+ '0.1' => TRUE,
+ '.1' => TRUE,
+ '1.1' => FALSE,
+ '-1' => FALSE,
+ '-1.1' => FALSE,
+ '2' => FALSE,
+ 'a' => FALSE,
+ );
+ foreach ($test_values as $value => $valid) {
+ $this->assertValidFieldValue('backup_migrate_fraction_validate', $element, $value, $valid, 'decimal between 0 and 1');
+ }
+ }
+
+ /**
+ * Asserts that the content of a field passes its associated validation.
+ *
+ * @param string $validator
+ * Drupal validator function callback.
+ * @param array $element
+ * Input for error setter.
+ * @param string $value
+ * Field value to be tested.
+ * @param bool $value_is_valid
+ * Expected outcome.
+ * @param string $type
+ * Description of value sub-type.
+ */
+ protected function assertValidFieldValue($validator, array $element, $value, $value_is_valid, $type) {
+ $form = array();
+ $form_state = array();
+ $field = 'mock_field';
+ $element['#value'] = $value;
+
+ form_clear_error();
+ call_user_func_array($validator, array($element, &$form_state, $form));
+ $errors = form_get_errors();
+
+ if ($value_is_valid) {
+ $args = array(
+ '%value' => $value,
+ '%type' => $type,
+ );
+ $msg = t('%value is a valid %type.', $args);
+ $result = $this->assertTrue(empty($errors[$field]), $msg);
+ }
+ else {
+ $args = array(
+ '%value' => $value,
+ '%type' => $type,
+ '%msg' => strip_tags($errors[$field]),
+ );
+ $msg = t('%value is not a valid %type. Error message: "%msg".', $args);
+ $result = $this->assertFalse(empty($errors[$field]), $msg);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Confirm backup_migrate_to_bytes() works.
+ */
+ public function testBackupMigrateToBytes() {
+ // PHP manual:
+ // http://php.net/manual/en/ini.core.php#ini.memory-limit
+ // '-1' is a reserved value meaning 'no limit'.
+ $input = '-1';
+ $expected = -1;
+ $this->assertEqual(backup_migrate_to_bytes($input), $expected);
+
+ // PHP would halt before this, but let us test anyway.
+ $input = 'nonsense';
+ $expected = 0;
+ $this->assertEqual(backup_migrate_to_bytes($input), $expected);
+
+ // This is 123 bytes, but there is a bug in B&M that turns
+ // this into 12.5 megabytes.
+ $input = '123';
+ $expected = 12582912;
+ $this->assertEqual(backup_migrate_to_bytes($input), $expected);
+
+ // 45 megabytes.
+ $input = '45M';
+ $expected = 47185920;
+ $this->assertEqual(backup_migrate_to_bytes($input), $expected);
+
+ // 8 gigabytes.
+ $input = '8G';
+ $expected = 8589934592;
+ $this->assertEqual(backup_migrate_to_bytes($input), $expected);
+ }
+
+}
+
+// @todo Test permissions.
+// @todo Test admin forms.
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestCtools.test b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestCtools.test
new file mode 100644
index 0000000..7bccdc1
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestCtools.test
@@ -0,0 +1,104 @@
+ 'CTools tests',
+ 'description' => 'Test integration with the CTools module.',
+ 'group' => 'backup_migrate',
+ 'dependencies' => array('ctools'),
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp(array $modules = array()) {
+ $modules[] = 'bm_test';
+ $modules[] = 'ctools';
+
+ parent::setUp($modules);
+
+ // Log in as user 1, so that permissions are irrelevant.
+ $this->loginUser1();
+ }
+
+ /**
+ * Confirm automated settings exist.
+ */
+ public function testSettingsPage() {
+ // Load the B&M Settings page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings');
+ $this->assertResponse(200);
+
+ // Does the mock schedule exist?
+ $this->assertText('Mock weekly database schedule');
+
+ // Does the mock source exist?
+ $this->assertText('Mock file directory');
+
+ // Does the mock destination exist?
+ $this->assertText('Mock e-mail destination');
+
+ // Load the B&M Schedule page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/schedule');
+ $this->assertResponse(200);
+
+ // Does the mock schedule exist?
+ $this->assertText('Mock weekly database schedule');
+
+ // Does the mock schedule contain the appropriate values?
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/schedule/edit/mock_db_weekly');
+ $this->assertResponse(200);
+
+ $fields = _bm_test_get_mock_schedule();
+
+ // @todo Deal with periods, but now I need sleep.
+ // See the get_frequency_period() method in includes/schedules.inc.
+ unset($fields['period']);
+
+ // Test the destination selection with its own assertion.
+ $this->assertOptionSelected('edit-destination-id', $fields['destination_id']);
+ unset($fields['destination_id']);
+
+ foreach ($fields as $key => $field) {
+ $id = 'edit-' . str_replace('_', '-', $key);
+ $this->assertFieldById($id, $field, 'Found field by id "' . $id . '" and value "' . $field . '".');
+ }
+
+ // Does the mock source contain the appropriate values?
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings/source/edit/mock_file_directory');
+ $this->assertResponse(200);
+
+ $fields = _bm_test_get_mock_source();
+ unset($fields['subtype']);
+ foreach ($fields as $key => $field) {
+ $id = 'edit-' . str_replace('_', '-', $key);
+ $this->assertFieldById($id, $field, 'Found field by id "' . $id . '" and value "' . $field . '".');
+ }
+
+ // Does the mock destination contain the appropriate values?
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/edit/mock_email');
+ $this->assertResponse(200);
+
+ $fields = _bm_test_get_mock_destination();
+ unset($fields['subtype']);
+ foreach ($fields as $key => $field) {
+ $id = 'edit-' . str_replace('_', '-', $key);
+ $this->assertFieldById($id, $field, 'Found field by id "' . $id . '" and value "' . $field . '".');
+ }
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestEmail.test b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestEmail.test
new file mode 100644
index 0000000..9c2241e
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestEmail.test
@@ -0,0 +1,207 @@
+ 'Email handling',
+ 'description' => 'Confirm email handling works as intended.',
+ 'group' => 'backup_migrate',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp(array $modules = array()) {
+ parent::setUp($modules);
+
+ // Log in as user 1, so that permissions are irrelevant.
+ $this->loginUser1();
+ }
+
+ /**
+ * Confirm the whole email process.
+ */
+ public function testAddEmailDestination() {
+ // See if we can add a destination.
+ // Load the email destination Add page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add/email');
+ $this->assertResponse(200);
+
+ // Verify all of the expected fields exist.
+ $this->assertFieldByName('name');
+ $this->assertFieldByName('name', 'Untitled Destination');
+ $this->assertFieldByName('machine_name');
+ $this->assertFieldByName('location');
+
+ // Set up test values.
+ $test_source = strtolower($this->randomName(16));
+ $address = strtolower($this->randomName(10)) . '@example.com';
+ $test_destination = strtolower($this->randomName(16));
+
+ // Submit e-mail destination form with invalid values.
+ $this->submitDestinationEmail('', $test_destination, $address);
+ $this->assertText(t('Destination name field is required.'), 'Name required.');
+
+ $this->submitDestinationEmail($this->randomString(16), '', $address);
+ $this->assertText(t('Machine-readable name field is required.'), 'Machine name required.');
+
+ $this->submitDestinationEmail($this->randomString(16), $test_destination, '');
+ $this->assertText(t('Email Address field is required.'), 'E-mail required.');
+
+ // Step 1, set-up.
+ // Create a test destination.
+ $this->submitDestinationEmail($this->randomString(16), $test_destination, $address);
+ $this->assertText(t('Your destination was saved'));
+
+ // Create a test source.
+ // @todo Test the source add form.
+ // @todo Maybe add a note somewhere about how we are using a small
+ // source on purpose, so as to not break the testing system.
+ $this->submitSourceFiles($this->randomString(16), $test_source, drupal_get_path('module', 'backup_migrate') . '/tests/files/');
+ $this->assertText(t('Your source was saved'));
+
+ // Run a manual back-up so we have a file to compare against.
+ $this->runBackup('manual', $test_source);
+
+ $files = $this->listBackupFiles();
+ $key = key($files);
+
+ // Confirm the back-up file exists.
+ $this->assertNotEqual($key, NULL, 'A backup file was found.');
+
+ $file = $files[$key];
+
+ // Copied from destinations.email.inc to build a compatible parameter.
+ $attachment = new stdClass();
+ $attachment->filename = $file->name;
+ $attachment->path = $file->path;
+
+ // Step 2, e-mail generated through the Quick Backup form.
+ // Run a backup per e-mail.
+ $this->runBackup($test_destination, $test_source);
+
+ // Confirm that an e-mail was sent.
+ $captured_emails = $this->drupalGetMails(array('id' => 'backup_migrate_destination_mail', 'to' => $address));
+ $this->verboseEmail();
+ $this->assertEqual(count($captured_emails), 1, 'A back-up was mailed.');
+
+ // Does the attachment occur in the captured e-mail?
+ // Note that the e-mail from Step 2 is tested against the back-up file from
+ // Step 1.
+ $file_data = fread(fopen($attachment->path, "r"), filesize($attachment->path));
+ $encoded_file_data = chunk_split(base64_encode($file_data), 70, "\r\n");
+ $this->assertMailString('body', $encoded_file_data, 1);
+
+ // Step 3, e-mail generated through the main helper function.
+ // Make sure the new $address is never the same as the old one.
+ $address = strtolower($this->randomName(1 + strlen($address))) . '@example.com';
+
+ _backup_migrate_destination_email_mail_backup($attachment, $address);
+
+ // Confirm that an e-mail is sent.
+ $captured_emails = $this->drupalGetMails(array('id' => 'backup_migrate_destination_mail', 'to' => $address));
+ $this->verboseEmail();
+ $this->assertEqual(count($captured_emails), 1, 'A back-up was mailed.');
+
+ // Check if the Subject field contains the filename.
+ $this->assertMailString('subject', $attachment->filename, 1);
+
+ // Check if the body contains the filename.
+ $this->assertMailString('body', $attachment->filename, 1);
+
+ // Step 4, (partial) e-mail generated through a mime_mail() object.
+ // Build an e-mail.
+ $test_mail = new mime_mail();
+ $boundary = "b" . md5(uniqid(time()));
+
+ // Make sure the new $address is never the same as the old one.
+ $address = strtolower($this->randomName(1 + strlen($address))) . '@example.com';
+
+ $attach = fread(fopen($attachment->path, "r"), filesize($attachment->path));
+ $test_mail->add_attachment($attach, $attachment->filename, "application/octet-stream");
+
+ $message = $test_mail->build_multipart($boundary);
+
+ $params = array(
+ 'body' => $message,
+ 'subject' => 'test',
+ 'headers' => array(
+ 'MIME-Version' => "1.0",
+ 'Content-Type' => "multipart/mixed; boundary=\"$boundary\"",
+ ),
+ );
+
+ drupal_mail('backup_migrate', 'destination_mail', $address, '', $params);
+ $captured_emails = $this->drupalGetMails(array('id' => 'backup_migrate_destination_mail', 'to' => $address));
+ $this->verboseEmail();
+
+ // Confirm that an e-mail was sent.
+ $this->assertEqual(count($captured_emails), 1, 'A back-up was mailed.');
+
+ // Does the boundary occur in the captured e-mail?
+ $this->assertMailString('body', '--' . $boundary, 1);
+
+ // How many boundaries?
+ $expected = count($test_mail->parts) + 1;
+ $this->assertMailStringCount('body', '--' . $boundary, $expected, 1);
+
+ // Cleanup - purge all backups.
+ $this->deleteBackups();
+ }
+
+ /**
+ * Submits the destination form for E-mails.
+ *
+ * @param string $name
+ * The name of the destination.
+ * @param string $machine_name
+ * The machine name of the destination.
+ * @param string $mail
+ * The e-mail address of the destination.
+ */
+ public function submitDestinationEmail($name, $machine_name, $mail) {
+ $this->drupalGet('admin/config/system/backup_migrate/settings/destination/add/email');
+ $this->assertResponse(200);
+ $edit = array();
+ $edit['name'] = $name;
+ $edit['machine_name'] = $machine_name;
+ $edit['location'] = $mail;
+ $this->drupalPost(NULL, $edit, t('Save destination'));
+ $this->assertResponse(200);
+ }
+
+ /**
+ * Submits the source form for Files.
+ *
+ * @param string $name
+ * The name of the source.
+ * @param string $machine_name
+ * The machine name of the source.
+ * @param string $path
+ * The path of the source.
+ */
+ public function submitSourceFiles($name, $machine_name, $path) {
+ $this->drupalGet('admin/config/system/backup_migrate/settings/source/add/filesource');
+ $this->assertResponse(200);
+ $edit = array();
+ $edit['name'] = $name;
+ $edit['machine_name'] = $machine_name;
+ $edit['location'] = $path;
+ $this->drupalPost(NULL, $edit, t('Save source'));
+ $this->assertResponse(200);
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestProfiles.test b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestProfiles.test
new file mode 100644
index 0000000..7a80697
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestProfiles.test
@@ -0,0 +1,170 @@
+ 'Profiles tests',
+ 'description' => 'Run through basic scenarios and functionality.',
+ 'group' => 'backup_migrate',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp(array $modules = array()) {
+ parent::setUp($modules);
+
+ // Log in as user 1, so that permissions are irrelevant.
+ $this->loginUser1();
+ }
+
+ /**
+ * Verify the profile page has the expected functionality available.
+ */
+ public function testProfilePage() {
+ // Load the main B&M page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings');
+ $this->assertResponse(200);
+
+ // Confirm the page has the expected settings details.
+ $this->assertText('Settings Profiles');
+ $this->assertText('Default Settings');
+ $this->assertLink('Create a new settings profile');
+ }
+
+ /**
+ * Confirm adding a new backup process works.
+ */
+ public function testAddDefaultProfile() {
+ require_once dirname(__FILE__) . '/../includes/files.inc';
+ require_once dirname(__FILE__) . '/../includes/profiles.inc';
+
+ // Load the main B&M page.
+ $this->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings/profile/add');
+ $this->assertResponse(200);
+
+ $filename = _backup_migrate_default_filename();
+ $defaults = _backup_migrate_profile_default_profile();
+
+ // Verify all of the expected fields exist.
+ $this->assertFieldByName('name');
+ $this->assertFieldByName('name', 'Untitled Profile');
+ $this->assertFieldByName('machine_name');
+ $this->assertFieldByName('filename');
+ $this->assertFieldByName('filename', $filename);
+ // @todo Confirm all of the expected options are present.
+ $this->assertFieldByName('append_timestamp');
+ $this->assertFieldByName('timestamp_format');
+ $this->assertFieldByName('timestamp_format', $defaults['timestamp_format']);
+ $this->assertFieldByName('filters[compression]');
+ $items = $this->supportedCompressors();
+ $this->assertSelectOptions('edit-filters-compression', $items);
+ $this->assertOptionSelected('edit-filters-compression', 'gzip');
+ $this->assertFieldByName('filters[sources][db][exclude_tables][]');
+ $this->assertFieldByName('filters[sources][db][nodata_tables][]');
+ $this->assertFieldByName('filters[sources][db][utils_lock_tables]');
+ $this->assertFieldByName('filters[sources][files][exclude_filepaths]');
+ $this->assertFieldByName('filters[sources][archive][exclude_filepaths]');
+ $this->assertFieldByName('filters[utils_site_offline]');
+ $this->assertFieldByName('filters[utils_site_offline_message]');
+ $this->assertFieldByName('filters[utils_description]');
+ $this->assertFieldByName('filters[use_cli]');
+ $this->assertFieldByName('filters[ignore_errors]');
+ $this->assertFieldByName('filters[notify_success_enable]');
+ $this->assertFieldByName('filters[notify_success_email]');
+ $this->assertFieldByName('filters[notify_failure_enable]');
+ $this->assertFieldByName('filters[notify_failure_email]');
+ }
+
+ /**
+ * Confirm the backup filename processes work as expected.
+ */
+ public function testFilenameOptions() {
+ // Load the profile. This will be interacted with directly because otherwise
+ // the number of form fields will likely make it impossible to execute
+ // properly due to the max_input_vars setting defaulting to 1000.
+ $profile = $this->getProfile();
+
+ // Run a backup.
+ $this->runBackup();
+
+ // Confirm that there is only one file and it has a timestamp of some sort.
+ $files1 = $this->listBackupFiles();
+ $this->verbose($files1);
+ $this->assertTrue(count($files1) === 1, 'One backup file was found.');
+ $this->assertFileTimestamp(array_shift($files1));
+
+ // Run another backup.
+ $this->runBackup();
+
+ // Confirm that there are two backup files.
+ $files1b = $this->listBackupFiles();
+ $this->verbose($files1b);
+ $this->assertTrue(count($files1b) === 2, 'Two backup files were found.');
+
+ // Cleanup before the next test - purge existing backups.
+ $this->deleteBackups();
+
+ // Change settings to "create separate backups".
+ $profile->append_timestamp = 0;
+ $profile->save();
+
+ // Run a backup.
+ $this->runBackup();
+
+ // Confirm that separate files are retained.
+ $files2 = $this->listBackupFiles();
+ $this->verbose($files2);
+ $this->assertTrue(count($files2) === 1, 'One backup file was found.');
+ $this->assertNoFileTimestamp(array_shift($files2));
+
+ // Run another backup.
+ $this->runBackup();
+
+ // Confirm that separate files are retained.
+ $files2b = $this->listBackupFiles();
+ $this->verbose($files2b);
+ $this->assertTrue(count($files2b) === 2, 'Two backup files were found.');
+
+ // Cleanup before the next test - purge existing backups.
+ $this->deleteBackups();
+
+ // Change settings to "overwrite".
+ $profile->append_timestamp = 2;
+ $profile->save();
+
+ // Run a backup.
+ $this->runBackup();
+
+ // Confirm that a new file was created.
+ $files3 = $this->listBackupFiles();
+ $this->verbose($files3);
+ $this->assertTrue(count($files3) === 1, 'One backup file was found.');
+ $this->assertNoFileTimestamp(array_shift($files3));
+
+ // Run the backup again.
+ $this->runBackup();
+
+ // Confirm that a new file was not created.
+ $files3b = $this->listBackupFiles();
+ $this->verbose($files3b);
+ $this->assertTrue(count($files3b) === 1, 'One backup file was found.');
+
+ // Cleanup - purge all backups.
+ $this->deleteBackups();
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestUpdate7310.test b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestUpdate7310.test
new file mode 100644
index 0000000..5496045
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/BmTestUpdate7310.test
@@ -0,0 +1,141 @@
+ 'Update 7310',
+ 'description' => 'Confirm update 7310 works as intended.',
+ 'group' => 'backup_migrate',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp(array $modules = array()) {
+ parent::setUp($modules);
+
+ // Log in as user 1, so that permissions are irrelevant.
+ $this->loginUser1();
+ }
+
+ /**
+ * Test update 7310.
+ */
+ public function testUpdate7310() {
+ require_once dirname(__FILE__) . '/../includes/destinations.inc';
+ require_once dirname(__FILE__) . '/../includes/schedules.inc';
+
+ $this->assertEqual(function_exists('backup_migrate_update_7310'), TRUE, 'Update 7310 exists.');
+
+ // First test what happens when there are no e-mail destinations.
+ // Execute the update function.
+ $result = backup_migrate_update_7310();
+
+ // We should be getting a notice as a result.
+ $message = "The following notice was displayed: "$result"";
+ $expected = 'No destinations were affected by this change.';
+ $this->assertEqual($expected, $result, $message);
+
+ // Next, add e-mail destinations and see what happens then.
+ // Create two mock e-mail destinations.
+ $address = strtolower($this->randomName(10)) . '@example.com';
+ $email_destination_id = strtolower($this->randomName(16));
+ $this->submitDestinationEmail('Mock e-mail destination', $email_destination_id, $address);
+ $address = strtolower($this->randomName(10)) . '@example.com';
+ $email_destination_id = strtolower($this->randomName(16));
+ $this->submitDestinationEmail('Mock e-mail destination', $email_destination_id, $address);
+ $this->assertText(t('Your destination was saved'));
+
+ // Create mock schedules with different types of destinations.
+ $mock_schedule_1 = $this->randomName(10);
+ $mock_schedule_2 = $this->randomName(10);
+ $mock_schedule_3 = $this->randomName(10);
+ $this->submitSchedule($mock_schedule_1, 'test_1', 'scheduled', '');
+ $this->assertText(t('Your schedule was saved'));
+ $this->submitSchedule($mock_schedule_2, 'test_2', $email_destination_id, '');
+ $this->assertText(t('Your schedule was saved'));
+ $this->submitSchedule($mock_schedule_3, 'test_3', 'scheduled', $email_destination_id);
+ $this->assertText(t('Your schedule was saved'));
+
+ $destinations = db_select('backup_migrate_destinations', 'bmd')->fields('bmd', array('machine_name'))->condition('subtype', 'email', '=')->execute()->fetchAllAssoc('machine_name', PDO::FETCH_ASSOC);
+ $destinations = array_keys($destinations);
+
+ // Execute the update function.
+ $result = backup_migrate_update_7310();
+
+ // We should be getting a notice as a result.
+ $expected = htmlspecialchars("Schedules that back up to e-mail destinations have been disabled. Check that you are using the correct e-mail addresses, then re-enable manually. The following schedules have been disabled:
{$mock_schedule_2}
{$mock_schedule_3}
");
+ $message = "The following notice was displayed: "$result".";
+ $this->assertEqual($expected, $result, $message);
+
+ $schedules_query = db_select('backup_migrate_schedules', 'bms')->fields('bms', array('machine_name', 'enabled'));
+ $schedules = $schedules_query->execute()->fetchAllAssoc('machine_name', PDO::FETCH_ASSOC);
+
+ // Check that the correct values have changed.
+ $this->assertEqual($schedules['test_1']['enabled'], 1, 'The file back-up schedule remained enabled.');
+ $this->assertEqual($schedules['test_2']['enabled'], 0, 'The e-mail back-up schedule was disabled.');
+ $this->assertEqual($schedules['test_2']['enabled'], 0, 'The file back-up schedule with an e-mail copy was disabled.');
+ }
+
+ /**
+ * Submits the destination form for E-mails.
+ *
+ * @param string $name
+ * The name of the destination.
+ * @param string $machine_name
+ * The machine name of the destination.
+ * @param string $mail
+ * The e-mail address of the destination.
+ */
+ public function submitDestinationEmail($name, $machine_name, $mail) {
+ $this->drupalGet('admin/config/system/backup_migrate/settings/destination/add/email');
+ $this->assertResponse(200);
+ $edit = array();
+ $edit['name'] = $name;
+ $edit['machine_name'] = $machine_name;
+ $edit['location'] = $mail;
+ $this->drupalPost(NULL, $edit, t('Save destination'));
+ $this->assertResponse(200);
+ }
+
+ /**
+ * Submits the schedule form.
+ *
+ * @param string $name
+ * The name of the destination.
+ * @param string $machine_name
+ * The machine name of the destination.
+ * @param string $destination_id
+ * The destination ID to use.
+ * @param string $copy_destination_id
+ * The destination ID to use for an optional copy.
+ */
+ public function submitSchedule($name, $machine_name, $destination_id, $copy_destination_id = NULL) {
+ $this->drupalGet('admin/config/system/backup_migrate/schedule/add');
+ $this->assertResponse(200);
+ $edit = array();
+ $edit['name'] = $name;
+ $edit['machine_name'] = $machine_name;
+ $edit['destination_id'] = $destination_id;
+ if (!empty($copy_destination_id)) {
+ $edit['copy'] = TRUE;
+ $edit['copy_destination_id'] = $copy_destination_id;
+ }
+ $this->drupalPost(NULL, $edit, t('Save schedule'));
+ $this->assertResponse(200);
+ }
+
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/bm_test.info b/sites/all/modules/contrib/admin/backup_migrate/tests/bm_test.info
new file mode 100644
index 0000000..0fc6938
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/bm_test.info
@@ -0,0 +1,13 @@
+name = "Backup and Migrate Mock Module"
+description = "Mock module for testing the Backup and Migrate module."
+package = Other
+core = 7.x
+hidden = TRUE
+dependencies[] = simpletest
+dependencies[] = backup_migrate
+
+; Information added by Drupal.org packaging script on 2020-07-15
+version = "7.x-3.9"
+core = "7.x"
+project = "backup_migrate"
+datestamp = "1594807678"
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/bm_test.module b/sites/all/modules/contrib/admin/backup_migrate/tests/bm_test.module
new file mode 100644
index 0000000..c051203
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/bm_test.module
@@ -0,0 +1,121 @@
+ "1");
+ }
+}
+
+/**
+ * Implements hook_exportables_backup_migrate_schedules().
+ */
+function bm_test_exportables_backup_migrate_schedules() {
+ $export = array();
+ $item = new BmTestItem();
+ $mock_record = _bm_test_get_mock_schedule();
+ foreach ($mock_record as $key => $field) {
+ $item->$key = $field;
+ }
+ $export['mock_db_weekly'] = $item;
+ return $export;
+}
+
+/**
+ * Helper function to create a mock schedule.
+ */
+function _bm_test_get_mock_schedule() {
+ return array(
+ 'machine_name' => 'mock_db_weekly',
+ 'name' => 'Mock weekly database schedule',
+ 'source_id' => 'db',
+ 'destination_id' => 'scheduled',
+ 'copy_destination_id' => '',
+ 'profile_id' => 'default',
+ 'keep' => 4,
+ 'period' => 604800,
+ 'enabled' => TRUE,
+ 'cron' => 'builtin',
+ 'cron_schedule' => '0 4 * * *',
+ );
+}
+
+/**
+ * Implements hook_exportables_backup_migrate_sources().
+ */
+function bm_test_exportables_backup_migrate_sources() {
+ $export = array();
+ $item = new BmTestItem();
+ $mock_record = _bm_test_get_mock_source();
+ foreach ($mock_record as $key => $field) {
+ $item->$key = $field;
+ }
+ $export['mock_file_directory'] = $item;
+ return $export;
+}
+
+/**
+ * Helper function to create a mock source.
+ */
+function _bm_test_get_mock_source() {
+ return array(
+ 'machine_name' => 'mock_file_directory',
+ 'name' => 'Mock file directory',
+ 'location' => '/dev/null',
+ 'subtype' => 'filesource',
+ );
+}
+
+/**
+ * Implements hook_exportables_backup_migrate_destinations().
+ */
+function bm_test_exportables_backup_migrate_destinations() {
+ $export = array();
+ $item = new BmTestItem();
+ $mock_record = _bm_test_get_mock_destination();
+ foreach ($mock_record as $key => $field) {
+ $item->$key = $field;
+ }
+ $export['mock_email'] = $item;
+ return $export;
+}
+
+/**
+ * Helper function to create a mock destination.
+ */
+function _bm_test_get_mock_destination() {
+ return array(
+ 'machine_name' => 'mock_email',
+ 'name' => 'Mock e-mail destination',
+ 'location' => 'test@example.com',
+ 'subtype' => 'email',
+ );
+}
diff --git a/sites/all/modules/contrib/admin/backup_migrate/tests/files/test.txt b/sites/all/modules/contrib/admin/backup_migrate/tests/files/test.txt
new file mode 100644
index 0000000..8c01d18
--- /dev/null
+++ b/sites/all/modules/contrib/admin/backup_migrate/tests/files/test.txt
@@ -0,0 +1,7 @@
+Nay, Traveller! rest. This lonely yew-tree stands
+Far from all human dwelling: what if here
+No sparkling rivulet spread the verdant herb;
+What if these barren boughs the bee not loves;
+Yet, if the wind breathe soft, the curling waves,
+That break against the shore, shall lull thy mind
+By one soft impulse saved from vacancy.
diff --git a/sites/all/modules/contrib/admin/google_analytics/README.txt b/sites/all/modules/contrib/admin/google_analytics/README.txt
index 1628cf7..8ef9818 100644
--- a/sites/all/modules/contrib/admin/google_analytics/README.txt
+++ b/sites/all/modules/contrib/admin/google_analytics/README.txt
@@ -1,6 +1,6 @@
Module: Google Analytics
-Author: Alexander Hass
+Author: Alexander Hass
Description
@@ -12,12 +12,20 @@ Requirements
* Google Analytics user account
-
Installation
============
-* Copy the 'googleanalytics' module directory in to your Drupal
+Copy the 'googleanalytics' module directory in to your Drupal
sites/all/modules directory as usual.
+Upgrading from 6.x-3.x and 7.x-1.x
+==================================
+If you upgrade from 6.x-3.x and 7.x-1.x (ga.js) to 7.x-2.x (analytics.js) you
+should verify if you used custom variables. Write down your settings or make a
+screenshot. You need to re-configure the settings to use custom dimensions or
+metrics. There is no automatic upgrade path for custom variables feature. All
+other module settings are upgraded automatically.
+
+See https://support.google.com/analytics/answer/2795983?hl=en for more details.
Usage
=====
@@ -27,12 +35,8 @@ All pages will now have the required JavaScript added to the
HTML footer can confirm this by viewing the page source from
your browser.
-New approach to page tracking in 5.x-1.5 and 6.x-1.1
-====================================================
-With 5.x-1.5 and 6.x-1.1 there are new settings on the settings page at
-admin/config/system/googleanalytics. The "Page specific tracking" area now
-comes with an interface that copies Drupal's block visibility settings.
-
+Page specific tracking
+======================
The default is set to "Add to every page except the listed pages". By
default the following pages are listed for exclusion:
@@ -44,33 +48,57 @@ node/*/*
user/*/*
These defaults are changeable by the website administrator or any other
-user with 'administer google analytics' permission.
+user with 'Administer Google Analytics' permission.
-Like the blocks visibility settings in Drupal core, there is now a
-choice for "Add if the following PHP code returns TRUE." Sample PHP snippets
-that can be used in this textarea can be found on the handbook page
-"Overview-approach to block visibility" at http://drupal.org/node/64135.
+Like the blocks visibility settings in Drupal core, there is a choice for
+"Add if the following PHP code returns TRUE." Sample PHP snippets that can be
+used in this textarea can be found on the handbook page "Overview-approach to
+block visibility" at https://drupal.org/node/64135.
-Custom variables
-=================
-One example for custom variables tracking is the "User roles" tracking. Enter
-the below configuration data into the custom variables settings form under
-admin/config/system/googleanalytics.
+Custom dimensions and metrics
+=============================
+One example for custom dimensions tracking is the "User roles" tracking.
-Slot: 1
-Name: User roles
-Value: [current-user:role-names]
-Scope: Visitor
+1. In the Google Analytics (https://marketingplatform.google.com/about/analytics/)
+ Management Interface you need to setup Dimension #1 with name
+ e.g. "User roles". This step is required. Do not miss it, please.
-More details about Custom variables can be found in the Google API documentation at
-http://code.google.com/intl/en/apis/analytics/docs/tracking/gaTrackingCustomVariables.html
+2. Enter the below configuration data into the Drupal custom dimensions settings
+ form under admin/config/system/googleanalytics. You can also choose another
+ index, but keep it always in sync with the index used in step #1.
+
+ Index: 1
+ Value: [current-user:role-names]
+
+More details about custom dimensions and metrics can be found in the Google API
+documentation at https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
Advanced Settings
=================
You can include additional JavaScript snippets in the custom javascript
code textarea. These can be found on the official Google Analytics pages
-and a few examples at http://drupal.org/node/248699. Support is not
+and a few examples at https://drupal.org/node/248699. Support is not
provided for any customisations you include.
-To speed up page loading you may also cache the Analytics ga.js
+To speed up page loading you may also cache the Google Analytics "analytics.js"
file locally.
+
+Manual JS debugging
+===================
+For manual debugging of the JS code you are able to create a test node. This
+is the example HTML code for this test node. You need to enable debugging mode
+in your Drupal configuration of Google Analytics settings to see verbose
+messages in your browsers JS console.
+
+Title: Google Analytics test page
+
+Body:
+
+
+Text format: Full HTML
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.inc b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.inc
index 40d5cad..2d8afa3 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.inc
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.inc
@@ -18,10 +18,17 @@ function googleanalytics_admin_settings_form($form_state) {
'#title' => t('Web Property ID'),
'#type' => 'textfield',
'#default_value' => variable_get('googleanalytics_account', 'UA-'),
- '#size' => 15,
+ '#size' => 20,
'#maxlength' => 20,
'#required' => TRUE,
- '#description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, register your site with Google Analytics, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. Find more information in the documentation.', array('@analytics' => 'http://www.google.com/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty')))),
+ '#description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, register your site with Google Analytics, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. Find more information in the documentation.', array('@analytics' => 'https://marketingplatform.google.com/about/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty')))),
+ );
+
+ $form['account']['googleanalytics_premium'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Premium account'),
+ '#description' => t('If you are a Google Analytics Premium customer, you can use up to 200 instead of 20 custom dimensions and metrics.'),
+ '#default_value' => variable_get('googleanalytics_premium', FALSE),
);
// Visibility settings.
@@ -80,7 +87,15 @@ function googleanalytics_admin_settings_form($form_state) {
'#title' => t('List of top-level domains'),
'#type' => 'textarea',
'#default_value' => variable_get('googleanalytics_cross_domains', ''),
- '#description' => t('If you selected "Multiple top-level domains" above, enter all related top-level domains. Add one domain per line. By default, the data in your reports only includes the path and name of the page, and not the domain name. For more information see section Show separate domain names in Tracking Multiple Domains.', array('@url' => url('http://support.google.com/analytics/bin/answer.py', array('query' => array('answer' => '1034342'))))),
+ '#description' => t('If you selected "Multiple top-level domains" above, enter all related top-level domains. Add one domain per line. By default, the data in your reports only includes the path and name of the page, and not the domain name. For more information see section Show separate domain names in Tracking Multiple Domains.', array('@url' => 'https://support.google.com/analytics/answer/1034342')),
+ '#states' => array(
+ 'enabled' => array(
+ ':input[name="googleanalytics_domain_mode"]' => array('value' => '2'),
+ ),
+ 'required' => array(
+ ':input[name="googleanalytics_domain_mode"]' => array('value' => '2'),
+ ),
+ ),
);
// Page specific visibility configurations.
@@ -97,8 +112,8 @@ function googleanalytics_admin_settings_form($form_state) {
if ($visibility == 2 && !$php_access) {
$form['tracking']['page_vis_settings'] = array();
- $form['tracking']['page_vis_settings']['visibility'] = array('#type' => 'value', '#value' => 2);
- $form['tracking']['page_vis_settings']['pages'] = array('#type' => 'value', '#value' => $pages);
+ $form['tracking']['page_vis_settings']['googleanalytics_visibility_pages'] = array('#type' => 'value', '#value' => 2);
+ $form['tracking']['page_vis_settings']['googleanalytics_pages'] = array('#type' => 'value', '#value' => $pages);
}
else {
$options = array(
@@ -161,7 +176,7 @@ function googleanalytics_admin_settings_form($form_state) {
'#type' => 'fieldset',
'#title' => t('Users'),
);
- $t_permission = array('%permission' => t('opt-in or out of tracking'));
+ $t_permission = array('%permission' => t('Opt-in or out of tracking'));
$form['tracking']['user_vis_settings']['googleanalytics_custom'] = array(
'#type' => 'radios',
'#title' => t('Allow users to customize tracking on their account page'),
@@ -172,6 +187,12 @@ function googleanalytics_admin_settings_form($form_state) {
),
'#default_value' => variable_get('googleanalytics_custom', 0),
);
+ $form['tracking']['user_vis_settings']['googleanalytics_trackuserid'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Track User ID'),
+ '#default_value' => variable_get('googleanalytics_trackuserid', 0),
+ '#description' => t('User ID enables the analysis of groups of sessions, across devices, using a unique, persistent, and non-personally identifiable ID string representing a user. Learn more about the benefits of using User ID.', array('@url' => 'https://support.google.com/analytics/answer/3123663')),
+ );
// Link specific configurations.
$form['tracking']['linktracking'] = array(
@@ -199,7 +220,40 @@ function googleanalytics_admin_settings_form($form_state) {
'#type' => 'textfield',
'#default_value' => variable_get('googleanalytics_trackfiles_extensions', GOOGLEANALYTICS_TRACKFILES_EXTENSIONS),
'#description' => t('A file extension list separated by the | character that will be tracked as download when clicked. Regular expressions are supported. For example: !extensions', array('!extensions' => GOOGLEANALYTICS_TRACKFILES_EXTENSIONS)),
- '#maxlength' => 255,
+ '#maxlength' => 500,
+ '#states' => array(
+ 'enabled' => array(
+ ':input[name="googleanalytics_trackfiles"]' => array('checked' => TRUE),
+ ),
+ // Note: Form required marker is not visible as title is invisible.
+ 'required' => array(
+ ':input[name="googleanalytics_trackfiles"]' => array('checked' => TRUE),
+ ),
+ ),
+ );
+
+ $colorbox_dependencies = '
';
+
+ $form['tracking']['linktracking']['googleanalytics_trackcolorbox'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Track content in colorbox modal dialogs'),
+ '#default_value' => variable_get('googleanalytics_trackcolorbox', 1),
+ '#description' => t('Enable to track the content shown in colorbox modal windows.') . $colorbox_dependencies,
+ '#disabled' => (module_exists('colorbox') ? FALSE : TRUE),
+ );
+ $form['tracking']['linktracking']['googleanalytics_tracklinkid'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Track enhanced link attribution'),
+ '#default_value' => variable_get('googleanalytics_tracklinkid', 0),
+ '#description' => t('Enhanced Link Attribution improves the accuracy of your In-Page Analytics report by automatically differentiating between multiple links to the same URL on a single page by using link element IDs. Enable enhanced link attribution in the Admin UI of your Google Analytics account.', array('@url' => 'https://support.google.com/analytics/answer/2558867')),
+ );
+ $form['tracking']['linktracking']['googleanalytics_trackurlfragments'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Track changing URL fragments as pageviews'),
+ '#default_value' => variable_get('googleanalytics_trackurlfragments', 0),
+ '#description' => t('By default, the URL reported to Google Analytics will not include the "fragment identifier" (i.e. the portion of the URL beginning with a hash sign), and hash changes by themselves will not cause new pageviews to be reported. Checking this box will cause hash changes to be reported as pageviews (in modern browsers) and all pageview URLs to include the fragment where applicable.'),
);
// Message specific configurations.
@@ -211,7 +265,7 @@ function googleanalytics_admin_settings_form($form_state) {
'#type' => 'checkboxes',
'#title' => t('Track messages of type'),
'#default_value' => variable_get('googleanalytics_trackmessages', array()),
- '#description' => t('This will track the selected message types shown to users. Tracking of form validation errors may help you identifying usability issues in your site. Keep in mind that Google allows a maximum of 500 events per session only and every message is tracked as one individual event. If the limit has been exceeded no further events are tracked, but normal page tracking is not effected. Messages from excluded pages cannot tracked.'),
+ '#description' => t('This will track the selected message types shown to users. Tracking of form validation errors may help you identifying usability issues in your site. For each visit (user session), a maximum of approximately 500 combined GATC requests (both events and page views) can be tracked. Every message is tracked as one individual event. Note that - as the number of events in a session approaches the limit - additional events might not be tracked. Messages from excluded pages cannot be tracked.'),
'#options' => array(
'status' => t('Status message'),
'warning' => t('Warning message'),
@@ -219,21 +273,19 @@ function googleanalytics_admin_settings_form($form_state) {
),
);
- // Google already have many translations, if not - they display a note to change the language.
- global $language;
$form['tracking']['search_and_advertising'] = array(
'#type' => 'fieldset',
'#title' => t('Search and Advertising'),
);
- $site_search_dependencies = '
';
$form['tracking']['search_and_advertising']['googleanalytics_site_search'] = array(
'#type' => 'checkbox',
'#title' => t('Track internal search'),
- '#description' => t('If checked, internal search keywords are tracked. You must configure your Google account to use the internal query parameter search. For more information see Setting Up Site Search for a Profile.', array('@url' => url('http://support.google.com/analytics/bin/answer.py', array('query' => array('answer' => '1012264'))))) . $site_search_dependencies,
+ '#description' => t('If checked, internal search keywords are tracked. You must configure your Google account to use the internal query parameter search. For more information see Setting Up Site Search for a Profile.', array('@url' => 'https://support.google.com/analytics/answer/1012264')) . $site_search_dependencies,
'#default_value' => variable_get('googleanalytics_site_search', FALSE),
'#disabled' => (module_exists('search') ? FALSE : TRUE),
);
@@ -245,8 +297,8 @@ function googleanalytics_admin_settings_form($form_state) {
);
$form['tracking']['search_and_advertising']['googleanalytics_trackdoubleclick'] = array(
'#type' => 'checkbox',
- '#title' => t('Track DoubleClick data'),
- '#description' => t('If checked, the alternative Google DoubleClick data tracking is used to enable AdWords remarketing features. If you choose this option you will need to update your privacy policy.', array('@doubleclick' => url('http://support.google.com/analytics/bin/answer.py', array('query' => array('answer' => '2444872'))), '@privacy' => url('http://support.google.com/analytics/bin/answer.py', array('query' => array('answer' => '2636405'))))),
+ '#title' => t('Track display features'),
+ '#description' => t('The display features plugin can be used to enable Display Advertising Features in Google Analytics, such as Remarketing, Demographics and Interest Reporting, and more. Learn more about Display Advertising Features in Google Analytics. If you choose this option you will need to update your privacy policy.', array('@displayfeatures' => 'https://support.google.com/analytics/answer/3450482', '@privacy' => 'https://support.google.com/analytics/answer/2700409')),
'#default_value' => variable_get('googleanalytics_trackdoubleclick', FALSE),
);
@@ -259,88 +311,119 @@ function googleanalytics_admin_settings_form($form_state) {
'#type' => 'checkbox',
'#title' => t('Anonymize visitors IP address'),
'#description' => t('Tell Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage. Note that this will slightly reduce the accuracy of geographic reporting. In some countries it is not allowed to collect personally identifying information for privacy reasons and this setting may help you to comply with the local laws.'),
- '#default_value' => variable_get('googleanalytics_tracker_anonymizeip', 0),
+ '#default_value' => variable_get('googleanalytics_tracker_anonymizeip', 1),
);
$form['tracking']['privacy']['googleanalytics_privacy_donottrack'] = array(
'#type' => 'checkbox',
'#title' => t('Universal web tracking opt-out'),
- '#description' => t('If enabled and your server receives the Do-Not-Track header from the client browser, the Google Analytics module will not embed any tracking code into your site. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision. This feature is currently limited to logged in users and disabled page caching.', array('@donottrack' => 'http://donottrack.us/')),
+ '#description' => t('If enabled and your server receives the Do-Not-Track header from the client browser, the Google Analytics module will not embed any tracking code into your site. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision. This feature is currently limited to logged in users and disabled page caching.', array('@donottrack' => 'https://www.eff.org/issues/do-not-track')),
'#default_value' => variable_get('googleanalytics_privacy_donottrack', 1),
);
- // Custom variables.
- $form['googleanalytics_custom_var'] = array(
+ // Custom Dimensions.
+ $form['googleanalytics_custom_dimension'] = array(
'#collapsed' => TRUE,
'#collapsible' => TRUE,
- '#description' => t('You can add Google Analytics Custom Variables here. These will be added to every page that Google Analytics tracking code appears on. Google Analytics will only accept custom variables if the name and value combined are less than 128 bytes after URL encoding. Keep the names as short as possible and expect long values to get trimmed. You may use tokens in custom variable names and values. Global and user tokens are always available; on node pages, node tokens are also available.', array('@custom_var_documentation' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables')),
+ '#description' => t('You can set values for Google Analytics Custom Dimensions here. You must have already configured your custom dimensions in the Google Analytics Management Interface. You may use tokens. Global and user tokens are always available; on node pages, node tokens are also available. A dimension value is allowed to have a maximum length of 150 bytes. Expect longer values to get trimmed.', array('@custom_var_documentation' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets', '@setup_documentation' => 'https://support.google.com/analytics/answer/2709829')),
'#theme' => 'googleanalytics_admin_custom_var_table',
- '#title' => t('Custom variables'),
+ '#title' => t('Custom dimensions'),
'#tree' => TRUE,
'#type' => 'fieldset',
);
- $googleanalytics_custom_vars = variable_get('googleanalytics_custom_var', array());
+ $googleanalytics_custom_dimension = variable_get('googleanalytics_custom_dimension', array());
- // Google Analytics supports up to 5 custom variables.
- for ($i = 1; $i < 6; $i++) {
- $form['googleanalytics_custom_var']['slots'][$i]['slot'] = array(
+ // Standard Google Analytics accounts support up to 20 custom dimensions,
+ // premium accounts support up to 200 custom dimensions.
+ $limit = (variable_get('googleanalytics_premium', FALSE)) ? 200 : 20;
+ for ($i = 1; $i <= $limit; $i++) {
+ $form['googleanalytics_custom_dimension']['indexes'][$i]['index'] = array(
'#default_value' => $i,
- '#description' => t('Slot number'),
+ '#description' => t('Index number'),
'#disabled' => TRUE,
'#size' => 1,
- '#title' => t('Custom variable slot #@slot', array('@slot' => $i)),
+ '#title' => t('Custom dimension index #@index', array('@index' => $i)),
'#title_display' => 'invisible',
'#type' => 'textfield',
);
- $form['googleanalytics_custom_var']['slots'][$i]['name'] = array(
- '#default_value' => !empty($googleanalytics_custom_vars['slots'][$i]['name']) ? $googleanalytics_custom_vars['slots'][$i]['name'] : '',
- '#description' => t('The custom variable name.'),
+ $form['googleanalytics_custom_dimension']['indexes'][$i]['value'] = array(
+ '#default_value' => isset($googleanalytics_custom_dimension[$i]['value']) ? $googleanalytics_custom_dimension[$i]['value'] : '',
+ '#description' => t('The custom dimension value.'),
'#maxlength' => 255,
- '#size' => 20,
- '#title' => t('Custom variable name #@slot', array('@slot' => $i)),
- '#title_display' => 'invisible',
- '#type' => 'textfield',
- '#element_validate' => array('googleanalytics_token_element_validate'),
- '#token_types' => array('node'),
- );
- $form['googleanalytics_custom_var']['slots'][$i]['value'] = array(
- '#default_value' => !empty($googleanalytics_custom_vars['slots'][$i]['value']) ? $googleanalytics_custom_vars['slots'][$i]['value'] : '',
- '#description' => t('The custom variable value.'),
- '#maxlength' => 255,
- '#title' => t('Custom variable value #@slot', array('@slot' => $i)),
+ '#title' => t('Custom dimension value #@index', array('@index' => $i)),
'#title_display' => 'invisible',
'#type' => 'textfield',
'#element_validate' => array('googleanalytics_token_element_validate'),
'#token_types' => array('node'),
);
if (module_exists('token')) {
- $form['googleanalytics_custom_var']['slots'][$i]['name']['#element_validate'][] = 'token_element_validate';
- $form['googleanalytics_custom_var']['slots'][$i]['value']['#element_validate'][] = 'token_element_validate';
+ $form['googleanalytics_custom_dimension']['indexes'][$i]['value']['#element_validate'][] = 'token_element_validate';
}
- $form['googleanalytics_custom_var']['slots'][$i]['scope'] = array(
- '#default_value' => !empty($googleanalytics_custom_vars['slots'][$i]['scope']) ? $googleanalytics_custom_vars['slots'][$i]['scope'] : 3,
- '#description' => t('The scope for the custom variable.'),
- '#title' => t('Custom variable slot #@slot', array('@slot' => $i)),
- '#title_display' => 'invisible',
- '#type' => 'select',
- '#options' => array(
- 1 => t('Visitor'),
- 2 => t('Session'),
- 3 => t('Page'),
- ),
+ }
+
+ $form['googleanalytics_custom_dimension']['googleanalytics_description'] = array(
+ '#type' => 'item',
+ '#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom dimensions. Section 7 of the Google Analytics terms of service requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'https://www.google.com/analytics/terms/gb.html')),
+ );
+ if (module_exists('token')) {
+ $form['googleanalytics_custom_dimension']['googleanalytics_token_tree'] = array(
+ '#theme' => 'token_tree',
+ '#token_types' => array('node'),
+ '#dialog' => TRUE,
);
}
- $form['googleanalytics_custom_var']['googleanalytics_custom_var_description'] = array(
- '#type' => 'item',
- '#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom variables. Section 7 of the Google Analytics terms of service requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'http://www.google.com/analytics/terms/gb.html')),
- );
- $form['googleanalytics_custom_var']['googleanalytics_custom_var_token_tree'] = array(
- '#theme' => 'token_tree',
- '#token_types' => array('node'),
- '#dialog' => TRUE,
+ // Custom Metrics.
+ $form['googleanalytics_custom_metric'] = array(
+ '#collapsed' => TRUE,
+ '#collapsible' => TRUE,
+ '#description' => t('You can add Google Analytics Custom Metrics here. You must have already configured your custom metrics in the Google Analytics Management Interface. You may use tokens. Global and user tokens are always available; on node pages, node tokens are also available.', array('@custom_var_documentation' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets', '@setup_documentation' => 'https://support.google.com/analytics/answer/2709829')),
+ '#theme' => 'googleanalytics_admin_custom_var_table',
+ '#title' => t('Custom metrics'),
+ '#tree' => TRUE,
+ '#type' => 'fieldset',
);
+ $googleanalytics_custom_metric = variable_get('googleanalytics_custom_metric', array());
+
+ // Standard Google Analytics accounts support up to 20 custom metrics,
+ // premium accounts support up to 200 custom metrics.
+ for ($i = 1; $i <= $limit; $i++) {
+ $form['googleanalytics_custom_metric']['indexes'][$i]['index'] = array(
+ '#default_value' => $i,
+ '#description' => t('Index number'),
+ '#disabled' => TRUE,
+ '#size' => 1,
+ '#title' => t('Custom metric index #@index', array('@index' => $i)),
+ '#title_display' => 'invisible',
+ '#type' => 'textfield',
+ );
+ $form['googleanalytics_custom_metric']['indexes'][$i]['value'] = array(
+ '#default_value' => isset($googleanalytics_custom_metric[$i]['value']) ? $googleanalytics_custom_metric[$i]['value'] : '',
+ '#description' => t('The custom metric value.'),
+ '#maxlength' => 255,
+ '#title' => t('Custom metric value #@index', array('@index' => $i)),
+ '#title_display' => 'invisible',
+ '#type' => 'textfield',
+ '#element_validate' => array('googleanalytics_token_element_validate'),
+ '#token_types' => array('node'),
+ );
+ if (module_exists('token')) {
+ $form['googleanalytics_custom_metric']['indexes'][$i]['value']['#element_validate'][] = 'token_element_validate';
+ }
+ }
+
+ $form['googleanalytics_custom_metric']['googleanalytics_description'] = array(
+ '#type' => 'item',
+ '#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom metrics. Section 7 of the Google Analytics terms of service requires that You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, userid, email address or billing information), or other data which can be reasonably linked to such information by Google. You will have and abide by an appropriate Privacy Policy and will comply with all applicable laws and regulations relating to the collection of information from Visitors. You must post a Privacy Policy and that Privacy Policy must provide notice of Your use of cookies that are used to collect traffic data, and You must not circumvent any privacy features (e.g., an opt-out) that are part of the Service.', array('@ga_tos' => 'https://www.google.com/analytics/terms/gb.html')),
+ );
+ if (module_exists('token')) {
+ $form['googleanalytics_custom_metric']['googleanalytics_token_tree'] = array(
+ '#theme' => 'token_tree',
+ '#token_types' => array('node'),
+ '#dialog' => TRUE,
+ );
+ }
// Advanced feature configurations.
$form['advanced'] = array(
@@ -367,38 +450,45 @@ function googleanalytics_admin_settings_form($form_state) {
);
}
+ $user_access_add_js_snippets = !user_access('add JS snippets for google analytics');
+ $user_access_add_js_snippets_permission_warning = $user_access_add_js_snippets ? ' ' . t('This field has been disabled because you do not have sufficient permissions to edit it.') . '' : '';
$form['advanced']['codesnippet'] = array(
'#type' => 'fieldset',
'#title' => t('Custom JavaScript code'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
- '#description' => t('You can add custom Google Analytics code snippets here. These will be added every time tracking is in effect. Before you add your custom code, you should read the Google Analytics Tracking Code - Functional Overview and the Google Analytics Tracking API documentation. Do not include the <script> tags, and always end your code with a semicolon (;).', array('@snippets' => 'http://drupal.org/node/248699', '@ga_concepts_overview' => 'https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview', '@ga_js_api' => 'https://developers.google.com/analytics/devguides/collection/gajs/methods/')),
+ '#description' => t('You can add custom Google Analytics code snippets here. These will be added every time tracking is in effect. Before you add your custom code, you should read the Google Analytics Tracking Code - Functional Overview and the Google Analytics Tracking API documentation. Do not include the <script> tags, and always end your code with a semicolon (;).', array('@snippets' => 'https://drupal.org/node/248699', '@ga_concepts_overview' => 'https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview', '@ga_js_api' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference')),
+ );
+ $form['advanced']['codesnippet']['googleanalytics_codesnippet_create'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Create only fields'),
+ '#default_value' => _googleanalytics_get_name_value_string(variable_get('googleanalytics_codesnippet_create', array())),
+ '#rows' => 5,
+ '#description' => t('Enter one value per line, in the format name|value. Settings in this textarea will be added to ga("create", "UA-XXXX-Y", {"name":"value"});. For more information, read create only fields documentation in the Analytics.js field reference.', array('@url' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#create')),
+ '#element_validate' => array('googleanalytics_validate_create_field_values'),
);
$form['advanced']['codesnippet']['googleanalytics_codesnippet_before'] = array(
'#type' => 'textarea',
'#title' => t('Code snippet (before)'),
'#default_value' => variable_get('googleanalytics_codesnippet_before', ''),
+ '#disabled' => $user_access_add_js_snippets,
'#rows' => 5,
- '#description' => t("Code in this textarea will be added before _gaq.push(['_trackPageview'])."),
+ '#description' => t('Code in this textarea will be added beforega("send", "pageview");.') . $user_access_add_js_snippets_permission_warning,
);
$form['advanced']['codesnippet']['googleanalytics_codesnippet_after'] = array(
'#type' => 'textarea',
'#title' => t('Code snippet (after)'),
'#default_value' => variable_get('googleanalytics_codesnippet_after', ''),
+ '#disabled' => $user_access_add_js_snippets,
'#rows' => 5,
- '#description' => t("Code in this textarea will be added after _gaq.push(['_trackPageview']). This is useful if you'd like to track a site in two accounts."),
+ '#description' => t('Code in this textarea will be added afterga("send", "pageview");. This is useful if you\'d like to track a site in two accounts.') . $user_access_add_js_snippets_permission_warning,
);
- $form['advanced']['googleanalytics_js_scope'] = array(
- '#type' => 'select',
- '#title' => t('JavaScript scope'),
- '#description' => t('Google recommends adding the external JavaScript files to the header for performance reasons. If Multiple top-level domains has been selected, this setting will be forced to header.'),
- '#options' => array(
- 'footer' => t('Footer'),
- 'header' => t('Header'),
- ),
- '#default_value' => variable_get('googleanalytics_js_scope', 'header'),
- '#disabled' => (variable_get('googleanalytics_domain_mode', 0) == 2) ? TRUE : FALSE,
+ $form['advanced']['googleanalytics_debug'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable debugging'),
+ '#description' => t('If checked, the Google Universal Analytics debugging script will be loaded. You should not enable your production site to use this version of the JavaScript. The analytics_debug.js script is larger than the analytics.js tracking code and it is not typically cached. Using it in your production site will slow down your site for all of your users. Again, this is only for your own testing purposes. Debug messages are printed to the window.console object.'),
+ '#default_value' => variable_get('googleanalytics_debug', 0),
);
return system_settings_form($form);
@@ -408,31 +498,37 @@ function googleanalytics_admin_settings_form($form_state) {
* Implements _form_validate().
*/
function googleanalytics_admin_settings_form_validate($form, &$form_state) {
- // Custom variables validation.
- foreach ($form_state['values']['googleanalytics_custom_var']['slots'] as $custom_var) {
- $form_state['values']['googleanalytics_custom_var']['slots'][$custom_var['slot']]['name'] = trim($custom_var['name']);
- $form_state['values']['googleanalytics_custom_var']['slots'][$custom_var['slot']]['value'] = trim($custom_var['value']);
-
- // Validate empty names/values.
- if (empty($custom_var['name']) && !empty($custom_var['value'])) {
- form_set_error("googleanalytics_custom_var][slots][" . $custom_var['slot'] . "][name", t('The custom variable @slot-number requires a Name if a Value has been provided.', array('@slot-number' => $custom_var['slot'])));
- }
- elseif (!empty($custom_var['name']) && empty($custom_var['value'])) {
- form_set_error("googleanalytics_custom_var][slots][" . $custom_var['slot'] . "][value", t('The custom variable @slot-number requires a Value if a Name has been provided.', array('@slot-number' => $custom_var['slot'])));
+ // Trim custom dimensions and metrics.
+ foreach ($form_state['values']['googleanalytics_custom_dimension']['indexes'] as $dimension) {
+ $form_state['values']['googleanalytics_custom_dimension']['indexes'][$dimension['index']]['value'] = trim($dimension['value']);
+ // Remove empty values from the array.
+ if (!drupal_strlen($form_state['values']['googleanalytics_custom_dimension']['indexes'][$dimension['index']]['value'])) {
+ unset($form_state['values']['googleanalytics_custom_dimension']['indexes'][$dimension['index']]);
}
}
+ $form_state['values']['googleanalytics_custom_dimension'] = $form_state['values']['googleanalytics_custom_dimension']['indexes'];
+
+ foreach ($form_state['values']['googleanalytics_custom_metric']['indexes'] as $metric) {
+ $form_state['values']['googleanalytics_custom_metric']['indexes'][$metric['index']]['value'] = trim($metric['value']);
+ // Remove empty values from the array.
+ if (!drupal_strlen($form_state['values']['googleanalytics_custom_metric']['indexes'][$metric['index']]['value'])) {
+ unset($form_state['values']['googleanalytics_custom_metric']['indexes'][$metric['index']]);
+ }
+ }
+ $form_state['values']['googleanalytics_custom_metric'] = $form_state['values']['googleanalytics_custom_metric']['indexes'];
// Trim some text values.
$form_state['values']['googleanalytics_account'] = trim($form_state['values']['googleanalytics_account']);
$form_state['values']['googleanalytics_pages'] = trim($form_state['values']['googleanalytics_pages']);
$form_state['values']['googleanalytics_cross_domains'] = trim($form_state['values']['googleanalytics_cross_domains']);
+ $form_state['values']['googleanalytics_codesnippet_create'] = _googleanalytics_extract_create_field_values($form_state['values']['googleanalytics_codesnippet_create']);
$form_state['values']['googleanalytics_codesnippet_before'] = trim($form_state['values']['googleanalytics_codesnippet_before']);
$form_state['values']['googleanalytics_codesnippet_after'] = trim($form_state['values']['googleanalytics_codesnippet_after']);
// Replace all type of dashes (n-dash, m-dash, minus) with the normal dashes.
$form_state['values']['googleanalytics_account'] = str_replace(array('–', '—', '−'), '-', $form_state['values']['googleanalytics_account']);
- if (!preg_match('/^UA-\d{4,}-\d+$/', $form_state['values']['googleanalytics_account'])) {
+ if (!preg_match('/^UA-\d+-\d+$/', $form_state['values']['googleanalytics_account'])) {
form_set_error('googleanalytics_account', t('A valid Google Analytics Web Property ID is case sensitive and formatted like UA-xxxxxxx-yy.'));
}
@@ -440,16 +536,25 @@ function googleanalytics_admin_settings_form_validate($form, &$form_state) {
if ($form_state['values']['googleanalytics_domain_mode'] == 2 && empty($form_state['values']['googleanalytics_cross_domains'])) {
form_set_error('googleanalytics_cross_domains', t('A list of top-level domains is required if Multiple top-level domains has been selected.'));
}
+ // Clear the domain list if cross domains are disabled.
+ if ($form_state['values']['googleanalytics_domain_mode'] != 2) {
+ $form_state['values']['googleanalytics_cross_domains'] = '';
+ }
+
+ // Disallow empty list of download file extensions.
+ if ($form_state['values']['googleanalytics_trackfiles'] && empty($form_state['values']['googleanalytics_trackfiles_extensions'])) {
+ form_set_error('googleanalytics_trackfiles_extensions', t('List of download file extensions cannot empty.'));
+ }
// Clear obsolete local cache if cache has been disabled.
if (empty($form_state['values']['googleanalytics_cache']) && $form['advanced']['googleanalytics_cache']['#default_value']) {
googleanalytics_clear_js_cache();
}
// This is for the Newbie's who cannot read a text area description.
- if (stristr($form_state['values']['googleanalytics_codesnippet_before'], 'google-analytics.com/ga.js')) {
+ if (stristr($form_state['values']['googleanalytics_codesnippet_before'], 'google-analytics.com/analytics.js')) {
form_set_error('googleanalytics_codesnippet_before', t('Do not add the tracker code provided by Google into the javascript code snippets! This module already builds the tracker code based on your Google Analytics account number and settings.'));
}
- if (stristr($form_state['values']['googleanalytics_codesnippet_after'], 'google-analytics.com/ga.js')) {
+ if (stristr($form_state['values']['googleanalytics_codesnippet_after'], 'google-analytics.com/analytics.js')) {
form_set_error('googleanalytics_codesnippet_after', t('Do not add the tracker code provided by Google into the javascript code snippets! This module already builds the tracker code based on your Google Analytics account number and settings.'));
}
if (preg_match('/(.*)<\/?script(.*)>(.*)/i', $form_state['values']['googleanalytics_codesnippet_before'])) {
@@ -458,41 +563,40 @@ function googleanalytics_admin_settings_form_validate($form, &$form_state) {
if (preg_match('/(.*)<\/?script(.*)>(.*)/i', $form_state['values']['googleanalytics_codesnippet_after'])) {
form_set_error('googleanalytics_codesnippet_after', t('Do not include the <script> tags in the javascript code snippets.'));
}
-
- // Header section must be forced for multiple top-level domains.
- if ($form_state['values']['googleanalytics_domain_mode'] == 2) {
- $form_state['values']['googleanalytics_js_scope'] = 'header';
- }
}
/**
* Layout for the custom variables table in the admin settings form.
+ *
+ * @param array $variables
+ * An array contains the form elements.
+ *
+ * @return string
+ * The rendered output.
*/
function theme_googleanalytics_admin_custom_var_table($variables) {
$form = $variables['form'];
$header = array(
- array('data' => t('Slot')),
- array('data' => t('Name')),
+ array('data' => t('Index')),
array('data' => t('Value')),
- array('data' => t('Scope')),
);
$rows = array();
- foreach (element_children($form['slots']) as $key => $id) {
+ foreach (element_children($form['indexes']) as $id) {
$rows[] = array(
'data' => array(
- drupal_render($form['slots'][$id]['slot']),
- drupal_render($form['slots'][$id]['name']),
- drupal_render($form['slots'][$id]['value']),
- drupal_render($form['slots'][$id]['scope']),
+ drupal_render($form['indexes'][$id]['index']),
+ drupal_render($form['indexes'][$id]['value']),
),
);
}
$output = theme('table', array('header' => $header, 'rows' => $rows));
- $output .= drupal_render($form['googleanalytics_custom_var_description']);
- $output .= drupal_render($form['googleanalytics_custom_var_token_tree']);
+ $output .= drupal_render($form['googleanalytics_description']);
+ if (isset($form['googleanalytics_token_tree'])) {
+ $output .= drupal_render($form['googleanalytics_token_tree']);
+ }
return $output;
}
@@ -528,11 +632,18 @@ function googleanalytics_token_element_validate(&$element, &$form_state) {
return $element;
}
+/**
+ * @param array $value
+ * An array of token values.
+ *
+ * @return array
+ * A unique array of invalid tokens.
+ */
function _googleanalytics_get_forbidden_tokens($value) {
$invalid_tokens = array();
$value_tokens = is_string($value) ? token_scan($value) : $value;
- foreach ($value_tokens as $type => $tokens) {
+ foreach ($value_tokens as $tokens) {
if (array_filter($tokens, '_googleanalytics_contains_forbidden_token')) {
$invalid_tokens = array_merge($invalid_tokens, array_values($tokens));
}
@@ -545,8 +656,9 @@ function _googleanalytics_get_forbidden_tokens($value) {
/**
* Validate if a string contains forbidden tokens not allowed by privacy rules.
*
- * @param $token_string
+ * @param string $token_string
* A string with one or more tokens to be validated.
+ *
* @return boolean
* TRUE if blacklisted token has been found, otherwise FALSE.
*/
@@ -599,3 +711,203 @@ function _googleanalytics_contains_forbidden_token($token_string) {
return preg_match('/' . implode('|', array_map('preg_quote', $token_blacklist)) . '/i', $token_string);
}
+
+/**
+ * #element_validate callback for create only fields.
+ *
+ * @param $element
+ * An associative array containing the properties and children of the
+ * generic form element.
+ * @param $form_state
+ * The $form_state array for the form this element belongs to.
+ *
+ * @see form_process_pattern()
+ */
+function googleanalytics_validate_create_field_values(&$element, &$form_state) {
+ $values = _googleanalytics_extract_create_field_values($element['#value']);
+
+ if (!is_array($values)) {
+ form_error($element, t('The %element-title field contains invalid input.', array('%element-title' => $element['#title'])));
+ }
+ else {
+ // Check that name and value are valid for the field type.
+ foreach ($values as $name => $value) {
+ if ($error = _googleanalytics_validate_create_field_name($name)) {
+ form_error($element, $error);
+ break;
+ }
+ if ($error = _googleanalytics_validate_create_field_value($value)) {
+ form_error($element, $error);
+ break;
+ }
+ }
+
+ return $element;
+ }
+}
+
+/**
+ * Extracts the values array from the element.
+ *
+ * @param string $string
+ * The raw string to extract values from.
+ *
+ * @return array|null
+ * The array of extracted key/value pairs, or NULL if the string is invalid.
+ *
+ * @see \Drupal\options\Plugin\Field\FieldType\ListTextItem::allowedValuesString()
+ */
+function _googleanalytics_extract_create_field_values($string) {
+ $values = array();
+
+ $list = explode("\n", $string);
+ $list = array_map('trim', $list);
+ $list = array_filter($list, 'strlen');
+
+ foreach ($list as $text) {
+ // Check for an explicit key.
+ $matches = array();
+ if (preg_match('/(.*)\|(.*)/', $text, $matches)) {
+ // Trim key and value to avoid unwanted spaces issues.
+ $name = trim($matches[1]);
+ $value = trim($matches[2]);
+ }
+ else {
+ return;
+ }
+
+ $values[$name] = $value;
+ }
+
+ return _googleanalytics_convert_form_value_data_types($values);
+}
+
+/**
+ * Checks whether a field name is valid.
+ *
+ * @param string $name
+ * The option value entered by the user.
+ *
+ * @return string
+ * The error message if the specified value is invalid, NULL otherwise.
+ */
+function _googleanalytics_validate_create_field_name($name) {
+ // List of supported field names:
+ // https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#create
+ $create_only_fields = array(
+ 'allowAnchor',
+ 'alwaysSendReferrer',
+ 'clientId',
+ 'cookieName',
+ 'cookieDomain',
+ 'cookieExpires',
+ 'legacyCookieDomain',
+ 'legacyHistoryImport',
+ 'sampleRate',
+ 'siteSpeedSampleRate',
+ 'storage',
+ 'useAmpClientId',
+ );
+
+ if ($name == 'name') {
+ return t('Create only field name %name is a disallowed field name. Changing the Tracker Name is currently not supported.', array('%name' => $name));
+ }
+ if ($name == 'allowLinker') {
+ return t('Create only field name %name is a disallowed field name. Please select Multiple top-level domains under What are you tracking to enable cross domain tracking.', array('%name' => $name));
+ }
+ if ($name == 'userId') {
+ return t('Create only field name %name is a disallowed field name. Please enable Track User ID under Tracking scope > Users.', array('%name' => $name));
+ }
+ if (!in_array($name, $create_only_fields)) {
+ return t('Create only field name %name is an unknown field name. Field names are case sensitive. Please see create only fields documentation for supported field names.', array('%name' => $name, '@url' => 'https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#create'));
+ }
+}
+
+/**
+ * Checks whether a field value is valid.
+ *
+ * @param string $value
+ * The option value entered by the user.
+ *
+ * @return string
+ * The error message if the specified value is invalid, NULL otherwise.
+ */
+function _googleanalytics_validate_create_field_value($value) {
+ if (!is_bool($value) && !drupal_strlen($value)) {
+ return t('A create only field requires a value.');
+ }
+ if (drupal_strlen($value) > 255) {
+ return t('The value of a create only field must be a string at most 255 characters long.');
+ }
+}
+
+/**
+ * Generates a string representation of an array.
+ *
+ * This string format is suitable for edition in a textarea.
+ *
+ * @param array $values
+ * An array of values, where array keys are values and array values are
+ * labels.
+ *
+ * @return string
+ * The string representation of the $values array:
+ * - Values are separated by a carriage return.
+ * - Each value is in the format "name|value" or "value".
+ */
+function _googleanalytics_get_name_value_string($values) {
+ $lines = array();
+ foreach ($values as $name => $value) {
+ // Convert data types.
+ // @todo: #2251377: Json utility class serializes boolean values to incorrect data type
+ if (is_bool($value)) {
+ $value = ($value) ? 'true' : 'false';
+ }
+
+ $lines[] = "$name|$value";
+ }
+ return implode("\n", $lines);
+}
+
+/**
+ * Prepare form data types for Json conversion.
+ *
+ * @param array $values
+ * Array of name/value pairs.
+ *
+ * @return array
+ * Array of name/value pairs with casted data types.
+ */
+function _googleanalytics_convert_form_value_data_types($values) {
+
+ foreach ($values as $name => $value) {
+ // Convert data types.
+ // @todo: #2251377: Json utility class serializes boolean values to incorrect data type
+ $match = drupal_strtolower($value);
+ if ($match == 'true') {
+ $value = TRUE;
+ }
+ elseif ($match == 'false') {
+ $value = FALSE;
+ }
+
+ // Convert other known fields.
+ // @todo: #2251343: Json utility class serializes numeric values to incorrect data type
+ switch ($name) {
+ case 'sampleRate':
+ // Float
+ settype($value, 'float');
+ break;
+
+ case 'siteSpeedSampleRate':
+ case 'cookieExpires':
+ // Integer
+ settype($value, 'integer');
+ break;
+ }
+
+ $values[$name] = $value;
+ }
+
+ return $values;
+}
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.js b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.js
index 35da84e..c81470d 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.js
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.admin.js
@@ -65,6 +65,15 @@ Drupal.behaviors.trackingSettingsSummary = {
if ($('input#edit-googleanalytics-trackfiles', context).is(':checked')) {
vals.push(Drupal.t('Downloads'));
}
+ if ($('input#edit-googleanalytics-trackcolorbox', context).is(':checked')) {
+ vals.push(Drupal.t('Colorbox'));
+ }
+ if ($('input#edit-googleanalytics-tracklinkid', context).is(':checked')) {
+ vals.push(Drupal.t('Link attribution'));
+ }
+ if ($('input#edit-googleanalytics-trackurlfragments', context).is(':checked')) {
+ vals.push(Drupal.t('URL fragments'));
+ }
if (!vals.length) {
return Drupal.t('Not tracked');
}
@@ -91,7 +100,7 @@ Drupal.behaviors.trackingSettingsSummary = {
vals.push(Drupal.t('AdSense ads'));
}
if ($('input#edit-googleanalytics-trackdoubleclick', context).is(':checked')) {
- vals.push(Drupal.t('DoubleClick data'));
+ vals.push(Drupal.t('Display features'));
}
if (!vals.length) {
return Drupal.t('Not tracked');
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.debug.js b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.debug.js
new file mode 100644
index 0000000..7186230
--- /dev/null
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.debug.js
@@ -0,0 +1,213 @@
+(function ($) {
+
+Drupal.googleanalytics = {};
+
+$(document).ready(function() {
+
+ // Attach mousedown, keyup, touchstart events to document only and catch
+ // clicks on all elements.
+ $(document.body).bind("mousedown keyup touchstart", function(event) {
+ console.group("Running Google Analytics for Drupal.");
+ console.info("Event '%s' has been detected.", event.type);
+
+ // Catch the closest surrounding link of a clicked element.
+ $(event.target).closest("a,area").each(function() {
+ console.info("Closest element '%o' has been found. URL '%s' extracted.", this, this.href);
+
+ // Is the clicked URL internal?
+ if (Drupal.googleanalytics.isInternal(this.href)) {
+ // Skip 'click' tracking, if custom tracking events are bound.
+ if ($(this).is('.colorbox') && (Drupal.settings.googleanalytics.trackColorbox)) {
+ // Do nothing here. The custom event will handle all tracking.
+ console.info("Click on .colorbox item has been detected.");
+ }
+ // Is download tracking activated and the file extension configured for download tracking?
+ else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) {
+ // Download link clicked.
+ console.info("Download url '%s' has been found. Tracked download as extension '%s'.", Drupal.googleanalytics.getPageUrl(this.href), Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase());
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Downloads",
+ "eventAction": Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(),
+ "eventLabel": Drupal.googleanalytics.getPageUrl(this.href),
+ "transport": "beacon"
+ });
+ }
+ else if (Drupal.googleanalytics.isInternalSpecial(this.href)) {
+ // Keep the internal URL for Google Analytics website overlay intact.
+ console.info("Click on internal special link '%s' has been tracked.", Drupal.googleanalytics.getPageUrl(this.href));
+ ga("send", {
+ "hitType": "pageview",
+ "page": Drupal.googleanalytics.getPageUrl(this.href),
+ "transport": "beacon"
+ });
+ }
+ else {
+ // e.g. anchor in same page or other internal page link
+ console.info("Click on internal link '%s' detected, but not tracked by click.", this.href);
+ }
+ }
+ else {
+ if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
+ // Mailto link clicked.
+ console.info("Click on e-mail '%s' has been tracked.", this.href.substring(7));
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Mails",
+ "eventAction": "Click",
+ "eventLabel": this.href.substring(7),
+ "transport": "beacon"
+ });
+ }
+ else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) {
+ if (Drupal.settings.googleanalytics.trackDomainMode !== 2 || (Drupal.settings.googleanalytics.trackDomainMode === 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) {
+ // External link clicked / No top-level cross domain clicked.
+ console.info("Outbound link '%s' has been tracked.", this.href);
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Outbound links",
+ "eventAction": "Click",
+ "eventLabel": this.href,
+ "transport": "beacon"
+ });
+ }
+ else {
+ console.info("Internal link '%s' clicked, not tracked.", this.href);
+ }
+ }
+ }
+ });
+
+ console.groupEnd();
+ });
+
+ // Track hash changes as unique pageviews, if this option has been enabled.
+ if (Drupal.settings.googleanalytics.trackUrlFragments) {
+ window.onhashchange = function() {
+ console.info("Track URL '%s' as pageview. Hash '%s' has changed.", location.pathname + location.search + location.hash, location.hash);
+ ga("send", {
+ "hitType": "pageview",
+ "page": location.pathname + location.search + location.hash
+ });
+ };
+ }
+
+ // Colorbox: This event triggers when the transition has completed and the
+ // newly loaded content has been revealed.
+ if (Drupal.settings.googleanalytics.trackColorbox) {
+ $(document).bind("cbox_complete", function () {
+ var href = $.colorbox.element().attr("href");
+ if (href) {
+ console.info("Colorbox transition to url '%s' has been tracked.", Drupal.googleanalytics.getPageUrl(href));
+ ga("send", {
+ "hitType": "pageview",
+ "page": Drupal.googleanalytics.getPageUrl(href)
+ });
+ }
+ });
+ }
+
+});
+
+/**
+ * Check whether the hostname is part of the cross domains or not.
+ *
+ * @param string hostname
+ * The hostname of the clicked URL.
+ * @param array crossDomains
+ * All cross domain hostnames as JS array.
+ *
+ * @return boolean
+ */
+Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) {
+ /**
+ * jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is
+ * `null` or `undefined`, https://bugs.jquery.com/ticket/10076,
+ * https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174
+ *
+ * @todo: Remove/Refactor in D8
+ */
+ if (!crossDomains) {
+ return false;
+ }
+ else {
+ return $.inArray(hostname, crossDomains) > -1 ? true : false;
+ }
+};
+
+/**
+ * Check whether this is a download URL or not.
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return boolean
+ */
+Drupal.googleanalytics.isDownload = function (url) {
+ var isDownload = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i");
+ return isDownload.test(url);
+};
+
+/**
+ * Check whether this is an absolute internal URL or not.
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return boolean
+ */
+Drupal.googleanalytics.isInternal = function (url) {
+ var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i");
+ return isInternal.test(url);
+};
+
+/**
+ * Check whether this is a special URL or not.
+ *
+ * URL types:
+ * - gotwo.module /go/* links.
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return boolean
+ */
+Drupal.googleanalytics.isInternalSpecial = function (url) {
+ var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
+ return isInternalSpecial.test(url);
+};
+
+/**
+ * Extract the relative internal URL from an absolute internal URL.
+ *
+ * Examples:
+ * - https://mydomain.com/node/1 -> /node/1
+ * - https://example.com/foo/bar -> https://example.com/foo/bar
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return string
+ * Internal website URL
+ */
+Drupal.googleanalytics.getPageUrl = function (url) {
+ var extractInternalUrl = new RegExp("^(https?):\/\/" + window.location.host, "i");
+ return url.replace(extractInternalUrl, '');
+};
+
+/**
+ * Extract the download file extension from the URL.
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return string
+ * The file extension of the passed url. e.g. "zip", "txt"
+ */
+Drupal.googleanalytics.getDownloadExtension = function (url) {
+ var extractDownloadextension = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i");
+ var extension = extractDownloadextension.exec(url);
+ return (extension === null) ? '' : extension[1];
+};
+
+})(jQuery);
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.info b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.info
index fea44ca..591816a 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.info
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.info
@@ -4,10 +4,9 @@ core = 7.x
package = Statistics
configure = admin/config/system/googleanalytics
files[] = googleanalytics.test
-
-; Information added by drupal.org packaging script on 2012-11-01
-version = "7.x-1.3"
+test_dependencies[] = token
+; Information added by Drupal.org packaging script on 2019-01-31
+version = "7.x-2.6"
core = "7.x"
project = "google_analytics"
-datestamp = "1351810914"
-
+datestamp = "1548968597"
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.install b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.install
index b3841cb..08b4e05 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.install
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.install
@@ -5,52 +5,46 @@
* Installation file for Google Analytics module.
*/
-/**
- * Implements hook_install().
- */
-function googleanalytics_install() {
- // By German laws it's always best to enable the anonymizing of IP addresses.
- // NOTE: If this is also an important default setting in other countries, please let us know!
- $countries = array(
- 'DE',
- );
- if (in_array(variable_get('site_default_country', ''), $countries)) {
- variable_set('googleanalytics_tracker_anonymizeip', 1);
- }
-}
-
/**
* Implements hook_uninstall().
*/
function googleanalytics_uninstall() {
variable_del('googleanalytics_account');
+ variable_del('googleanalytics_premium');
variable_del('googleanalytics_cache');
+ variable_del('googleanalytics_codesnippet_create');
variable_del('googleanalytics_codesnippet_before');
variable_del('googleanalytics_codesnippet_after');
variable_del('googleanalytics_cross_domains');
variable_del('googleanalytics_custom');
- variable_del('googleanalytics_custom_var');
+ variable_del('googleanalytics_custom_dimension');
+ variable_del('googleanalytics_custom_metric');
+ variable_del('googleanalytics_debug');
variable_del('googleanalytics_domain_mode');
- variable_del('googleanalytics_js_scope');
variable_del('googleanalytics_last_cache');
variable_del('googleanalytics_pages');
variable_del('googleanalytics_roles');
variable_del('googleanalytics_site_search');
variable_del('googleanalytics_trackadsense');
+ variable_del('googleanalytics_trackcolorbox');
variable_del('googleanalytics_trackdoubleclick');
variable_del('googleanalytics_tracker_anonymizeip');
variable_del('googleanalytics_trackfiles');
variable_del('googleanalytics_trackfiles_extensions');
+ variable_del('googleanalytics_tracklinkid');
+ variable_del('googleanalytics_trackurlfragments');
+ variable_del('googleanalytics_trackuserid');
variable_del('googleanalytics_trackmailto');
+ variable_del('googleanalytics_trackmessages');
variable_del('googleanalytics_trackoutbound');
variable_del('googleanalytics_translation_set');
variable_del('googleanalytics_visibility_pages');
variable_del('googleanalytics_visibility_roles');
+ variable_del('googleanalytics_privacy_donottrack');
- // Remove backup variables if exist. Remove this code in D8.
- variable_del('googleanalytics_codesnippet_after_backup_6300');
- variable_del('googleanalytics_codesnippet_before_backup_6300');
- variable_del('googleanalytics_segmentation');
+ // Remove backup variables if they exist. Remove this code in D8.
+ variable_del('googleanalytics_codesnippet_after_backup_7200');
+ variable_del('googleanalytics_codesnippet_before_backup_7200');
}
/**
@@ -71,21 +65,32 @@ function googleanalytics_requirements($phase) {
if ($phase == 'runtime') {
// Raise warning if Google user account has not been set yet.
- if (!preg_match('/^UA-\d{4,}-\d+$/', variable_get('googleanalytics_account', 'UA-'))) {
- $requirements['googleanalytics'] = array(
+ if (!preg_match('/^UA-\d+-\d+$/', variable_get('googleanalytics_account', 'UA-'))) {
+ $requirements['googleanalytics_account'] = array(
'title' => $t('Google Analytics module'),
'description' => $t('Google Analytics module has not been configured yet. Please configure its settings from the Google Analytics settings page.', array('@url' => url('admin/config/system/googleanalytics'))),
'severity' => REQUIREMENT_WARNING,
'value' => $t('Not configured'),
);
}
+
+ // Raise warning if debugging is enabled.
+ if (variable_get('googleanalytics_debug', 0)) {
+ $requirements['google_analytics_debugging'] = array(
+ 'title' => $t('Google Analytics module'),
+ 'description' => $t('Google Analytics module has debugging enabled. Please disable debugging setting in production sites from the Google Analytics settings page.', array('@url' => url('admin/config/system/googleanalytics'))),
+ 'severity' => REQUIREMENT_WARNING,
+ 'value' => $t('Debugging enabled'),
+ );
+ }
}
return $requirements;
}
/**
- * Upgrade old extension variable to new and use old name as enabled/disabled flag.
+ * Upgrade old extension variable to new and use old name as enabled/disabled
+ * flag.
*/
function googleanalytics_update_6000() {
variable_set('googleanalytics_trackfiles_extensions', variable_get('googleanalytics_trackfiles', '7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip'));
@@ -98,7 +103,8 @@ function googleanalytics_update_6000() {
function googleanalytics_update_6001() {
variable_set('googleanalytics_visibility', 0);
- // Remove tracking from all administrative pages, see http://drupal.org/node/34970.
+ // Remove tracking from all administrative pages, see:
+ // https://drupal.org/node/34970.
$pages = array(
'admin*',
'user*',
@@ -111,11 +117,12 @@ function googleanalytics_update_6001() {
}
/**
- * Upgrade role settings and per user tracking settings
- * of "User 1" and remove outdated tracking variables.
+ * Upgrade role settings and per user tracking settings of "User 1" and remove
+ * outdated tracking variables.
*/
function googleanalytics_update_6002() {
- // Upgrade enabled/disabled roles to new logic (correct for upgrades from 5.x-1.4 and 6.x-1.0).
+ // Upgrade enabled/disabled roles to new logic (correct for upgrades from
+ // 5.x-1.4 and 6.x-1.0).
$roles = array();
$messages = array();
foreach (user_roles() as $rid => $name) {
@@ -134,7 +141,7 @@ function googleanalytics_update_6002() {
if (!$track_user1 = variable_get('googleanalytics_track__user1', 1)) {
variable_set('googleanalytics_custom', 1);
- // Load user 1 object, set appropriate value and save new user settings back.
+ // Load user 1 object, set appropriate value and save new user settings.
$account = user_load(1);
$account = user_save($account, array('data' => array('googleanalytics' => array('custom' => 0))), 'account');
$messages[] = t('Disabled user specific page tracking for site administrator.');
@@ -149,11 +156,11 @@ function googleanalytics_update_6002() {
}
/**
- * #262468: Clear menu cache to solve stale menu data in 5.x-1.5 and 6.x-1.1
+ * #262468: Clear menu cache to solve stale menu data in 5.x-1.5 and 6.x-1.1.
*/
function googleanalytics_update_6003() {
menu_rebuild();
- return t('Menu has been rebuild.');
+ return t('Menu has been rebuilt.');
}
/**
@@ -228,8 +235,9 @@ function googleanalytics_update_6006() {
/**
* Remove "User identifier" and "User name" from segmentation fields.
*
- * This is a data protection and privacy law change. For more information see Google Analytics
- * terms of use section 8.1 (http://www.google.com/analytics/en-GB/tos.html).
+ * This is a data protection and privacy law change. For more information see
+ * Google Analytics terms of use section 8.1:
+ * https://www.google.com/analytics/en-GB/tos.html
*/
function googleanalytics_update_6007() {
$profile_fields = variable_get('googleanalytics_segmentation', array());
@@ -290,15 +298,15 @@ function googleanalytics_update_6300() {
$messages[] = t('Upgraded custom "before" code snippet.');
}
- // Upgrade of AFTER code snippet.
- // We cannot update this code snippet automatically. Show message that the upgrade has been skipped.
+ // Upgrade of AFTER code snippet. We cannot update this code snippet
+ // automatically. Show message that the upgrade has been skipped.
$code_after = variable_get('googleanalytics_codesnippet_after', '');
if (!empty($code_after)) {
drupal_set_message(Database::getConnection()->prefixTables("Automatic upgrade of Google Analytics custom 'after' code snippet has been skipped. Backup of previous code snippet has been saved in database table '{variable}' as 'googleanalytics_codesnippet_after_backup_6300'. You need to manually upgrade the custom 'after' code snippet."), 'error');
$messages[] = t('Skipped custom "after" code snippet.');
}
- return empty($messages) ? t('No custom code snipped found. Nothing to do.') : implode(' ', $messages);
+ return empty($messages) ? t('No custom code snippet found. Nothing to do.') : implode(' ', $messages);
}
/**
@@ -353,18 +361,20 @@ function googleanalytics_update_7002() {
$googleanalytics_custom_vars['slots'][1]['slot'] = 1;
$googleanalytics_custom_vars['slots'][1]['name'] = 'User roles';
$googleanalytics_custom_vars['slots'][1]['value'] = '[current-user:role-names]';
- $googleanalytics_custom_vars['slots'][1]['scope'] = 1; // Sets the scope to visitor-level.
+ // Sets the scope to visitor-level.
+ $googleanalytics_custom_vars['slots'][1]['scope'] = 1;
variable_set('googleanalytics_custom_var', $googleanalytics_custom_vars);
- return t('The deprecated profile segmentation setting for "User roles" has been added to custom variables. You need to deselect all selected profile fields in Google Analytics settings and upgrade other profile fields manually or you may loose tracking data in future! See Google Analytics Custom Variables for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
+ return t('The deprecated profile segmentation setting for "User roles" has been added to custom variables. You need to deselect all selected profile fields in Google Analytics settings and upgrade other profile fields manually or you may lose tracking data in future! See Google Analytics Custom Variables for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
}
else {
- return t('You need to deselect all selected profile fields in Google Analytics settings and upgrade other profile fields manually or you may loose tracking data in future! See Google Analytics Custom Variables for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
+ return t('You need to deselect all selected profile fields in Google Analytics settings and upgrade other profile fields manually or you may lose tracking data in future! See Google Analytics Custom Variables for more information.', array('@customvar' => 'https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables', '@admin' => url('admin/config/system/googleanalytics')));
}
}
/**
- * Rename googleanalytics_trackoutgoing variable to googleanalytics_trackoutbound.
+ * Rename googleanalytics_trackoutgoing variable to
+ * googleanalytics_trackoutbound.
*/
function googleanalytics_update_7003() {
variable_set('googleanalytics_trackoutbound', variable_get('googleanalytics_trackoutgoing', 1));
@@ -374,7 +384,8 @@ function googleanalytics_update_7003() {
}
/**
- * Rename googleanalytics_visibility variable to googleanalytics_visibility_pages for consistency.
+ * Rename googleanalytics_visibility variable to
+ * googleanalytics_visibility_pages for consistency.
*/
function googleanalytics_update_7004() {
variable_set('googleanalytics_visibility_pages', variable_get('googleanalytics_visibility', 1));
@@ -398,7 +409,7 @@ function googleanalytics_update_7005() {
$diff = array_diff($pages, preg_split('/(\r\n?|\n)/', variable_get('googleanalytics_pages', implode("\n", $pages))));
if (empty($diff)) {
- // No diff to previous settings found. Update with new settings.
+ // No difference to previous settings found. Update with new settings.
$pages = array(
'admin',
'admin/*',
@@ -425,10 +436,113 @@ function googleanalytics_update_7006() {
}
/**
-* Delete obsolete googleanalytics_trackpageloadtime variable.
-*/
+ * Delete obsolete googleanalytics_trackpageloadtime variable.
+ */
function googleanalytics_update_7007() {
variable_del('googleanalytics_trackpageloadtime');
return t('Deleted obsolete googleanalytics_trackpageloadtime variable.');
}
+
+/**
+ * Delete custom ga.js code snippets to prevent malfunctions in new Universal
+ * Analytics tracker. A backup of your snippets will be created.
+ */
+function googleanalytics_update_7200() {
+ $messages = array();
+
+ // ga.js code will cause the tracker to break. Remove custom code snippets.
+ $googleanalytics_codesnippet_before = variable_get('googleanalytics_codesnippet_before', '');
+ if (!empty($googleanalytics_codesnippet_before) && stristr($googleanalytics_codesnippet_before, '_gaq.push(')) {
+ variable_set('googleanalytics_codesnippet_before_backup_7200', $googleanalytics_codesnippet_before);
+ variable_del('googleanalytics_codesnippet_before');
+ drupal_set_message(Database::getConnection()->prefixTables("A backup of your previous Google Analytics code snippet (ga.js) has been saved in database table '{variable}' as 'googleanalytics_codesnippet_before_backup_7200'. You need to manually upgrade the custom 'before' code snippet to analytics.js API."), 'warning');
+ $messages[] = t('Manual upgrade of custom "before" code snippet from ja.js to analytics.js API is required.');
+ }
+
+ $googleanalytics_codesnippet_after = variable_get('googleanalytics_codesnippet_after', '');
+ if (!empty($googleanalytics_codesnippet_after) && stristr($googleanalytics_codesnippet_after, '_gaq.push(')) {
+ variable_set('googleanalytics_codesnippet_after_backup_7200', $googleanalytics_codesnippet_after);
+ variable_del('googleanalytics_codesnippet_after');
+ drupal_set_message(Database::getConnection()->prefixTables("A backup of your previous Google Analytics code snippet (ga.js) has been saved in database table '{variable}' as 'googleanalytics_codesnippet_after_backup_7200'. You need to manually upgrade the custom 'after' code snippet to analytics.js API."), 'warning');
+ $messages[] = t('Manual upgrade of custom "after" code snippet from ja.js to analytics.js API is required.');
+ }
+
+ return empty($messages) ? t('No custom code snippet found. Nothing to do.') : implode(' ', $messages);
+}
+
+/**
+ * Delete obsolete custom variables. Custom variables are now custom dimensions
+ * and metrics.
+ */
+function googleanalytics_update_7201() {
+ variable_del('googleanalytics_custom_var');
+
+ return t('Deleted obsolete custom variables. Custom variables are now custom dimensions and metrics and you need to manually configure them!');
+}
+
+/**
+ * Delete obsolete JavaScript scope variable.
+ */
+function googleanalytics_update_7202() {
+ // Remove obsolete scope variable.
+ variable_del('googleanalytics_js_scope');
+
+ return t('Removed obsolete JavaScript scope variable.');
+}
+
+/**
+ * Flatten the metrics and dimensions arrays.
+ */
+function googleanalytics_update_7203() {
+ $googleanalytics_custom_dimension = variable_get('googleanalytics_custom_dimension', array());
+ if (isset($googleanalytics_custom_dimension['indexes'])) {
+ foreach ($googleanalytics_custom_dimension['indexes'] as $dimension) {
+ $googleanalytics_custom_dimension['indexes'][$dimension['index']]['value'] = trim($dimension['value']);
+ // Remove empty values from the array.
+ if (!drupal_strlen($googleanalytics_custom_dimension['indexes'][$dimension['index']]['value'])) {
+ unset($googleanalytics_custom_dimension['indexes'][$dimension['index']]);
+ }
+ }
+ variable_set('googleanalytics_custom_dimension', $googleanalytics_custom_dimension['indexes']);
+ }
+ $googleanalytics_custom_metric = variable_get('googleanalytics_custom_metric', array());
+ if (isset($googleanalytics_custom_metric['indexes'])) {
+ foreach ($googleanalytics_custom_metric['indexes'] as $dimension) {
+ $googleanalytics_custom_metric['indexes'][$dimension['index']]['value'] = trim($dimension['value']);
+ // Remove empty values from the array.
+ if (!drupal_strlen($googleanalytics_custom_metric['indexes'][$dimension['index']]['value'])) {
+ unset($googleanalytics_custom_metric['indexes'][$dimension['index']]);
+ }
+ }
+ variable_set('googleanalytics_custom_metric', $googleanalytics_custom_metric['indexes']);
+ }
+
+ return t('Saved custom dimensions and metrics.');
+}
+
+/**
+ * Remove obsolete backup variables.
+ */
+function googleanalytics_update_7204() {
+ variable_del('googleanalytics_segmentation');
+ variable_del('googleanalytics_codesnippet_after_backup_6300');
+ variable_del('googleanalytics_codesnippet_before_backup_6300');
+ variable_del('googleanalytics_codesnippet_after_backup_6400');
+ variable_del('googleanalytics_codesnippet_before_backup_6400');
+
+ return t('Removed obsolete backup variables.');
+}
+
+/**
+ * Update list of default file extensions.
+ */
+function googleanalytics_update_7205() {
+ if (variable_get('googleanalytics_trackfiles_extensions', '') == '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip') {
+ variable_set('googleanalytics_trackfiles_extensions', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip');
+ return t('The default extensions for download tracking have been updated.');
+ }
+ else {
+ return t('Custom extensions for download tracking setting found. Update skipped!');
+ }
+}
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.js b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.js
index 58be03d..5ba42ca 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.js
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.js
@@ -1,66 +1,93 @@
(function ($) {
+Drupal.googleanalytics = {};
+
$(document).ready(function() {
- // Expression to check for absolute internal links.
- var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i");
+ // Attach mousedown, keyup, touchstart events to document only and catch
+ // clicks on all elements.
+ $(document.body).bind("mousedown keyup touchstart", function(event) {
- // Attach onclick event to document only and catch clicks on all elements.
- $(document.body).click(function(event) {
// Catch the closest surrounding link of a clicked element.
$(event.target).closest("a,area").each(function() {
- var ga = Drupal.settings.googleanalytics;
- // Expression to check for special links like gotwo.module /go/* links.
- var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
- // Expression to check for download links.
- var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i");
-
// Is the clicked URL internal?
- if (isInternal.test(this.href)) {
+ if (Drupal.googleanalytics.isInternal(this.href)) {
// Skip 'click' tracking, if custom tracking events are bound.
- if ($(this).is('.colorbox')) {
+ if ($(this).is('.colorbox') && (Drupal.settings.googleanalytics.trackColorbox)) {
// Do nothing here. The custom event will handle all tracking.
+ //console.info("Click on .colorbox item has been detected.");
}
// Is download tracking activated and the file extension configured for download tracking?
- else if (ga.trackDownload && isDownload.test(this.href)) {
+ else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) {
// Download link clicked.
- var extension = isDownload.exec(this.href);
- _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]);
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Downloads",
+ "eventAction": Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(),
+ "eventLabel": Drupal.googleanalytics.getPageUrl(this.href),
+ "transport": "beacon"
+ });
}
- else if (isInternalSpecial.test(this.href)) {
+ else if (Drupal.googleanalytics.isInternalSpecial(this.href)) {
// Keep the internal URL for Google Analytics website overlay intact.
- _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]);
+ ga("send", {
+ "hitType": "pageview",
+ "page": Drupal.googleanalytics.getPageUrl(this.href),
+ "transport": "beacon"
+ });
}
}
else {
- if (ga.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
+ if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
// Mailto link clicked.
- _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]);
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Mails",
+ "eventAction": "Click",
+ "eventLabel": this.href.substring(7),
+ "transport": "beacon"
+ });
}
- else if (ga.trackOutbound && this.href.match(/^\w+:\/\//i)) {
- if (ga.trackDomainMode == 2 && isCrossDomain($(this).attr('hostname'), ga.trackCrossDomains)) {
- // Top-level cross domain clicked. document.location is handled by _link internally.
- event.preventDefault();
- _gaq.push(["_link", this.href]);
- }
- else {
- // External link clicked.
- _gaq.push(["_trackEvent", "Outbound links", "Click", this.href]);
+ else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) {
+ if (Drupal.settings.googleanalytics.trackDomainMode !== 2 || (Drupal.settings.googleanalytics.trackDomainMode === 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) {
+ // External link clicked / No top-level cross domain clicked.
+ ga("send", {
+ "hitType": "event",
+ "eventCategory": "Outbound links",
+ "eventAction": "Click",
+ "eventLabel": this.href,
+ "transport": "beacon"
+ });
}
}
}
});
});
+ // Track hash changes as unique pageviews, if this option has been enabled.
+ if (Drupal.settings.googleanalytics.trackUrlFragments) {
+ window.onhashchange = function() {
+ ga("send", {
+ "hitType": "pageview",
+ "page": location.pathname + location.search + location.hash
+ });
+ };
+ }
+
// Colorbox: This event triggers when the transition has completed and the
// newly loaded content has been revealed.
- $(document).bind("cbox_complete", function() {
- var href = $.colorbox.element().attr("href");
- if (href) {
- _gaq.push(["_trackPageview", href.replace(isInternal, '')]);
- }
- });
+ if (Drupal.settings.googleanalytics.trackColorbox) {
+ $(document).bind("cbox_complete", function () {
+ var href = $.colorbox.element().attr("href");
+ if (href) {
+ ga("send", {
+ "hitType": "pageview",
+ "page": Drupal.googleanalytics.getPageUrl(href)
+ });
+ }
+ });
+ }
});
@@ -74,10 +101,10 @@ $(document).ready(function() {
*
* @return boolean
*/
-function isCrossDomain(hostname, crossDomains) {
+Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) {
/**
* jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is
- * `null` or `undefined`, http://bugs.jquery.com/ticket/10076,
+ * `null` or `undefined`, https://bugs.jquery.com/ticket/10076,
* https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174
*
* @todo: Remove/Refactor in D8
@@ -88,6 +115,81 @@ function isCrossDomain(hostname, crossDomains) {
else {
return $.inArray(hostname, crossDomains) > -1 ? true : false;
}
-}
+};
+
+/**
+ * Check whether this is a download URL or not.
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return boolean
+ */
+Drupal.googleanalytics.isDownload = function (url) {
+ var isDownload = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i");
+ return isDownload.test(url);
+};
+
+/**
+ * Check whether this is an absolute internal URL or not.
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return boolean
+ */
+Drupal.googleanalytics.isInternal = function (url) {
+ var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i");
+ return isInternal.test(url);
+};
+
+/**
+ * Check whether this is a special URL or not.
+ *
+ * URL types:
+ * - gotwo.module /go/* links.
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return boolean
+ */
+Drupal.googleanalytics.isInternalSpecial = function (url) {
+ var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
+ return isInternalSpecial.test(url);
+};
+
+/**
+ * Extract the relative internal URL from an absolute internal URL.
+ *
+ * Examples:
+ * - https://mydomain.com/node/1 -> /node/1
+ * - https://example.com/foo/bar -> https://example.com/foo/bar
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return string
+ * Internal website URL
+ */
+Drupal.googleanalytics.getPageUrl = function (url) {
+ var extractInternalUrl = new RegExp("^(https?):\/\/" + window.location.host, "i");
+ return url.replace(extractInternalUrl, '');
+};
+
+/**
+ * Extract the download file extension from the URL.
+ *
+ * @param string url
+ * The web url to check.
+ *
+ * @return string
+ * The file extension of the passed url. e.g. "zip", "txt"
+ */
+Drupal.googleanalytics.getDownloadExtension = function (url) {
+ var extractDownloadextension = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i");
+ var extension = extractDownloadextension.exec(url);
+ return (extension === null) ? '' : extension[1];
+};
})(jQuery);
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.module b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.module
index 9efae87..0026703 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.module
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.module
@@ -1,26 +1,42 @@
+ * Adds the required Javascript to all your Drupal pages to allow tracking by
+ * the Google Analytics statistics package.
+ *
+ * @author: Alexander Hass
*/
-define('GOOGLEANALYTICS_TRACKFILES_EXTENSIONS', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip');
+/**
+ * Define the default file extension list that should be tracked as download.
+ */
+define('GOOGLEANALYTICS_TRACKFILES_EXTENSIONS', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip');
-// Remove tracking from all administrative pages, see http://drupal.org/node/34970.
+/**
+ * Define default path exclusion list to remove tracking from admin pages,
+ * see https://drupal.org/node/34970 for more information.
+ */
define('GOOGLEANALYTICS_PAGES', "admin\nadmin/*\nbatch\nnode/add*\nnode/*/*\nuser/*/*");
+/**
+ * Advertise the supported google analytics api details.
+ */
+function googleanalytics_api() {
+ return array(
+ 'api' => 'analytics.js',
+ );
+}
+
/**
* Implements hook_help().
*/
function googleanalytics_help($path, $arg) {
switch ($path) {
case 'admin/config/system/googleanalytics':
- return t('Google Analytics is a free (registration required) website traffic and marketing effectiveness service.', array('@ga_url' => 'http://www.google.com/analytics/'));
+ return t('Google Analytics is a free (registration required) website traffic and marketing effectiveness service.', array('@ga_url' => 'https://marketingplatform.google.com/about/analytics/'));
}
}
@@ -53,6 +69,11 @@ function googleanalytics_permission() {
'description' => t('Enter PHP code in the field for tracking visibility settings.'),
'restrict access' => TRUE,
),
+ 'add JS snippets for google analytics' => array(
+ 'title' => t('Add JavaScript snippets'),
+ 'description' => 'Enter JavaScript code snippets for advanced Google Analytics functionality.',
+ 'restrict access' => TRUE,
+ ),
);
}
@@ -77,7 +98,7 @@ function googleanalytics_menu() {
* Implements hook_page_alter() to insert JavaScript to the appropriate scope/region of the page.
*/
function googleanalytics_page_alter(&$page) {
- global $user;
+ global $base_path, $user;
$id = variable_get('googleanalytics_account', '');
@@ -88,19 +109,14 @@ function googleanalytics_page_alter(&$page) {
'404 Not Found',
);
- // 1. Check if the GA account number has a value.
+ // 1. Check if the GA account number has a valid value.
// 2. Track page views based on visibility value.
// 3. Check if we should track the currently active user's role.
// 4. Ignore pages visibility filter for 404 or 403 status codes.
- if (!empty($id) && (_googleanalytics_visibility_pages() || in_array($status, $trackable_status_codes)) && _googleanalytics_visibility_user($user)) {
+ if (preg_match('/^UA-\d+-\d+$/', $id) && (_googleanalytics_visibility_pages() || in_array($status, $trackable_status_codes)) && _googleanalytics_visibility_user($user)) {
- // We allow different scopes. Default to 'header' but allow user to override if they really need to.
- $scope = variable_get('googleanalytics_js_scope', 'header');
-
- if (variable_get('googleanalytics_trackadsense', FALSE)) {
- // Custom tracking. Prepend before all other JavaScript.
- drupal_add_js('window.google_analytics_uacct = ' . drupal_json_encode($id) . ';', array('type' => 'inline', 'group' => JS_LIBRARY-1));
- }
+ $debug = variable_get('googleanalytics_debug', 0);
+ $url_custom = '';
// Add link tracking.
$link_settings = array();
@@ -114,16 +130,32 @@ function googleanalytics_page_alter(&$page) {
$link_settings['trackDownload'] = $track_download;
$link_settings['trackDownloadExtensions'] = $trackfiles_extensions;
}
+ if (module_exists('colorbox') && ($track_colorbox = variable_get('googleanalytics_trackcolorbox', 1))) {
+ $link_settings['trackColorbox'] = $track_colorbox;
+ }
if ($track_domain_mode = variable_get('googleanalytics_domain_mode', 0)) {
- $link_settings['trackDomainMode'] = $track_domain_mode;
+ $link_settings['trackDomainMode'] = (int) $track_domain_mode;
}
if ($track_cross_domains = variable_get('googleanalytics_cross_domains', '')) {
$link_settings['trackCrossDomains'] = preg_split('/(\r\n?|\n)/', $track_cross_domains);
}
+ if ($track_url_fragments = variable_get('googleanalytics_trackurlfragments', 0)) {
+ $link_settings['trackUrlFragments'] = $track_url_fragments;
+ $url_custom = 'location.pathname + location.search + location.hash';
+ }
if (!empty($link_settings)) {
drupal_add_js(array('googleanalytics' => $link_settings), 'setting');
- drupal_add_js(drupal_get_path('module', 'googleanalytics') . '/googleanalytics.js');
+
+ // Add debugging code.
+ if ($debug) {
+ drupal_add_js(drupal_get_path('module', 'googleanalytics') . '/googleanalytics.debug.js');
+ // Add the JS test in development to the page.
+ //drupal_add_js(drupal_get_path('module', 'googleanalytics') . '/googleanalytics.test.js');
+ }
+ else {
+ drupal_add_js(drupal_get_path('module', 'googleanalytics') . '/googleanalytics.js');
+ }
}
// Add messages tracking.
@@ -140,15 +172,17 @@ function googleanalytics_page_alter(&$page) {
// Track only the selected message types.
if (in_array($type, $message_types)) {
foreach ($messages as $message) {
- $message_events .= '_gaq.push(["_trackEvent", ' . drupal_json_encode(t('Messages')) . ', ' . drupal_json_encode($status_heading[$type]) . ', ' . drupal_json_encode(strip_tags($message)) . ']);';
+ // @todo: Track as exceptions?
+ $message_events .= 'ga("send", "event", ' . drupal_json_encode(t('Messages')) . ', ' . drupal_json_encode($status_heading[$type]) . ', ' . drupal_json_encode(strip_tags($message)) . ');';
}
}
}
}
// Site search tracking support.
- $url_custom = '';
if (module_exists('search') && variable_get('googleanalytics_site_search', FALSE) && arg(0) == 'search' && $keys = googleanalytics_search_get_keys()) {
+ // hook_preprocess_search_results() is not executed if search result is
+ // empty. Make sure the counter is set to 0 if there are no results.
$url_custom = '(window.googleanalytics_search_results) ? ' . drupal_json_encode(url('search/' . arg(1), array('query' => array('search' => $keys)))) . ' : ' . drupal_json_encode(url('search/' . arg(1), array('query' => array('search' => 'no-results:' . $keys, 'cat' => 'no-results'))));
}
@@ -167,77 +201,149 @@ function googleanalytics_page_alter(&$page) {
// Track access denied (403) and file not found (404) pages.
if ($status == '403 Forbidden') {
- // See http://www.google.com/support/analytics/bin/answer.py?answer=86927
- $url_custom = '"/403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
+ // See https://www.google.com/support/analytics/bin/answer.py?answer=86927
+ $url_custom = '"' . $base_path . '403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
}
elseif ($status == '404 Not Found') {
- $url_custom = '"/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
+ $url_custom = '"' . $base_path . '404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
}
- // Add any custom code snippets if specified.
- $codesnippet_before = variable_get('googleanalytics_codesnippet_before', '');
- $codesnippet_after = variable_get('googleanalytics_codesnippet_after', '');
+ // #2693595: User has entered an invalid login and clicked on forgot
+ // password link. This link contains the username or email address and may
+ // get send to Google if we do not override it. Override only if 'name'
+ // query param exists. Last custom url condition, this need to win.
+ //
+ // URLs to protect are:
+ // - user/password?name=username
+ // - user/password?name=foo@example.com
+ if (arg(0) == 'user' && arg(1) == 'password' && array_key_exists('name', drupal_get_query_parameters())) {
+ $url_custom = '"' . $base_path . 'user/password"';
+ }
- // Add custom variables.
- $googleanalytics_custom_vars = variable_get('googleanalytics_custom_var', array());
+ // Add custom dimensions and metrics.
$custom_var = '';
- for ($i = 1; $i < 6; $i++) {
- $custom_var_name = !empty($googleanalytics_custom_vars['slots'][$i]['name']) ? $googleanalytics_custom_vars['slots'][$i]['name'] : '';
- if (!empty($custom_var_name)) {
- $custom_var_value = !empty($googleanalytics_custom_vars['slots'][$i]['value']) ? $googleanalytics_custom_vars['slots'][$i]['value'] : '';
- $custom_var_scope = !empty($googleanalytics_custom_vars['slots'][$i]['scope']) ? $googleanalytics_custom_vars['slots'][$i]['scope'] : 3;
+ foreach (array('dimension', 'metric') as $googleanalytics_custom_type) {
+ $googleanalytics_custom_vars = variable_get('googleanalytics_custom_' . $googleanalytics_custom_type, array());
+ // Are there dimensions or metrics configured?
+ if (!empty($googleanalytics_custom_vars)) {
+ // Add all the configured variables to the content.
+ foreach ($googleanalytics_custom_vars as $googleanalytics_custom_var) {
+ // Replace tokens in values.
+ $types = array();
+ $node = menu_get_object();
+ if (is_object($node)) {
+ $types += array('node' => $node);
+ }
+ $googleanalytics_custom_var['value'] = token_replace($googleanalytics_custom_var['value'], $types, array('clear' => TRUE));
- $types = array();
- $node = menu_get_object();
- if (is_object($node)) {
- $types += array('node' => $node);
+ // Suppress empty values.
+ if (!drupal_strlen(trim($googleanalytics_custom_var['value']))) {
+ continue;
+ }
+
+ // Per documentation the max length of a dimension is 150 bytes.
+ // A metric has no length limitation. It's not documented if this
+ // limit means 150 bytes after url encoding or before.
+ // See https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#customs
+ if ($googleanalytics_custom_type == 'dimension' && drupal_strlen($googleanalytics_custom_var['value']) > 150) {
+ $googleanalytics_custom_var['value'] = substr($googleanalytics_custom_var['value'], 0, 150);
+ }
+
+ // Cast metric values for json_encode to data type numeric.
+ if ($googleanalytics_custom_type == 'metric') {
+ settype($googleanalytics_custom_var['value'], 'float');
+ };
+
+ // Add variables to tracker.
+ $custom_var .= 'ga("set", ' . drupal_json_encode($googleanalytics_custom_type . $googleanalytics_custom_var['index']) . ', ' . drupal_json_encode($googleanalytics_custom_var['value']) . ');';
}
- $custom_var_name = token_replace($custom_var_name, $types, array('clear' => TRUE));
- $custom_var_value = token_replace($custom_var_value, $types, array('clear' => TRUE));
-
- // Suppress empty custom names and/or variables.
- if (!drupal_strlen(trim($custom_var_name)) || !drupal_strlen(trim($custom_var_value))) {
- continue;
- }
-
- // The length of the string used for the 'name' and the length of the
- // string used for the 'value' must not exceed 128 bytes after url encoding.
- $name_length = drupal_strlen(rawurlencode($custom_var_name));
- $tmp_value = rawurlencode($custom_var_value);
- $value_length = drupal_strlen($tmp_value);
- if ($name_length + $value_length > 128) {
- // Trim value and remove fragments of url encoding.
- $tmp_value = rtrim(substr($tmp_value, 0, 127 - $name_length), '%0..9A..F');
- $custom_var_value = urldecode($tmp_value);
- }
-
- $custom_var_name = drupal_json_encode($custom_var_name);
- $custom_var_value = drupal_json_encode($custom_var_value);
- $custom_var .= "_gaq.push(['_setCustomVar', $i, $custom_var_name, $custom_var_value, $custom_var_scope]);";
}
}
// Build tracker code.
- $script = 'var _gaq = _gaq || [];';
- $script .= '_gaq.push(["_setAccount", ' . drupal_json_encode($id) . ']);';
- if (variable_get('googleanalytics_tracker_anonymizeip', 0)) {
- // FIXME: The Google API is currently broken and "_gat._anonymizeIp" is only
- // a workaround until "_anonymizeIp" has been implemented/fixed.
- $script .= '_gaq.push(["_gat._anonymizeIp"]);';
+ $script = '(function(i,s,o,g,r,a,m){';
+ $script .= 'i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){';
+ $script .= '(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),';
+ $script .= 'm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)';
+ $script .= '})(window,document,"script",';
+
+ // Which version of the tracking library should be used?
+ $library_tracker_url = 'https://www.google-analytics.com/' . ($debug ? 'analytics_debug.js' : 'analytics.js');
+
+ // Should a local cached copy of analytics.js be used?
+ if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache($library_tracker_url)) {
+ // A dummy query-string is added to filenames, to gain control over
+ // browser-caching. The string changes on every update or full cache
+ // flush, forcing browsers to load a new copy of the files, as the
+ // URL changed.
+ $query_string = '?' . variable_get('css_js_query_string', '0');
+
+ $script .= '"' . $url . $query_string . '"';
}
+ else {
+ $script .= '"' . $library_tracker_url . '"';
+ }
+ $script .= ',"ga");';
+
+ // Add any custom code snippets if specified.
+ $codesnippet_create = variable_get('googleanalytics_codesnippet_create', array());
+ $codesnippet_before = variable_get('googleanalytics_codesnippet_before', '');
+ $codesnippet_after = variable_get('googleanalytics_codesnippet_after', '');
+
+ // Build the create only fields list.
+ $create_only_fields = array('cookieDomain' => 'auto');
+ $create_only_fields = array_merge($create_only_fields, $codesnippet_create);
// Domain tracking type.
global $cookie_domain;
$domain_mode = variable_get('googleanalytics_domain_mode', 0);
+ $googleanalytics_adsense_script = '';
// Per RFC 2109, cookie domains must contain at least one dot other than the
// first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
if ($domain_mode == 1 && count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
- $script .= '_gaq.push(["_setDomainName", ' . drupal_json_encode($cookie_domain) . ']);';
+ $create_only_fields = array_merge($create_only_fields, array('cookieDomain' => $cookie_domain));
+ $googleanalytics_adsense_script .= 'window.google_analytics_domain_name = ' . drupal_json_encode($cookie_domain) . ';';
}
elseif ($domain_mode == 2) {
- $script .= '_gaq.push(["_setDomainName", "none"]);';
- $script .= '_gaq.push(["_setAllowLinker", true]);';
+ // Cross Domain tracking. 'autoLinker' need to be enabled in 'create'.
+ $create_only_fields = array_merge($create_only_fields, array('allowLinker' => TRUE));
+ $googleanalytics_adsense_script .= 'window.google_analytics_domain_name = "none";';
+ }
+
+ // Track logged in users across all devices.
+ if (variable_get('googleanalytics_trackuserid', 0) && user_is_logged_in()) {
+ $create_only_fields['userId'] = google_analytics_user_id_hash($user->uid);
+ }
+
+ // Create a tracker.
+ $script .= 'ga("create", ' . drupal_json_encode($id) . ', ' . drupal_json_encode($create_only_fields) .');';
+
+ // Prepare Adsense tracking.
+ $googleanalytics_adsense_script .= 'window.google_analytics_uacct = ' . drupal_json_encode($id) . ';';
+
+ // Add enhanced link attribution after 'create', but before 'pageview' send.
+ // @see https://support.google.com/analytics/answer/2558867
+ if (variable_get('googleanalytics_tracklinkid', 0)) {
+ $script .= 'ga("require", "linkid", "linkid.js");';
+ }
+
+ // Add display features after 'create', but before 'pageview' send.
+ // @see https://support.google.com/analytics/answer/2444872
+ if (variable_get('googleanalytics_trackdoubleclick', 0)) {
+ $script .= 'ga("require", "displayfeatures");';
+ }
+
+ // Domain tracking type.
+ if ($domain_mode == 2) {
+ // Cross Domain tracking
+ // https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs#cross-domain
+ $script .= 'ga("require", "linker");';
+ $script .= 'ga("linker:autoLink", ' . drupal_json_encode($link_settings['trackCrossDomains']) . ');';
+ }
+
+ if (variable_get('googleanalytics_tracker_anonymizeip', 1)) {
+ $script .= 'ga("set", "anonymizeIp", true);';
}
if (!empty($custom_var)) {
@@ -246,12 +352,11 @@ function googleanalytics_page_alter(&$page) {
if (!empty($codesnippet_before)) {
$script .= $codesnippet_before;
}
- if (empty($url_custom)) {
- $script .= '_gaq.push(["_trackPageview"]);';
- }
- else {
- $script .= '_gaq.push(["_trackPageview", ' . $url_custom . ']);';
+ if (!empty($url_custom)) {
+ $script .= 'ga("set", "page", ' . $url_custom . ');';
}
+ $script .= 'ga("send", "pageview");';
+
if (!empty($message_events)) {
$script .= $message_events;
}
@@ -259,48 +364,34 @@ function googleanalytics_page_alter(&$page) {
$script .= $codesnippet_after;
}
- $script .= '(function() {';
- $script .= 'var ga = document.createElement("script");';
- $script .= 'ga.type = "text/javascript";';
- $script .= 'ga.async = true;';
-
- // Which version of the tracking library should be used?
- if ($trackdoubleclick = variable_get('googleanalytics_trackdoubleclick', FALSE)) {
- $library_tracker_url = 'stats.g.doubleclick.net/dc.js';
- $library_cache_url = 'http://' . $library_tracker_url;
- }
- else {
- $library_tracker_url = '.google-analytics.com/ga.js';
- $library_cache_url = 'http://www' . $library_tracker_url;
+ if (variable_get('googleanalytics_trackadsense', FALSE)) {
+ // Custom tracking. Prepend before all other JavaScript.
+ // @TODO: https://support.google.com/adsense/answer/98142
+ // sounds like it could be appended to $script.
+ drupal_add_js($googleanalytics_adsense_script, array('type' => 'inline', 'group' => JS_LIBRARY-1, 'requires_jquery' => FALSE));
}
- // Should a local cached copy of ga.js be used?
- if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache($library_cache_url)) {
- // A dummy query-string is added to filenames, to gain control over
- // browser-caching. The string changes on every update or full cache
- // flush, forcing browsers to load a new copy of the files, as the
- // URL changed.
- $query_string = '?' . variable_get('css_js_query_string', '0');
-
- $script .= 'ga.src = "' . $url . $query_string . '";';
- }
- else {
- // Library paths do not follow the same naming convention.
- if ($trackdoubleclick) {
- $script .= 'ga.src = ("https:" == document.location.protocol ? "https://" : "http://") + "' . $library_tracker_url . '";';
- }
- else {
- $script .= 'ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + "' . $library_tracker_url . '";';
- }
- }
- $script .= 'var s = document.getElementsByTagName("script")[0];';
- $script .= 's.parentNode.insertBefore(ga, s);';
- $script .= '})();';
-
- drupal_add_js($script, array('scope' => $scope, 'type' => 'inline'));
+ drupal_add_js($script, array('scope' => 'header', 'type' => 'inline', 'requires_jquery' => FALSE));
}
}
+/**
+ * Generate user id hash to implement USER_ID.
+ *
+ * The USER_ID value should be a unique, persistent, and non-personally
+ * identifiable string identifier that represents a user or signed-in
+ * account across devices.
+ *
+ * @param int $uid
+ * User id.
+ *
+ * @return string
+ * User id hash.
+ */
+function google_analytics_user_id_hash($uid) {
+ return drupal_hmac_base64($uid, drupal_get_private_key() . drupal_get_hash_salt());
+}
+
/**
* Implements hook_field_extra_fields().
*/
@@ -382,13 +473,7 @@ function googleanalytics_user_presave(&$edit, $account, $category) {
function googleanalytics_cron() {
// Regenerate the tracking code file every day.
if (REQUEST_TIME - variable_get('googleanalytics_last_cache', 0) >= 86400 && variable_get('googleanalytics_cache', 0)) {
- // Which version of the tracking library should be used?
- if (variable_get('googleanalytics_trackdoubleclick', FALSE)) {
- _googleanalytics_cache('http://stats.g.doubleclick.net/dc.js', TRUE);
- }
- else {
- _googleanalytics_cache('http://www.google-analytics.com/ga.js', TRUE);
- }
+ _googleanalytics_cache('https://www.google-analytics.com/analytics.js', TRUE);
variable_set('googleanalytics_last_cache', REQUEST_TIME);
}
}
@@ -399,17 +484,19 @@ function googleanalytics_cron() {
* Collects and adds the number of search results to the head.
*/
function googleanalytics_preprocess_search_results(&$variables) {
- // There is no search result $variable available that hold the number of items
- // found. But the pager item mumber can tell the number of search results.
- global $pager_total_items;
+ if (variable_get('googleanalytics_site_search', FALSE)) {
+ // There is no search result $variable available that hold the number of items
+ // found. But the pager item mumber can tell the number of search results.
+ global $pager_total_items;
- drupal_add_js('window.googleanalytics_search_results = ' . intval($pager_total_items[0]) . ';', array('type' => 'inline', 'group' => JS_LIBRARY-1));
+ drupal_add_js('window.googleanalytics_search_results = ' . intval($pager_total_items[0]) . ';', array('type' => 'inline', 'group' => JS_LIBRARY-1, 'requires_jquery' => FALSE));
+ }
}
/**
* Helper function for grabbing search keys. Function is missing in D7.
*
- * http://api.drupal.org/api/function/search_get_keys/6
+ * https://api.drupal.org/api/function/search_get_keys/6
*/
function googleanalytics_search_get_keys() {
static $return;
@@ -428,16 +515,16 @@ function googleanalytics_search_get_keys() {
*
* @param $location
* The full URL to the external javascript file.
- * @param $sync_cached_file
- * Synchronize tracking code and update if remote file have changed.
+ * @param $synchronize
+ * Synchronize to local cache if remote file has changed.
* @return mixed
* The path to the local javascript file on success, boolean FALSE on failure.
*/
-function _googleanalytics_cache($location, $sync_cached_file = FALSE) {
+function _googleanalytics_cache($location, $synchronize = FALSE) {
$path = 'public://googleanalytics';
$file_destination = $path . '/' . basename($location);
- if (!file_exists($file_destination) || $sync_cached_file) {
+ if (!file_exists($file_destination) || $synchronize) {
// Download the latest tracking code.
$result = drupal_http_request($location);
@@ -450,6 +537,10 @@ function _googleanalytics_cache($location, $sync_cached_file = FALSE) {
if ($data_hash_local != $data_hash_remote && file_prepare_directory($path)) {
// Save updated tracking code file to disk.
file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
+ // Based on Drupal Core drupal_build_css_cache().
+ if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
+ file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
+ }
watchdog('googleanalytics', 'Locally cached tracking code file has been updated.', array(), WATCHDOG_INFO);
// Change query-strings on css/js files to enforce reload for all users.
@@ -462,6 +553,10 @@ function _googleanalytics_cache($location, $sync_cached_file = FALSE) {
// There is no need to flush JS here as core refreshes JS caches
// automatically, if new files are added.
file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
+ // Based on Drupal Core drupal_build_css_cache().
+ if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
+ file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
+ }
watchdog('googleanalytics', 'Locally cached tracking code file has been saved.', array(), WATCHDOG_INFO);
// Return the local JS file path.
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test
index f8a68cd..52c3148 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test
@@ -6,10 +6,17 @@
*/
class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
+ /**
+ * User without permissions to edit snippets.
+ *
+ * @var \StdClass
+ */
+ protected $noSnippetUser;
+
public static function getInfo() {
return array(
- 'name' => t('Google Analytics basic tests'),
- 'description' => t('Test basic functionality of Google Analytics module.'),
+ 'name' => 'Google Analytics basic tests',
+ 'description' => 'Test basic functionality of Google Analytics module.',
'group' => 'Google Analytics',
);
}
@@ -20,31 +27,70 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
$permissions = array(
'access administration pages',
'administer google analytics',
+ 'administer modules',
+ 'administer site configuration',
);
// User to set up google_analytics.
+ $this->noSnippetUser = $this->drupalCreateUser($permissions);
+ $permissions[] = 'add JS snippets for google analytics';
$this->admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->admin_user);
}
function testGoogleAnalyticsConfiguration() {
+ // Check if Configure link is available on 'Modules' page.
+ // Requires 'administer modules' permission.
+ $this->drupalGet('admin/modules');
+ $this->assertRaw('admin/config/system/googleanalytics', '[testGoogleAnalyticsConfiguration]: Configure link from Modules page to Google Analytics Settings page exists.');
+
+ // Check if Configure link is available on 'Status Reports' page. NOTE: Link is only shown without UA code configured.
+ // Requires 'administer site configuration' permission.
+ $this->drupalGet('admin/reports/status');
+ $this->assertRaw('admin/config/system/googleanalytics', '[testGoogleAnalyticsConfiguration]: Configure link from Status Reports page to Google Analytics Settings page exists.');
+
// Check for setting page's presence.
$this->drupalGet('admin/config/system/googleanalytics');
$this->assertRaw(t('Web Property ID'), '[testGoogleAnalyticsConfiguration]: Settings page displayed.');
// Check for account code validation.
$edit['googleanalytics_account'] = $this->randomName(2);
- $this->drupalPost('admin/config/system/googleanalytics', $edit, 'Save configuration');
+ $this->drupalPost('admin/config/system/googleanalytics', $edit, t('Save configuration'));
$this->assertRaw(t('A valid Google Analytics Web Property ID is case sensitive and formatted like UA-xxxxxxx-yy.'), '[testGoogleAnalyticsConfiguration]: Invalid Web Property ID number validated.');
+
+ // User should have access to code snippets.
+ $this->assertFieldByName('googleanalytics_codesnippet_create');
+ $this->assertFieldByName('googleanalytics_codesnippet_before');
+ $this->assertFieldByName('googleanalytics_codesnippet_after');
+ $this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_create' and @disabled='disabled']", NULL, '"Create only fields" is enabled.');
+ $this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is enabled.');
+ $this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is enabled.');
+
+ // Login as user without JS permissions.
+ $this->drupalLogin($this->noSnippetUser);
+ $this->drupalGet('admin/config/system/googleanalytics');
+
+ // User should *not* have access to snippets, but create fields.
+ $this->assertFieldByName('googleanalytics_codesnippet_create');
+ $this->assertFieldByName('googleanalytics_codesnippet_before');
+ $this->assertFieldByName('googleanalytics_codesnippet_after');
+ $this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_create' and @disabled='disabled']", NULL, '"Create only fields" is enabled.');
+ $this->assertFieldByXPath("//textarea[@name='googleanalytics_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is disabled.');
+ $this->assertFieldByXPath("//textarea[@name='googleanalytics_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is disabled.');
}
function testGoogleAnalyticsPageVisibility() {
+ // Verify that no tracking code is embedded into the webpage; if there is
+ // only the module installed, but UA code not configured. See #2246991.
+ $this->drupalGet('');
+ $this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed without UA code configured.');
+
$ua_code = 'UA-123456-1';
variable_set('googleanalytics_account', $ua_code);
// Show tracking on "every page except the listed pages".
variable_set('googleanalytics_visibility_pages', 0);
- // Disable tracking one "admin*" pages only.
+ // Disable tracking on "admin*" pages only.
variable_set('googleanalytics_pages', "admin\nadmin/*");
// Enable tracking only for authenticated users only.
variable_set('googleanalytics_roles', array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
@@ -58,7 +104,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
$this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin page.');
$this->drupalGet('admin/config/system/googleanalytics');
// Checking for tracking code URI here, as $ua_code is displayed in the form.
- $this->assertNoRaw('google-analytics.com/ga.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin subpage.');
+ $this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin subpage.');
// Test whether tracking code display is properly flipped.
variable_set('googleanalytics_visibility_pages', 1);
@@ -66,7 +112,7 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
$this->assertRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin page.');
$this->drupalGet('admin/config/system/googleanalytics');
// Checking for tracking code URI here, as $ua_code is displayed in the form.
- $this->assertRaw('google-analytics.com/ga.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin subpage.');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin subpage.');
$this->drupalGet('');
$this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is NOT displayed on front page.');
@@ -80,31 +126,33 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// Enable tracking code for all user roles.
variable_set('googleanalytics_roles', array());
+ $base_path = base_path();
+
// Test whether 403 forbidden tracking code is shown if user has no access.
$this->drupalGet('admin');
- $this->assertRaw('/403.html', '[testGoogleAnalyticsPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
+ $this->assertRaw($base_path . '403.html', '[testGoogleAnalyticsPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
// Test whether 404 not found tracking code is shown on non-existent pages.
$this->drupalGet($this->randomName(64));
- $this->assertRaw('/404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
+ $this->assertRaw($base_path . '404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
// DNT Tests:
- // Enable caching of pages for anonymous users.
+ // Enable system internal page cache for anonymous users.
variable_set('cache', 1);
// Test whether DNT headers will fail to disable embedding of tracking code.
$this->drupalGet('', array(), array('DNT: 1'));
- $this->assertRaw('_gaq.push(["_trackPageview"]);', '[testGoogleAnalyticsDNTVisibility]: DNT header send from client, but page caching is enabled and tracker cannot removed.');
- // DNT works only with caching of pages for anonymous users disabled.
+ $this->assertRaw('ga("send", "pageview");', '[testGoogleAnalyticsDNTVisibility]: DNT header send from client, but page caching is enabled and tracker cannot removed.');
+ // DNT works only with system internal page cache for anonymous users disabled.
variable_set('cache', 0);
$this->drupalGet('');
- $this->assertRaw('_gaq.push(["_trackPageview"]);', '[testGoogleAnalyticsDNTVisibility]: Tracking is enabled without DNT header.');
+ $this->assertRaw('ga("send", "pageview");', '[testGoogleAnalyticsDNTVisibility]: Tracking is enabled without DNT header.');
// Test whether DNT header is able to remove the tracking code.
$this->drupalGet('', array(), array('DNT: 1'));
- $this->assertNoRaw('_gaq.push(["_trackPageview"]);', '[testGoogleAnalyticsDNTVisibility]: DNT header received from client. Tracking has been disabled by browser.');
+ $this->assertNoRaw('ga("send", "pageview");', '[testGoogleAnalyticsDNTVisibility]: DNT header received from client. Tracking has been disabled by browser.');
// Disable DNT feature and see if tracker is still embedded.
variable_set('googleanalytics_privacy_donottrack', 0);
$this->drupalGet('', array(), array('DNT: 1'));
- $this->assertRaw('_gaq.push(["_trackPageview"]);', '[testGoogleAnalyticsDNTVisibility]: DNT feature is disabled, DNT header from browser has been ignored.');
+ $this->assertRaw('ga("send", "pageview");', '[testGoogleAnalyticsDNTVisibility]: DNT feature is disabled, DNT header from browser has been ignored.');
}
function testGoogleAnalyticsTrackingCode() {
@@ -118,40 +166,75 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
/* Sample JS code as added to page:
-
+
*/
// Test whether tracking code uses latest JS.
variable_set('googleanalytics_cache', 0);
$this->drupalGet('');
- $this->assertRaw('google-analytics.com/ga.js', '[testGoogleAnalyticsTrackingCode]: Latest tracking code used.');
-
- // Test whether the alternate doubleclick library is used
- variable_set('googleanalytics_trackdoubleclick', 1);
- $this->drupalGet('');
- $this->assertRaw('stats.g.doubleclick.net/dc.js', '[testGoogleAnalyticsTrackingCode]: Doubleclick tracking code used.');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Latest tracking code used.');
// Test whether anonymize visitors IP address feature has been enabled.
+ variable_set('googleanalytics_tracker_anonymizeip', 0);
$this->drupalGet('');
- $this->assertNoRaw('_gaq.push(["_gat._anonymizeIp"]);', '[testGoogleAnalyticsTrackingCode]: Anonymize visitors IP address not found on frontpage.');
+ $this->assertNoRaw('ga("set", "anonymizeIp", true);', '[testGoogleAnalyticsTrackingCode]: Anonymize visitors IP address not found on frontpage.');
// Enable anonymizing of IP addresses.
variable_set('googleanalytics_tracker_anonymizeip', 1);
$this->drupalGet('');
- $this->assertRaw('_gaq.push(["_gat._anonymizeIp"]);', '[testGoogleAnalyticsTrackingCode]: Anonymize visitors IP address found on frontpage.');
+ $this->assertRaw('ga("set", "anonymizeIp", true);', '[testGoogleAnalyticsTrackingCode]: Anonymize visitors IP address found on frontpage.');
+
+ // Test if track Enhanced Link Attribution is enabled.
+ variable_set('googleanalytics_tracklinkid', 1);
+ $this->drupalGet('');
+ $this->assertRaw('ga("require", "linkid", "linkid.js");', '[testGoogleAnalyticsTrackingCode]: Tracking code for Enhanced Link Attribution is enabled.');
+
+ // Test if track Enhanced Link Attribution is disabled.
+ variable_set('googleanalytics_tracklinkid', 0);
+ $this->drupalGet('');
+ $this->assertNoRaw('ga("require", "linkid", "linkid.js");', '[testGoogleAnalyticsTrackingCode]: Tracking code for Enhanced Link Attribution is not enabled.');
+
+ // Test if tracking of User ID is enabled.
+ variable_set('googleanalytics_trackuserid', 1);
+ $this->drupalGet('');
+ $this->assertRaw(', {"cookieDomain":"auto","userId":"', '[testGoogleAnalyticsTrackingCode]: Tracking code for User ID is enabled.');
+
+ // Test if tracking of User ID is disabled.
+ variable_set('googleanalytics_trackuserid', 0);
+ $this->drupalGet('');
+ $this->assertNoRaw(', {"cookieDomain":"auto","userId":"', '[testGoogleAnalyticsTrackingCode]: Tracking code for User ID is disabled.');
+
+ // Test if tracking of url fragments is enabled.
+ variable_set('googleanalytics_trackurlfragments', 1);
+ $this->drupalGet('');
+ $this->assertRaw('ga("set", "page", location.pathname + location.search + location.hash);', '[testGoogleAnalyticsTrackingCode]: Tracking code for url fragments is enabled.');
+
+ // Test if tracking of url fragments is disabled.
+ variable_set('googleanalytics_trackurlfragments', 0);
+ $this->drupalGet('');
+ $this->assertNoRaw('ga("set", "page", location.pathname + location.search + location.hash);', '[testGoogleAnalyticsTrackingCode]: Tracking code for url fragments is not enabled.');
+
+ // Test if track display features is enabled.
+ variable_set('googleanalytics_trackdoubleclick', 1);
+ $this->drupalGet('');
+ $this->assertRaw('ga("require", "displayfeatures");', '[testGoogleAnalyticsTrackingCode]: Tracking code for display features is enabled.');
+
+ // Test if track display features is disabled.
+ variable_set('googleanalytics_trackdoubleclick', 0);
+ $this->drupalGet('');
+ $this->assertNoRaw('ga("require", "displayfeatures");', '[testGoogleAnalyticsTrackingCode]: Tracking code for display features is not enabled.');
// Test whether single domain tracking is active.
$this->drupalGet('');
- $this->assertNoRaw('_gaq.push(["_setDomainName"', '[testGoogleAnalyticsTrackingCode]: Single domain tracking is active.');
+ $this->assertRaw('{"cookieDomain":"auto"}', '[testGoogleAnalyticsTrackingCode]: Single domain tracking is active.');
// Enable "One domain with multiple subdomains".
variable_set('googleanalytics_domain_mode', 1);
@@ -161,36 +244,63 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
// TODO: Workaround to run tests successfully. This feature cannot tested reliable.
global $cookie_domain;
if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
- $this->assertRaw('_gaq.push(["_setDomainName",', '[testGoogleAnalyticsTrackingCode]: One domain with multiple subdomains is active on real host.');
+ $this->assertRaw('{"cookieDomain":"' . $cookie_domain . '"}', '[testGoogleAnalyticsTrackingCode]: One domain with multiple subdomains is active on real host.');
}
else {
// Special cases, Localhost and IP addresses don't show '_setDomainName'.
- $this->assertNoRaw('_gaq.push(["_setDomainName",', '[testGoogleAnalyticsTrackingCode]: One domain with multiple subdomains may be active on localhost (test result is not reliable).');
+ $this->assertNoRaw('{"cookieDomain":"' . $cookie_domain . '"}', '[testGoogleAnalyticsTrackingCode]: One domain with multiple subdomains may be active on localhost (test result is not reliable).');
}
// Enable "Multiple top-level domains" tracking.
variable_set('googleanalytics_domain_mode', 2);
variable_set('googleanalytics_cross_domains', "www.example.com\nwww.example.net");
$this->drupalGet('');
- $this->assertRaw('_gaq.push(["_setDomainName", "none"]);', '[testGoogleAnalyticsTrackingCode]: _setDomainName: "none" found. Cross domain tracking is active.');
- $this->assertRaw('_gaq.push(["_setAllowLinker", true]);', '[testGoogleAnalyticsTrackingCode]: _setAllowLinker: true found. Cross domain tracking is active.');
+ $this->assertRaw('ga("create", "' . $ua_code . '", {"cookieDomain":"auto","allowLinker":true', '[testGoogleAnalyticsTrackingCode]: "allowLinker" has been found. Cross domain tracking is active.');
+ $this->assertRaw('ga("require", "linker");', '[testGoogleAnalyticsTrackingCode]: Require linker has been found. Cross domain tracking is active.');
+ $this->assertRaw('ga("linker:autoLink", ["www.example.com","www.example.net"]);', '[testGoogleAnalyticsTrackingCode]: "linker:autoLink" has been found. Cross domain tracking is active.');
+ $this->assertRaw('"trackDomainMode":2,', '[testGoogleAnalyticsTrackingCode]: Domain mode value is of type integer.');
$this->assertRaw('"trackCrossDomains":["www.example.com","www.example.net"]', '[testGoogleAnalyticsTrackingCode]: Cross domain tracking with www.example.com and www.example.net is active.');
+ variable_set('googleanalytics_domain_mode', 0);
- // Test whether the BEFORE and AFTER code is added to the tracker.
- variable_set('googleanalytics_codesnippet_before', '_setDetectFlash(false);');
- variable_set('googleanalytics_codesnippet_after', '_gaq.push(["t2._setAccount", "UA-123456-3"]);_gaq.push(["t2._trackPageview"]);');
+ // Test whether debugging script has been enabled.
+ variable_set('googleanalytics_debug', 1);
$this->drupalGet('');
- $this->assertRaw('_setDetectFlash(false);', '[testGoogleAnalyticsTrackingCode]: Before codesnippet has been found with "Flash" detection disabled.');
- $this->assertRaw('t2._setAccount', '[testGoogleAnalyticsTrackingCode]: After codesnippet with "t2" tracker has been found.');
+ $this->assertRaw('https://www.google-analytics.com/analytics_debug.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been enabled.');
+
+ // Check if text and link is shown on 'Status Reports' page.
+ // Requires 'administer site configuration' permission.
+ $this->drupalGet('admin/reports/status');
+ $this->assertRaw(t('Google Analytics module has debugging enabled. Please disable debugging setting in production sites from the Google Analytics settings page.', array('@url' => url('admin/config/system/googleanalytics'))), '[testGoogleAnalyticsConfiguration]: Debugging enabled is shown on Status Reports page.');
+
+ // Test whether debugging script has been disabled.
+ variable_set('googleanalytics_debug', 0);
+ $this->drupalGet('');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsTrackingCode]: Google debugging script has been disabled.');
+
+ // Test whether the CREATE and BEFORE and AFTER code is added to the tracker.
+ $codesnippet_create = array(
+ 'cookieDomain' => 'foo.example.com',
+ 'cookieName' => 'myNewName',
+ 'cookieExpires' => 20000,
+ 'allowAnchor' => TRUE,
+ 'sampleRate' => 4.3,
+ );
+ variable_set('googleanalytics_codesnippet_create', $codesnippet_create);
+ variable_set('googleanalytics_codesnippet_before', 'ga("set", "forceSSL", true);');
+ variable_set('googleanalytics_codesnippet_after', 'ga("create", "UA-123456-3", {"name": "newTracker"});ga("newTracker.send", "pageview");');
+ $this->drupalGet('');
+ $this->assertRaw('ga("create", "' . $ua_code . '", {"cookieDomain":"foo.example.com","cookieName":"myNewName","cookieExpires":20000,"allowAnchor":true,"sampleRate":4.3});', '[testGoogleAnalyticsTrackingCode]: Create only fields have been found.');
+ $this->assertRaw('ga("set", "forceSSL", true);', '[testGoogleAnalyticsTrackingCode]: Before codesnippet will force http pages to also send all beacons using https.');
+ $this->assertRaw('ga("create", "UA-123456-3", {"name": "newTracker"});', '[testGoogleAnalyticsTrackingCode]: After codesnippet with "newTracker" tracker has been found.');
}
}
-class GoogleAnalyticsCustomVariablesTest extends DrupalWebTestCase {
+class GoogleAnalyticsCustomDimensionsAndMetricsTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
- 'name' => t('Google Analytics Custom Variables tests'),
- 'description' => t('Test custom variables functionality of Google Analytics module.'),
+ 'name' => 'Google Analytics custom dimensions and metrics tests',
+ 'description' => 'Test custom dimensions and metrics functionality of Google Analytics module.',
'group' => 'Google Analytics',
'dependencies' => array('token'),
);
@@ -206,110 +316,217 @@ class GoogleAnalyticsCustomVariablesTest extends DrupalWebTestCase {
// User to set up google_analytics.
$this->admin_user = $this->drupalCreateUser($permissions);
+ $this->drupalLogin($this->admin_user);
}
- function testGoogleAnalyticsCustomVariables() {
+ function testGoogleAnalyticsCustomDimensions() {
$ua_code = 'UA-123456-3';
variable_set('googleanalytics_account', $ua_code);
// Basic test if the feature works.
- $custom_vars = array(
- 'slots' => array(
- 1 => array(
- 'slot' => 1,
- 'name' => 'Foo 1',
- 'value' => 'Bar 1',
- 'scope' => 3,
- ),
- 2 => array(
- 'slot' => 2,
- 'name' => 'Foo 2',
- 'value' => 'Bar 2',
- 'scope' => 2,
- ),
- 3 => array(
- 'slot' => 3,
- 'name' => 'Foo 3',
- 'value' => 'Bar 3',
- 'scope' => 3,
- ),
- 4 => array(
- 'slot' => 4,
- 'name' => 'Foo 4',
- 'value' => 'Bar 4',
- 'scope' => 2,
- ),
- 5 => array(
- 'slot' => 5,
- 'name' => 'Foo 5',
- 'value' => 'Bar 5',
- 'scope' => 1,
- ),
- )
+ $googleanalytics_custom_dimension = array(
+ 1 => array(
+ 'index' => 1,
+ 'value' => 'Bar 1',
+ ),
+ 2 => array(
+ 'index' => 2,
+ 'value' => 'Bar 2',
+ ),
+ 3 => array(
+ 'index' => 3,
+ 'value' => 'Bar 3',
+ ),
+ 4 => array(
+ 'index' => 4,
+ 'value' => 'Bar 4',
+ ),
+ 5 => array(
+ 'index' => 5,
+ 'value' => 'Bar 5',
+ ),
);
- variable_set('googleanalytics_custom_var', $custom_vars);
+ variable_set('googleanalytics_custom_dimension', $googleanalytics_custom_dimension);
$this->drupalGet('');
- foreach ($custom_vars['slots'] as $slot) {
- $this->assertRaw("_gaq.push(['_setCustomVar', " . $slot['slot'] . ", \"" . $slot['name'] . "\", \"" . $slot['value'] . "\", " . $slot['scope'] . "]);", '[testGoogleAnalyticsCustomVariables]: _setCustomVar ' . $slot['slot'] . ' is shown.');
+ foreach ($googleanalytics_custom_dimension as $dimension) {
+ $this->assertRaw('ga("set", ' . drupal_json_encode('dimension' . $dimension['index']) . ', ' . drupal_json_encode($dimension['value']) . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Dimension #' . $dimension['index'] . ' is shown.');
}
- // Test whether tokens are replaced in custom variable names.
+ // Test whether tokens are replaced in custom dimension values.
$site_slogan = $this->randomName(16);
variable_set('site_slogan', $site_slogan);
- $custom_vars = array(
- 'slots' => array(
- 1 => array(
- 'slot' => 1,
- 'name' => 'Name: [site:slogan]',
- 'value' => 'Value: [site:slogan]',
- 'scope' => 3,
- ),
- 2 => array(
- 'slot' => 2,
- 'name' => '',
- 'value' => $this->randomName(16),
- 'scope' => 1,
- ),
- 3 => array(
- 'slot' => 3,
- 'name' => $this->randomName(16),
- 'value' => '',
- 'scope' => 2,
- ),
- 4 => array(
- 'slot' => 4,
- 'name' => '',
- 'value' => '',
- 'scope' => 3,
- ),
- 5 => array(
- 'slot' => 5,
- 'name' => '',
- 'value' => '',
- 'scope' => 3,
- ),
- )
+ $googleanalytics_custom_dimension = array(
+ 1 => array(
+ 'index' => 1,
+ 'value' => 'Value: [site:slogan]',
+ ),
+ 2 => array(
+ 'index' => 2,
+ 'value' => $this->randomName(16),
+ ),
+ 3 => array(
+ 'index' => 3,
+ 'value' => '',
+ ),
+ // #2300701: Custom dimensions and custom metrics not outputed on zero value.
+ 4 => array(
+ 'index' => 4,
+ 'value' => '0',
+ ),
);
- variable_set('googleanalytics_custom_var', $custom_vars);
- $this->verbose('
');
+
+ $this->drupalGet('');
+ $this->assertRaw('ga("set", ' . drupal_json_encode('metric1') . ', ', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Tokens have been replaced in metric value.');
+ $this->assertRaw('ga("set", ' . drupal_json_encode('metric2') . ', ' . drupal_json_encode($googleanalytics_custom_metric['2']['value']) . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Random value is shown.');
+ $this->assertNoRaw('ga("set", ' . drupal_json_encode('metric3') . ', ' . drupal_json_encode('') . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Empty value is not shown.');
+ $this->assertRaw('ga("set", ' . drupal_json_encode('metric4') . ', ' . drupal_json_encode(0) . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Value 0 is shown.');
+ }
+
+ /**
+ * Tests if Custom Dimensions token form validation works.
+ */
+ public function testGoogleAnalyticsCustomDimensionsTokenFormValidation() {
+ $ua_code = 'UA-123456-1';
+
+ // Check form validation.
+ $edit['googleanalytics_account'] = $ua_code;
+ $edit['googleanalytics_custom_dimension[indexes][1][value]'] = '[current-user:name]';
+ $edit['googleanalytics_custom_dimension[indexes][2][value]'] = '[current-user:edit-url]';
+ $edit['googleanalytics_custom_dimension[indexes][3][value]'] = '[user:name]';
+ $edit['googleanalytics_custom_dimension[indexes][4][value]'] = '[term:name]';
+ $edit['googleanalytics_custom_dimension[indexes][5][value]'] = '[term:tid]';
+
+ $this->drupalPost('admin/config/system/googleanalytics', $edit, t('Save configuration'));
+
+ $this->assertRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 1)), '@invalid-tokens' => implode(', ', array('[current-user:name]')))));
+ $this->assertRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 2)), '@invalid-tokens' => implode(', ', array('[current-user:edit-url]')))));
+ $this->assertRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 3)), '@invalid-tokens' => implode(', ', array('[user:name]')))));
+ // BUG #2037595
+ //$this->assertNoRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 4)), '@invalid-tokens' => implode(', ', array('[term:name]')))));
+ //$this->assertNoRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 5)), '@invalid-tokens' => implode(', ', array('[term:tid]')))));
+ }
+}
+
+/**
+ * Test custom url functionality of Google Analytics module.
+ */
+class GoogleAnalyticsCustomUrls extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Google Analytics custom url tests',
+ 'description' => 'Test custom url functionality of Google Analytics module.',
+ 'group' => 'Google Analytics',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('googleanalytics');
+
+ $permissions = array(
+ 'access administration pages',
+ 'administer google analytics',
+ );
+
+ // User to set up google_analytics.
+ $this->admin_user = $this->drupalCreateUser($permissions);
+ }
+
+ /**
+ * Tests if user password page urls are overridden.
+ */
+ public function testGoogleAnalyticsUserPasswordPage() {
+ $base_path = base_path();
+ $ua_code = 'UA-123456-4';
+ variable_set('googleanalytics_account', $ua_code);
+
+ $this->drupalGet('user/password', array('query' => array('name' => 'foo')));
+ $this->assertRaw('ga("set", "page", "' . $base_path . 'user/password"');
+
+ $this->drupalGet('user/password', array('query' => array('name' => 'foo@example.com')));
+ $this->assertRaw('ga("set", "page", "' . $base_path . 'user/password"');
+
+ $this->drupalGet('user/password');
+ $this->assertNoRaw('ga("set", "page",', '[testGoogleAnalyticsCustomUrls]: Custom url not set.');
+ }
+
}
class GoogleAnalyticsStatusMessagesTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
- 'name' => t('Google Analytics status messages tests'),
- 'description' => t('Test status messages functionality of Google Analytics module.'),
+ 'name' => 'Google Analytics status messages tests',
+ 'description' => 'Test status messages functionality of Google Analytics module.',
'group' => 'Google Analytics',
);
}
@@ -333,20 +550,20 @@ class GoogleAnalyticsStatusMessagesTest extends DrupalWebTestCase {
// Enable logging of errors only.
variable_set('googleanalytics_trackmessages', array('error' => 'error'));
- $this->drupalPost('user/login', array(), 'Log in');
- $this->assertRaw('_gaq.push(["_trackEvent", "Messages", "Error message", "Username field is required."]);', '[testGoogleAnalyticsStatusMessages]: _trackEvent "Username field is required." is shown.');
- $this->assertRaw('_gaq.push(["_trackEvent", "Messages", "Error message", "Password field is required."]);', '[testGoogleAnalyticsStatusMessages]: _trackEvent "Password field is required." is shown.');
+ $this->drupalPost('user/login', array(), t('Log in'));
+ $this->assertRaw('ga("send", "event", "Messages", "Error message", "Username field is required.");', '[testGoogleAnalyticsStatusMessages]: Event message "Username field is required." is shown.');
+ $this->assertRaw('ga("send", "event", "Messages", "Error message", "Password field is required.");', '[testGoogleAnalyticsStatusMessages]: Event message "Password field is required." is shown.');
// @todo: investigate why drupal_set_message() fails.
//drupal_set_message('Example status message.', 'status');
//drupal_set_message('Example warning message.', 'warning');
//drupal_set_message('Example error message.', 'error');
- //drupal_set_message('Example error message with html tags and link.', 'error');
+ //drupal_set_message('Example error message with html tags and link.', 'error');
//$this->drupalGet('');
- //$this->assertNoRaw('_gaq.push(["_trackEvent", "Messages", "Status message", "Example status message."]);', '[testGoogleAnalyticsStatusMessages]: Example status message is not enabled for tracking.');
- //$this->assertNoRaw('_gaq.push(["_trackEvent", "Messages", "Warning message", "Example warning message."]);', '[testGoogleAnalyticsStatusMessages]: Example warning message is not enabled for tracking.');
- //$this->assertRaw('_gaq.push(["_trackEvent", "Messages", "Error message", "Example error message."]);', '[testGoogleAnalyticsStatusMessages]: Example error message is shown.');
- //$this->assertRaw('_gaq.push(["_trackEvent", "Messages", "Error message", "Example error message with html tags and link."]);', '[testGoogleAnalyticsStatusMessages]: HTML has been stripped successful from Example error message with html tags and link.');
+ //$this->assertNoRaw('ga("send", "event", "Messages", "Status message", "Example status message.");', '[testGoogleAnalyticsStatusMessages]: Example status message is not enabled for tracking.');
+ //$this->assertNoRaw('ga("send", "event", "Messages", "Warning message", "Example warning message.");', '[testGoogleAnalyticsStatusMessages]: Example warning message is not enabled for tracking.');
+ //$this->assertRaw('ga("send", "event", "Messages", "Error message", "Example error message.");', '[testGoogleAnalyticsStatusMessages]: Example error message is shown.');
+ //$this->assertRaw('ga("send", "event", "Messages", "Error message", "Example error message with html tags and link.");', '[testGoogleAnalyticsStatusMessages]: HTML has been stripped successful from Example error message with html tags and link.');
}
}
@@ -354,8 +571,8 @@ class GoogleAnalyticsRolesTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
- 'name' => t('Google Analytics role tests'),
- 'description' => t('Test roles functionality of Google Analytics module.'),
+ 'name' => 'Google Analytics role tests',
+ 'description' => 'Test roles functionality of Google Analytics module.',
'group' => 'Google Analytics',
);
}
@@ -438,5 +655,165 @@ class GoogleAnalyticsRolesTest extends DrupalWebTestCase {
$this->drupalGet('');
$this->assertRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is displayed on frontpage for included anonymous users.');
}
+}
+
+class GoogleAnalyticsSearchTest extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Google Analytics search tests',
+ 'description' => 'Test search functionality of Google Analytics module.',
+ 'group' => 'Google Analytics',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('googleanalytics', 'search', 'node');
+
+ $permissions = array(
+ 'access administration pages',
+ 'administer google analytics',
+ 'search content',
+ 'create page content',
+ 'edit own page content',
+ );
+
+ // User to set up google_analytics.
+ $this->admin_user = $this->drupalCreateUser($permissions);
+ $this->drupalLogin($this->admin_user);
+ }
+
+ function testGoogleAnalyticsSearchTracking() {
+ $ua_code = 'UA-123456-1';
+ variable_set('googleanalytics_account', $ua_code);
+
+ // Check tracking code visibility.
+ $this->drupalGet('');
+ $this->assertRaw($ua_code, '[testGoogleAnalyticsSearch]: Tracking code is displayed for authenticated users.');
+
+ $this->drupalGet('search/node');
+ $this->assertNoRaw('ga("set", "page",', '[testGoogleAnalyticsSearch]: Custom url not set.');
+
+ // Enable site search support.
+ variable_set('googleanalytics_site_search', 1);
+
+ // Search for random string.
+ $search = array();
+ $search['keys'] = $this->randomName(8);
+
+ // Create a node to search for.
+ $langcode = LANGUAGE_NONE;
+ $edit = array();
+ $edit['title'] = 'This is a test title';
+ $edit["body[$langcode][0][value]"] = 'This test content contains ' . $search['keys'] . ' string.';
+
+ // Fire a search, it's expected to get 0 results.
+ $this->drupalPost('search/node', $search, t('Search'));
+ $this->assertRaw('ga("set", "page", (window.googleanalytics_search_results) ?', '[testGoogleAnalyticsSearch]: Search results tracker is displayed.');
+ $this->assertRaw('window.googleanalytics_search_results = 0;', '[testGoogleAnalyticsSearch]: Search yielded no results.');
+
+ // Save the node.
+ $this->drupalPost('node/add/page', $edit, t('Save'));
+ $this->assertText(t('@type @title has been created.', array('@type' => 'Basic page', '@title' => $edit['title'])), 'Node was created.');
+
+ // Index the node or it cannot found.
+ $this->cronRun();
+
+ $this->drupalPost('search/node', $search, t('Search'));
+ $this->assertRaw('ga("set", "page", (window.googleanalytics_search_results) ?', '[testGoogleAnalyticsSearch]: Search results tracker is displayed.');
+ $this->assertRaw('window.googleanalytics_search_results = 1;', '[testGoogleAnalyticsSearch]: One search result found.');
+
+ $this->drupalPost('node/add/page', $edit, t('Save'));
+ $this->assertText(t('@type @title has been created.', array('@type' => 'Basic page', '@title' => $edit['title'])), 'Node was created.');
+
+ // Index the node or it cannot found.
+ $this->cronRun();
+
+ $this->drupalPost('search/node', $search, t('Search'));
+ $this->assertRaw('ga("set", "page", (window.googleanalytics_search_results) ?', '[testGoogleAnalyticsSearch]: Search results tracker is displayed.');
+ $this->assertRaw('window.googleanalytics_search_results = 2;', '[testGoogleAnalyticsSearch]: Two search results found.');
+ }
+
+}
+
+class GoogleAnalyticsPhpFilterTest extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Google Analytics php filter tests',
+ 'description' => 'Test php filter functionality of Google Analytics module.',
+ 'group' => 'Google Analytics',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('googleanalytics', 'php');
+
+ // Administrator with all permissions.
+ $permissions_admin_user = array(
+ 'access administration pages',
+ 'administer google analytics',
+ 'use PHP for tracking visibility',
+ );
+ $this->admin_user = $this->drupalCreateUser($permissions_admin_user);
+
+ // Administrator who cannot configure tracking visibility with PHP.
+ $permissions_delegated_admin_user = array(
+ 'access administration pages',
+ 'administer google analytics',
+ );
+ $this->delegated_admin_user = $this->drupalCreateUser($permissions_delegated_admin_user);
+ }
+
+ function testGoogleAnalyticsPhpFilter() {
+ $ua_code = 'UA-123456-1';
+ $this->drupalLogin($this->admin_user);
+
+ $edit = array();
+ $edit['googleanalytics_account'] = $ua_code;
+ $edit['googleanalytics_visibility_pages'] = 2;
+ $edit['googleanalytics_pages'] = '';
+ $this->drupalPost('admin/config/system/googleanalytics', $edit, t('Save configuration'));
+
+ // Compare saved setting with posted setting.
+ $googleanalytics_pages = variable_get('googleanalytics_pages', $this->randomName(8));
+ $this->assertEqual('', $googleanalytics_pages, '[testGoogleAnalyticsPhpFilter]: PHP code snippet is intact.');
+
+ // Check tracking code visibility.
+ variable_set('googleanalytics_pages', '');
+ $this->drupalGet('');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on frontpage page.');
+ $this->drupalGet('admin');
+ $this->assertRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is displayed on admin page.');
+
+ variable_set('googleanalytics_pages', '');
+ $this->drupalGet('');
+ $this->assertNoRaw('https://www.google-analytics.com/analytics.js', '[testGoogleAnalyticsPhpFilter]: Tracking is not displayed on frontpage page.');
+
+ // Test administration form.
+ variable_set('googleanalytics_pages', '');
+ $this->drupalGet('admin/config/system/googleanalytics');
+ $this->assertRaw(t('Pages on which this PHP code returns TRUE (experts only)'), '[testGoogleAnalyticsPhpFilter]: Permission to administer PHP for tracking visibility.');
+ $this->assertRaw(check_plain(''), '[testGoogleAnalyticsPhpFilter]: PHP code snippted is displayed.');
+
+ // Login the delegated user and check if fields are visible.
+ $this->drupalLogin($this->delegated_admin_user);
+ $this->drupalGet('admin/config/system/googleanalytics');
+ $this->assertNoRaw(t('Pages on which this PHP code returns TRUE (experts only)'), '[testGoogleAnalyticsPhpFilter]: No permission to administer PHP for tracking visibility.');
+ $this->assertNoRaw(check_plain(''), '[testGoogleAnalyticsPhpFilter]: No permission to view PHP code snippted.');
+
+ // Set a different value and verify that this is still the same after the post.
+ variable_set('googleanalytics_pages', '');
+
+ $edit = array();
+ $edit['googleanalytics_account'] = $ua_code;
+ $this->drupalPost('admin/config/system/googleanalytics', $edit, t('Save configuration'));
+
+ // Compare saved setting with posted setting.
+ $googleanalytics_visibility_pages = variable_get('googleanalytics_visibility_pages', 0);
+ $googleanalytics_pages = variable_get('googleanalytics_pages', $this->randomName(8));
+ $this->assertEqual(2, $googleanalytics_visibility_pages, '[testGoogleAnalyticsPhpFilter]: Pages on which this PHP code returns TRUE is selected.');
+ $this->assertEqual('', $googleanalytics_pages, '[testGoogleAnalyticsPhpFilter]: PHP code snippet is intact.');
+ }
}
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test.js b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test.js
new file mode 100644
index 0000000..f22d6f1
--- /dev/null
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.test.js
@@ -0,0 +1,121 @@
+(function ($) {
+
+/**
+ * This file is for developers only.
+ *
+ * This tests are made for the javascript functions used in GA module.
+ * These tests verify if the return values are properly working.
+ *
+ * Hopefully this can be added somewhere else once Drupal core has JavaScript
+ * unit testing integrated.
+ */
+
+"use strict";
+
+Drupal.googleanalytics.test = {};
+
+Drupal.googleanalytics.test.assertSame = function (value1, value2, message) {
+ if (value1 === value2) {
+ console.info(message);
+ }
+ else {
+ console.error(message);
+ }
+};
+
+Drupal.googleanalytics.test.assertNotSame = function (value1, value2, message) {
+ if (value1 !== value2) {
+ console.info(message);
+ }
+ else {
+ console.error(message);
+ }
+};
+
+Drupal.googleanalytics.test.assertTrue = function (value1, message) {
+ if (value1 === true) {
+ console.info(message);
+ }
+ else {
+ console.error(message);
+ }
+};
+
+Drupal.googleanalytics.test.assertFalse = function (value1, message) {
+ if (value1 === false) {
+ console.info(message);
+ }
+ else {
+ console.error(message);
+ }
+};
+
+// Run after the documented is ready or Drupal.settings is undefined.
+$(document).ready(function() {
+
+ /**
+ * Run javascript tests against the GA module.
+ */
+
+ // JavaScript debugging
+ var base_url = window.location.protocol + '//' + window.location.host;
+ var base_path = window.location.pathname;
+ console.dir(Drupal);
+
+ console.group("Test 'isDownload':");
+ Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isDownload(base_url + Drupal.settings.basePath + 'node/8'), "Verify that '/node/8' url is not detected as file download.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isDownload(base_url + Drupal.settings.basePath + 'files/foo1.zip'), "Verify that '/files/foo1.zip' url is detected as a file download.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isDownload(base_url + Drupal.settings.basePath + 'files/foo1.zip#foo'), "Verify that '/files/foo1.zip#foo' url is detected as a file download.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isDownload(base_url + Drupal.settings.basePath + 'files/foo1.zip?foo=bar'), "Verify that '/files/foo1.zip?foo=bar' url is detected as a file download.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isDownload(base_url + Drupal.settings.basePath + 'files/foo1.zip?foo=bar#foo'), "Verify that '/files/foo1.zip?foo=bar#foo' url is detected as a file download.");
+ Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isDownload(base_url + Drupal.settings.basePath + 'files/foo2.ddd'), "Verify that '/files/foo2.ddd' url is not detected as file download.");
+ console.groupEnd();
+
+ console.group("Test 'isInternal':");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'node/1'), "Link '" + base_url + Drupal.settings.basePath + "node/2' has been detected as internal link.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'node/1#foo'), "Link '" + base_url + Drupal.settings.basePath + "node/1#foo' has been detected as internal link.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'node/1?foo=bar'), "Link '" + base_url + Drupal.settings.basePath + "node/1?foo=bar' has been detected as internal link.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'node/1?foo=bar#foo'), "Link '" + base_url + Drupal.settings.basePath + "node/1?foo=bar#foo' has been detected as internal link.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternal(base_url + Drupal.settings.basePath + 'go/foo'), "Link '" + base_url + Drupal.settings.basePath + "go/foo' has been detected as internal link.");
+ Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isInternal('https://example.com/node/3'), "Link 'https://example.com/node/3' has been detected as external link.");
+ console.groupEnd();
+
+ console.group("Test 'isInternalSpecial':");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isInternalSpecial(base_url + Drupal.settings.basePath + 'go/foo'), "Link '" + base_url + Drupal.settings.basePath + "go/foo' has been detected as special internal link.");
+ Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isInternalSpecial(base_url + Drupal.settings.basePath + 'node/1'), "Link '" + base_url + Drupal.settings.basePath + "node/1' has been detected as special internal link.");
+ console.groupEnd();
+
+ console.group("Test 'getPageUrl':");
+ Drupal.google_analytics.test.assertSame(base_path, Drupal.google_analytics.getPageUrl(window.location.href), "Absolute internal URL '" + base_path + "' has been extracted from full qualified url '" + window.location.href + "'.");
+ Drupal.google_analytics.test.assertSame(base_path, Drupal.google_analytics.getPageUrl(base_path), "Absolute internal URL '" + base_path + "' has been extracted from absolute url '" + base_path + "'.");
+ //Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(base_url + Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from full qualified url '" + base_url + base_path + "'.");
+ //Drupal.googleanalytics.test.assertSame(base_path, Drupal.googleanalytics.getPageUrl(Drupal.settings.basePath + 'node/1'), "Absolute internal URL '" + Drupal.settings.basePath + "node/1' has been extracted from absolute url '" + base_path + "'.");
+ Drupal.googleanalytics.test.assertSame('https://example.com/node/2', Drupal.googleanalytics.getPageUrl('https://example.com/node/2'), "Full qualified external url 'https://example.com/node/2' has been extracted.");
+ Drupal.googleanalytics.test.assertSame('//example.com/node/2', Drupal.googleanalytics.getPageUrl('//example.com/node/2'), "Full qualified external url '//example.com/node/2' has been extracted.");
+ console.groupEnd();
+
+ console.group("Test 'getDownloadExtension':");
+ Drupal.googleanalytics.test.assertSame('zip', Drupal.googleanalytics.getDownloadExtension(base_url + Drupal.settings.basePath + '/files/foo1.zip'), "Download extension 'zip' has been found in '" + base_url + Drupal.settings.basePath + "files/foo1.zip'.");
+ Drupal.googleanalytics.test.assertSame('zip', Drupal.googleanalytics.getDownloadExtension(base_url + Drupal.settings.basePath + '/files/foo1.zip#foo'), "Download extension 'zip' has been found in '" + base_url + Drupal.settings.basePath + "files/foo1.zip#foo'.");
+ Drupal.googleanalytics.test.assertSame('zip', Drupal.googleanalytics.getDownloadExtension(base_url + Drupal.settings.basePath + '/files/foo1.zip?foo=bar'), "Download extension 'zip' has been found in '" + base_url + Drupal.settings.basePath + "files/foo1.zip?foo=bar'.");
+ Drupal.googleanalytics.test.assertSame('zip', Drupal.googleanalytics.getDownloadExtension(base_url + Drupal.settings.basePath + '/files/foo1.zip?foo=bar#foo'), "Download extension 'zip' has been found in '" + base_url + Drupal.settings.basePath + "files/foo1.zip?foo=bar'.");
+ Drupal.googleanalytics.test.assertSame('', Drupal.googleanalytics.getDownloadExtension(base_url + Drupal.settings.basePath + '/files/foo2.dddd'), "No download extension found in '" + base_url + Drupal.settings.basePath + "files/foo2.dddd'.");
+ console.groupEnd();
+
+ // List of top-level domains: example.com, example.net
+ console.group("Test 'isCrossDomain' (requires cross domain configuration with 'example.com' and 'example.net'):");
+ if (Drupal.settings.googleanalytics.trackCrossDomains) {
+ console.dir(Drupal.settings.googleanalytics.trackCrossDomains);
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isCrossDomain('example.com', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'example.com' has been found in cross domain list.");
+ Drupal.googleanalytics.test.assertTrue(Drupal.googleanalytics.isCrossDomain('example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'example.net' has been found in cross domain list.");
+ Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isCrossDomain('www.example.com', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'www.example.com' not found in cross domain list.");
+ Drupal.googleanalytics.test.assertFalse(Drupal.googleanalytics.isCrossDomain('www.example.net', Drupal.settings.googleanalytics.trackCrossDomains), "URL 'www.example.net' not found in cross domain list.");
+ }
+ else {
+ console.warn('Cross domain tracking is not enabled. Tests skipped.');
+ }
+ console.groupEnd();
+
+});
+
+})(jQuery);
diff --git a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.variable.inc b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.variable.inc
index 36885de..5b88b1f 100644
--- a/sites/all/modules/contrib/admin/google_analytics/googleanalytics.variable.inc
+++ b/sites/all/modules/contrib/admin/google_analytics/googleanalytics.variable.inc
@@ -13,10 +13,11 @@ function googleanalytics_variable_info($options) {
'type' => 'string',
'title' => t('Web Property ID', array(), $options),
'default' => 'UA-',
- 'description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, register your site with Google Analytics, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. Find more information in the documentation.', array('@analytics' => 'http://www.google.com/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty'))), $options),
+ 'description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, register your site with Google Analytics, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. Find more information in the documentation.', array('@analytics' => 'https://marketingplatform.google.com/about/analytics/', '@webpropertyid' => url('https://developers.google.com/analytics/resources/concepts/gaConceptsAccounts', array('fragment' => 'webProperty'))), $options),
'required' => TRUE,
'group' => 'googleanalytics',
'localize' => TRUE,
+ 'multidomain' => TRUE,
'validate callback' => 'googleanalytics_validate_googleanalytics_account',
);
@@ -39,12 +40,16 @@ function googleanalytics_variable_group_info() {
/**
* Validate Web Property ID variable.
+ *
+ * @param array $variable
+ *
+ * @return string
*/
function googleanalytics_validate_googleanalytics_account($variable) {
// Replace all type of dashes (n-dash, m-dash, minus) with the normal dashes.
$variable['value'] = str_replace(array('–', '—', '−'), '-', $variable['value']);
- if (!preg_match('/^UA-\d{4,}-\d+$/', $variable['value'])) {
+ if (!preg_match('/^UA-\d+-\d+$/', $variable['value'])) {
return t('A valid Google Analytics Web Property ID is case sensitive and formatted like UA-xxxxxxx-yy.');
}
}
diff --git a/sites/all/modules/contrib/admin/module_filter/CHANGELOG.txt b/sites/all/modules/contrib/admin/module_filter/CHANGELOG.txt
index 4320cc1..5513831 100644
--- a/sites/all/modules/contrib/admin/module_filter/CHANGELOG.txt
+++ b/sites/all/modules/contrib/admin/module_filter/CHANGELOG.txt
@@ -1,41 +1,193 @@
-Module Filter 7.x-1.7, 2012-07-05
+Module Filter 7.x-2.1, 2017-06-09
---------------------------------
+Issue #2437439 by mikhail.krainiuk, greenSkin, jayhawkfan75: Module Filter does
+ not care about anchors in permission links.
+Issue #2866236 by Munavijayalakshmi, dhruveshdtripathi: Typo error in
+ README.TXT file.
+Issue #2452067 by Madis: Option to show description expanded as default
+ not working.
+Issue #2580791 by makbul_khan8: Coding standards and few function without
+ help comments.
+Issue #2153697 by annya: Disabling option "Number of enabled modules" breaks
+ tabs functionality.
+Issue #1710230 by willvincent: On | Off buttons does not change state with
+ jquery_update module active.
+Added option to show description as expanded by default.
+Improved description field so when it is open, interacting with it's contents
+ does not make it collapse.
+Placed collapsed/expanded images inside of module for easier, more reliable
+ access.
+Added option to place version in own column.
+Issue #2113191 by joelpittet: Category tabs not working.
+
+
+Module Filter 7.x-2.0, 2015-02-22
+---------------------------------
+Simplifying the table rows by hiding version and requirements until a
+ particular description is clicked.
+#2235553 by greenSkin: Fixed latest jquery_update breaks module filter.
+#2304687 by mpdonadio: Fixed Remove hardcoded operations.
+#2293029 by topsitemakers: Fixed Take header offset into account when selecting
+ a tab.
+#2290213 by topsitemakers: Minor typo in description - "has no affect" -> "has
+ no effect".
+#2141743, #2141743 by greenSkin: Fixed issues related to the new dynamically
+ positioned tabs and using the dynamically positioned save button.
+by greenSkin: Tabs now should always be visible while scrolling large lists of
+ modules.
+#1854348 by alexweber, greenSkin: Make filter textfield wider on modules page
+ when viewing as tabs.
+by greenSkin: Fixed what was suppose to be a call to variable_set().
+#1370492 by greenSkin: Remember selected tab after modules form submit.
+by greenSkin: Changed the title for the 'module_filter_dynamic_save_position'
+ checkbox to make it clearer what it does.
+#1166414 by greenSkin: Fixed broken submit when tabs are disabled. We no longer
+ reroute the theme of the system modules page unless tabs are enabled.
+by greenSkin: Fixed issue on Available updates page where the update state
+ would not be remembered.
+by greenSkin: Fixed 7200 update to rebuild the theme registry at the same time
+ as rebuilding the menu.
+by greenSkin: Fixed issue relating to row coloring when enabling/disabling
+ modules via switch due to recent fix for jQuery Update module.
+by greenSkin: Added functionality to show recently enabled/disabled modules.
+#1710230 by littlekoala, greenSkin: Fixed On | Off buttons does not change
+ state with jquery_update() module active.
+by greenSkin: Added description to filter textfield on permissions page.
+by greenSkin: Added filter to user permissions page.
+by greenSkin: Fixed styling when JavaScript is disabled.
+by greenSkin: Fixed compatiblility with page_actions.
+#1351184 klonos, greenSkin: Added support for update_advanced "Ignored from
+ settings".
+#1149978 by good_man, greenSkin: Added RTL Styling for tabs and toggle switch.
+by greenSkin: Hide toggle switch when JavaScript is disabled.
+by greenSkin: Added support for ctools dropbutton as well as views styling for
+ ctools dropbutton.
+by greenSkin: Improved hash validation.
+by greenSkin: Added ability for tabs to be disabled. Direct use case is when
+ the "New" tab contains zero new modules.
+by greenSkin: Added title to "New" tab link that helps to describe the criteria
+ of a "new" module.
+#1320796 by greenSkin: Added some validation checks before trying to select a
+ tab in case the tab does not actually exist.
+#1429248 by klonos, greenSkin: Fixed Modules page table header overlaps
+ admin_menu().
+#1494694 by greenSkin: Added Let me decide if I want the cursor to focus on the
+ search box or not.
+#1515256 by catmat, greenSkin: Fixed Tabbed theme may remove functional
+ content.
+by greenSkin: Integrated dynamic positioning of the save button back in, but
+ if the module page_actions is enabled we let it handle the save button. See
+ issue #1424994.
+by greenSkin: Clicking on module name now affects the toggle switch.
+by greenSkin: Do not render the switch for incompatible modules.
#1033012 by greenSkin: Hide incompatible module rows when the 'Unavailable'
checkbox is unchecked.
-#1170388 by greenSkin: Fixed conflict with Overlay module. Added class
- "overlay-exclude" to tab links.
+by greenSkin: Performance tweak to counting the number of enabled modules.
+by greenSkin: Base new modules on the filectime of their .info file.
+#1424034 by greenSkin: Now adds the jquery.cookie.js file when needed.
+by greenSkin: Removed tweaks to the save configuration button in favor
+ http://drupal.org/project/page_actions.
+by greenSkin: Updated hook_uninstall to del all Module Filter variables.
+by greenSkin: No longer including machine name in the tab summary of modules to
+ enable/disable.
+by greenSkin: Made switches honor disabled checkboxes. A disabled switch can
+ not be turned on or off.
+by greenSkin: Added setting to toggle between using the switch or checkbox for
+ enabling/disabling modules.
+by greenSkin: Centered enable switch.
+by greenSkin: Moved couple styles to be applied via JavaScript instead of CSS
+ so they get applied once the initial loading has finished.
+by greenSkin: Implemented a "switch" look instead of checkboxes.
+by greenSkin: Remember last selected state on "Available updates" page.
+by greenSkin: Switched to using filectime() rather than filemtime() for
+ determining new modules.
+#1354134 by klonos, greenSkin: Module list now formats correctly in core
+ "Garland" theme.
+#1354134 by klonos, greenSkin: Module list now formats correctly in core
+ "Garland" theme.
#1124218 by jyee, greenSkin: Suppress form submission when hitting the enter
key while the filter input is focused.
-
-
-Module Filter 7.x-1.6, 2011-09-15
----------------------------------
-#1241662 by Niklas Fiekas: Sort modules by display name.
+by greenSkin: Simplified filter rules for updates page. Instead of checkboxes,
+ now using radios.
+by greenSkin: Fixed "All" tab to be selected by default when the page is first
+ loaded.
+#1350124 by greenSkin: Fixed filtering on package tab.
+by greenSkin: Added the "All" tab back. Added a "New" tab that lists modules
+ installed within the last week.
+by greenSkin: Fixed "No Results" not showing within selected tabs.
+#1259876 by greenSkin: Filter criteria remembered after save.
+by greenSkin: Remove deprecated function moduleGetID() from JavaScript code.
+by greenSkin: Filter now uses OR instead of AND when filtering multiply
+ queries.
+#1288590 by greenSkin: Fixed Drupal.settings.moduleFilter.enabledCounts[id] is
+ undefined.
+#1344214 by eMPee584: Fixed Notice: Undefined index: #default_value in
+ theme_module_filter_system_modules_tabs().
+#1170388 by greenSkin: Fixed confict with Overlay module. Added class
+ "overlay-exclude" to tab links. Added setting to toggle the use of a URL
+ fragment when selecting tabs.
+by greenSkin: Added README.txt.
+by greenSkin: Fixed table row striping.
+by greenSkin: Fixed regular expression to not require an operator be at the
+ beginning. Make filter queries filter with AND instead of OR. Each query will
+ further filter the list rather than potentially add to it.
+by greenSkin: Spruced up the regular expression for splitting query strings.
+by greenSkin: Added "description:" operator.
+by greenSkin: Added operator support to filter. Added "requires:" and
+ "requiredBy:" operators.
+by greenSkin: Filter now processes multiple queries separated by spaces. Use
+ quotes for a single query that includes space(s).
+by greenSkin: Fixed not updating the index when a module is enabled/disabled.
+by greenSkin: Fixed visual aid for enabling/disabling modules. Previously had
+ failed to remove +/- from tab summary.
+by Kiphaas7, greenSkin: Tabs can now be configured to hide when they contain
+ no results.
+by Kiphaas7, greenSkin: Added result info to tabs. When a filter is performed,
+ a count per tab is displayed of the number of visible results for that tab.
+by greenSkin: Now more descriptive of what modules are being enabled/disabled.
+by greenSkin: Moved module operation links to below "Requires" and
+ "Required by" section.
+by greenSkin: Added a suggest class to tabs when their module is hovered.
+by greenSkin: Distinguished difference between tab ID and hash.
+by greenSkin: Only alter the menu item 'admin/reports/updates' if it first
+ exists.
+by greenSkin: Added update to force a menu rebuild. This is needed to let
+ Module Filter alter the Update Status menu item in order to provide our
+ filter on its page.
#1254140 by greenSkin: No longer return anything in hook_update_7100.
-by greenSkin: Fixed bug with visual aids sometimes not updating correctly.
-
-
-Module Filter 7.x-1.5, 2011-08-16
----------------------------------
-by greenSkin: Brought the 7.x branch current with the 6.x branch features.
-
-
-Module Filter 7.x-1.3, 2011-03-07
----------------------------------
-by realityloop: Updated CHANGELOG.txt
-
-
-Module Filter 7.x-1.2, 2011-03-07
----------------------------------
-by realityloop: Changed placement of Submit buttons for other languages
-
-
-Module Filter 7.x-1.1, 2011-03-07
----------------------------------
-by realityloop: first commit via git, broke the release somehow :/
-
-
-Module Filter 7.x-1.0, 2011-01-04
----------------------------------
-by realityloop: Fixed Undefined index error.
-by greenSkin: Removed unused .css and .js files.
+#1257860 by greenSkin: Added filter to update status report.
+by greenSkin: Moved hiding of the inputs wrapper to css rather than a style
+ attribute.
+by greenSkin: Added missing semi-colons in JavaScript.
+by greenSkin: Changed hook comment from using "Implementation of" to
+ "Implements".
+by greenSkin: Fixed showing all modules by default when no hash is present.
+by greenSkin: Turned off autocomplete for filter textfield.
+by greenSkin: Now using "all" for hash when no tab is selected.
+by greenSkin: Implemented visual aids (displays number of modules being
+ enabled/disabled as well as coloring the modules row accordingly).
+by greenSkin: Implemented the enabled count (displays the number of enabled
+ modules of total for a package.
+by greenSkin: Updated tabs setting description.
+by greenSkin: Added missing period.
+by greenSkin: Made dynamic save position default to on. Updated element title
+ on admin page and removed "DEVELOPMENTAL" from description.
+by greenSkin: Improved fixed-top positioning when toolbar is enabled.
+by greenSkin: Added fixed classes for submit button wrapper.
+by greenSkin: Changed module-filter-tabs from a class to an id.
+by greenSkin: Fixed filter on modules page when tabs are disabled.
+by greenSkin: Set min-height to #module-filter-modules.
+by greenSkin: Implemented module_filter element and using attached js and css
+ more.
+by greenSkin: Filter input and checkboxes can now have their default values set
+ based on query params.
+by greenSkin: Tabs now use URL fragments.
+by greenSkin: Fixed regular expression used to determine tab ID.
+by greenSkin: Tabs have been re-written and are functioning.
+by greenSkin: Added Module Filter to "Administration" package.
+by greenSkin: Improved filtering performance.
+by greenSkin: New filter code.
+by greenSkin: Initial tab layout modified. Modules are all in one table but
+ look like they are in packages. All JavaScript has to do on load now is
+ remove the package name and header rows from tbody then sort the rows.
+by greenSkin: Modified the menu item's description.
diff --git a/sites/all/modules/contrib/admin/module_filter/README.txt b/sites/all/modules/contrib/admin/module_filter/README.txt
new file mode 100644
index 0000000..b03d970
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/README.txt
@@ -0,0 +1,107 @@
+Description
+-----------
+This module provides a method for filtering modules on the modules page as well
+as for filtering projects on the update status report.
+
+The supplied filter is simpler than using your browsers find feature which
+searches the entire page. The provided filter will filter modules/projects that
+do not meet your input.
+
+Along with the filter textfield there are additional
+checkboxes that help to narrow the search more. The modules page contains four
+checkboxes: Enabled, Disabled, Required, and Unavailable. While the first two
+are self-explanatory, the latter two can take an explanation. The Required
+checkbox affects visibility of modules that are enabled and have other
+module(s) that require it also enabled. The Unavailable checkbox affects
+visibility of modules that are disabled and depend on module(s) that are
+missing.
+
+The update status report filter also contains four checkboxes: Up-to-Date,
+Update available, Security update, and Unknown. These directly affect the
+visibility of each project; whether it is up-to-date, there is an update
+available, a security update is available, or the status is unknown.
+
+Installation
+------------
+To install this module, do the following:
+
+1. Extract the tar ball that you downloaded from Drupal.org.
+
+2. Upload the entire directory and all its contents to your modules directory.
+
+Configuration
+-------------
+To enable and configure this module do the following:
+
+1. Go to Admin -> Modules, and enable Module Filter.
+
+2. Go to Admin -> Configuration -> User interface -> Module filter, and make
+ any necessary configuration changes.
+
+Tabs
+----
+By default Module Filter alters the modules page into tabs (Can be disabled on
+configuration page). In the tabs view, each package is converted to a vertical
+tab rather than a fieldset which greatly increases the ability to browse them.
+
+There are several benefits to using the tabs view over the standard view for
+the modules page. I've listed the key benefits below as well as additional
+information that pertains to each.
+
+1. The increased ease of browsing between packages.
+
+2. Allows all modules to be listed alphabetically outside of their package,
+ making it all the easier to find the module by name rather than package it
+ happens to be in.
+
+3. The operations for a module are moved within the description column giving
+ the description more "elbow room".
+
+4. Filtering is restricted to within the active tab or globally when no tab is
+ selected. By default no tab is selected which will list all modules. When a
+ tab is active and you want to get back to the 'all' state click on the
+ active tab to deselect it.
+
+5. The number of enabled modules per tab is shown on the active tab. (Can be
+ disabled on configuration page)
+
+6. Nice visual aids become available showing what modules are to be
+ enabled/disabled and the number of matching modules in each tab when
+ filtering. (Can be disabled on configuration page)
+
+7. The save configuration button becomes more accessible, either staying at
+ the bottom of the window when the tabs exceed past the bottom and at the
+ top when scrolling past the tabs. (Can be disabled on configuration page)
+
+8. When filtering, tabs that do not contain matches can be hidden. (Can be
+ enabled on configuration page)
+
+9. Tab states are remembered like individual pages allowing you to move
+ forward and backward within your selections via your browsers
+ forward/backward buttons.
+
+10. When viewing all modules (no active tab) and mousing over modules it's tab
+ becomes highlighted to signify which tab it belongs to.
+
+Filter operators
+----------------
+The modules page's filter has three filter operators available. Filter
+operators allow alternative filtering techniques. A filter operator is applied
+by typing within the filter textfield 'operator:' (where operator is the
+operator type) followed immediately with the string to pass to the operator
+function (e.g. 'requires:block'). The available operators are:
+
+description:
+ Filter based on a module's description.
+
+requiredBy:
+ Filter based on what a module is required by.
+
+requires:
+ Filter based on what a module requires.
+
+Multiple filters (or queries) can be applied by space delimiting. For example,
+the filter string 'description:ctools views' would filter down to modules with
+"ctools" in the description and "views" within the module's name. To pass a
+space within a single query wrap it within double quotes (e.g. 'requires:"chaos
+tools"' or '"bulk export"').
diff --git a/sites/all/modules/contrib/admin/module_filter/css/dynamic_position.css b/sites/all/modules/contrib/admin/module_filter/css/dynamic_position.css
new file mode 100644
index 0000000..bc3b3e7
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/css/dynamic_position.css
@@ -0,0 +1,23 @@
+html.js #module-filter-submit {
+ background-color: #F6F6F6;
+ width: 239px;
+ border: 1px solid #ccc;
+ border-top: 0;
+}
+html.js #module-filter-submit .form-actions {
+ text-align: center;
+ margin: 0;
+}
+html.js #module-filter-submit input {
+ margin: 2em 0 1em;
+}
+html.js #module-filter-submit.fixed {
+ position: fixed;
+ border-top: 1px solid #ccc;
+}
+html.js #module-filter-submit.fixed-top {
+ top: 0;
+}
+html.js #module-filter-submit.fixed-bottom {
+ bottom: 0;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/module_filter.css b/sites/all/modules/contrib/admin/module_filter/css/module_filter.css
index d2353ba..b03bbb7 100644
--- a/sites/all/modules/contrib/admin/module_filter/css/module_filter.css
+++ b/sites/all/modules/contrib/admin/module_filter/css/module_filter.css
@@ -1,4 +1,26 @@
-
+.module-filter-inputs-wrapper {
+ display: none;
+}
+.module-filter-clear {
+ display: inline;
+ position: relative;
+}
+.module-filter-clear a {
+ margin-left: 5px;
+ font-size: 11px;
+ position: absolute;
+}
#module-filter-show-wrapper .form-item {
display: inline;
}
+.module-filter-no-results {
+ text-align: center;
+ text-transform: uppercase;
+ color: #888;
+}
+#module-filter-modules {
+ position: relative;
+}
+#module-filter-modules table {
+ position: absolute;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab-rtl.css b/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab-rtl.css
new file mode 100644
index 0000000..b70f6ef
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab-rtl.css
@@ -0,0 +1,54 @@
+#module-filter-tabs {
+ float: right;
+}
+#module-filter-tabs li.selected a,
+#module-filter-tabs li.selected a:hover,
+#module-filter-tabs li.selected a:focus,
+#module-filter-tabs li.selected a:active {
+ background-color: #fff;
+ margin-left: -1px;
+ margin-right: 0;
+}
+.admin-operations {
+ float: left;
+}
+#module-filter-modules {
+ margin-right: 240px;
+}
+html.js .toggle-enable {
+ background-image: -webkit-gradient(linear, 100% 0%, 0% 0%, color-stop(50%, red), color-stop(50%, orange), color-stop(100%, orange));
+ background-image: -moz-linear-gradient(right, red 50%, orange 50%, orange 100%);
+ background-image: linear-gradient(right, red 50%, orange 50%, orange 100%);
+}
+html.js .toggle-enable.enabled {
+ background-image: -webkit-gradient(linear, 100% 0%, 0% 0%, color-stop(50%, orange), color-stop(50%, green), color-stop(100%, green));
+ background-image: -moz-linear-gradient(right, orange 50%, green 50%, green 100%);
+ background-image: linear-gradient(right, orange 50%, green 50%, green 100%);
+}
+html.js .toggle-enable.disabled {
+ background: #ccc;
+ border-color: #ddd;
+ cursor: auto;
+}
+html.js .toggle-enable.disabled div {
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #FEFEFE), color-stop(100%, #EEEEEE));
+ background-image: -moz-linear-gradient(top, #FEFEFE 0%, #EEEEEE 100%);
+ background-image: linear-gradient(top, #FEFEFE 0%, #EEEEEE 100%);
+}
+html.js .toggle-enable div {
+ -webkit-transition: right 0.2s;
+ -mox-transition: right 0.2s;
+ -o-transition: right 0.2s;
+ transition: right 0.2s;
+}
+html.js .toggle-enable div:before {
+ content: "ON";
+ left: -24px;
+}
+html.js .toggle-enable div:after {
+ content: "OFF";
+ left: -24px;
+}
+html.js .toggle-enable.off div {
+ right: 24px;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab.css b/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab.css
index 47e7337..fd7d0f0 100644
--- a/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab.css
+++ b/sites/all/modules/contrib/admin/module_filter/css/module_filter_tab.css
@@ -1,136 +1,259 @@
+.sticky-header {
+ z-index: 1;
+}
-#module-filter-wrapper .form-item {
- border: 0px none;
+#module-filter-tabs {
+ float: left;
+}
+#module-filter-tabs ul {
+ width: 239px;
+ list-style: none;
+ list-style-image: none;
+ background-color: #ddd;
+ border: 1px solid #ccc;
+ border-top: none;
+ margin: 0;
+ padding: 0;
+ line-height: 1;
+}
+#module-filter-tabs li {
+ background: #eee;
+ border-top: 1px solid #ccc;
+ padding: 0;
+ margin: 0;
+ min-width: 0;
+}
+#module-filter-tabs li#new-tab {
+ margin-bottom: 10px;
+ border-bottom: 1px solid #ccc;
+}
+#module-filter-tabs li.disabled,
+#module-filter-tabs li#new-tab.disabled {
+ pointer-events: none;
+ cursor: default;
+ background: #ccc;
+ border-top-color: #bbb;
+ border-bottom-color: #bbb;
+}
+#module-filter-tabs li.disabled a,
+#module-filter-tabs li.disabled span {
+ color: #999;
+}
+#module-filter-tabs li.suggest {
+ background: #F9F9F9;
+}
+#module-filter-tabs li a {
+ display: block;
+ text-decoration: none;
+ padding: 10px;
+}
+#module-filter-tabs li a span.result-info {
+ float: right;
+ font-size: 10px;
+ color: #999;
+ margin-top: 3px;
+}
+#module-filter-tabs li a span.visual-aid {
+ font-size: 8px;
+/* float: right;*/
+}
+#module-filter-tabs li span.visual-aid {
+ font-weight: bold;
+}
+#module-filter-tabs li a span.enabling {
+ color: green;
+}
+#module-filter-tabs li a span.disabling {
+ color: red;
+}
+#module-filter-tabs li strong {
+ font-size: 0.923em;
+}
+#module-filter-tabs li a:hover,
+#module-filter-tabs li a:focus {
+ outline: 1px dotted;
+ background: #d5d5d5;
+ text-decoration: none;
+ outline: 0;
+}
+#module-filter-tabs li.selected a,
+#module-filter-tabs li.selected a:hover,
+#module-filter-tabs li.selected a:focus,
+#module-filter-tabs li.selected a:active {
+ background-color: #fff;
+ margin-right: -1px;
+}
+#module-filter-tabs li .summary {
+ display: block;
+ margin-bottom: 0;
+ color: #666;
+ font-size: 0.846em;
+ padding-top: 0.4em;
+}
+#module-filter-tabs li .summary .count {
+ display: none;
+}
+#module-filter-tabs li.selected .summary .count {
+ display: block;
+}
+html.js #module-filter-submit input {
+ margin: 2em 2em 1em;
+}
+html.js .module-filter-inputs-wrapper {
+ text-align: center;
+}
+html.js .module-filter-inputs-wrapper .form-item {
margin: 0;
padding: 9px;
}
-#module-filter-wrapper .form-item:after {
-/* display: block;*/
- clear: none;
+html.js .module-filter-inputs-wrapper label {
+ display: inline;
}
-#module-filter-left {
- float: left;
- background-color: #F6F6F6;
- border: 1px solid #D6DBDE;
- margin-right: -1px;
- width: 185px;
+html.js .module-filter-inputs-wrapper input[name="module_filter[name]"] {
+ width: 80%;
}
-#module-filter-left ul {
- margin: 0px;
- padding: 0px;
- list-style: none;
+html.js #module-filter-show-wrapper {
+ margin-bottom: 1em;
}
-#module-filter-left ul li {
- background: #EFEFEF none repeat scroll 0 0;;
- border-bottom: 1px solid #D6DBDE;
- margin: 0px;
- padding: 0px;
- list-style-image: none;
+html.js #module-filter-modules {
+ margin-left: 240px;
+ border: 1px solid #ccc;
}
-#module-filter-left ul li.active {
- margin-right: -1px;
- width: 186px;
- background-color: #FFFFFF;
- position: relative;
+#module-filter-modules table {
+ border-top: none;
+ border-right: none;
+ border-left: none;
}
-#module-filter-left ul li a {
- color: #777777;
- display: block;
- padding: 0.5em;
- line-height: 100%;
- font-size: 90%;
- outline: none;
-}
-#module-filter-left ul li.active a {
- background-color: #FFFFFF;
- color: #000000;
- font-weight: bold;
-}
-#module-filter-left ul li a:hover {
- background-color: #F6F6F6;
- text-decoration: none;
-}
-#module-filter-left ul li.active a:hover {
- background-color: #FFFFFF;
-}
-#module-filter-left ul li a span.visual-aid {
- font-size: 8px;
- float: right;
-}
-#module-filter-left ul li a span.enabling {
- color: green;
-}
-#module-filter-left ul li a span.disabling {
- color: red;
- margin-left: 5px;
-}
-#module-filter-left ul li a span.counts {
- font-weight: normal;
- display: none;
- font-size: 0.8em;
- color: #333333;
- padding: 2px 0 0;
-}
-#module-filter-left ul li.active a span.counts {
- display: block;
-}
-#module-filter-submit {
+html.js #module-filter-modules table {
margin: 0;
+ border-bottom: none;
}
-#module-filter-submit .form-actions {
- text-align: center;
+html.js #module-filter-modules table tr,
+html.js #module-filter-modules table td {
+ border-left: 0;
+ border-right: 0;
}
-#module-filter-submit input.form-submit {
- margin: 1em 0 0;
+#module-filter-modules table thead {
+ display: none;
}
-#module-filter-submit.fixed {
- position: fixed;
- background-color: #F6F6F6;
- border: 1px solid #D6DBDE;
- margin-left: -1px;
- width: 185px;
+#module-filter-modules table tr.admin-package-title,
+#module-filter-modules table tr.admin-package-title td {
+ border: none !important;
+ border-top: 1px solid #ccc !important;
+ background-color: transparent !important;
+ padding: 10px 0 0;
}
-#module-filter-submit.fixed-top {
- top: 0;
+#module-filter-modules table tr.admin-package-title.first,
+#module-filter-modules table tr.admin-package-title.first td {
+ border-top: none !important;
}
-#module-filter-submit.fixed-bottom {
- bottom: 0;
+#module-filter-modules table tr.admin-package-header td {
+ border: 1px solid #ccc;
+ text-transform: uppercase;
+ background: #E1E2DC;
+ font-weight: normal;
+ padding: 3px 10px;
}
-#module-filter-right {
- display: block;
-}
-#module-filter-squeeze {
- margin-left: 186px;
- background-color: #FFFFFF;
- border: 1px solid #D6DBDE;
- height: auto !important;
-}
-.form-item-module-filter-name {
- text-align: center;
-}
-.form-item-module-filter-name label {
- display: inline;
-}
-#module-filter-show-wrapper .form-checkboxes {
- text-align: center;
-}
-#module-filter-show-wrapper .form-item:after {
- display: inline;
-}
-table.package {
- margin: 1em 0;
-}
-table.package,
-table.package thead,
-table.package tbody,
-table.package tbody tr,
-table.package td:last-child {
- border-right: 0 none;
- border-left: 0 none;
-}
-table.package tr.enabling {
+#module-filter-modules table tr.enabling {
background-color: #dfd;
}
-table.package tr.disabling {
+#module-filter-modules table tr.disabling {
background-color: #fcc;
}
+#module-filter-modules span.module-machine-name {
+ font-size: 0.9em;
+ font-weight: normal;
+}
+.admin-version {
+ white-space: nowrap;
+}
+.admin-operations a.module-link {
+ display: inline;
+}
+
+html.js .toggle-enable {
+ margin: auto;
+ position: relative;
+ width: 50px;
+ overflow: hidden;
+ height: 18px;
+ line-height: 18px;
+ font-size: 11px;
+ text-align: center;
+ cursor: pointer;
+ border: 1px solid #ccc;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ -khtml-border-radius: 3px;
+ border-radius: 3px;
+ -moz-box-shadow: 0 0 10px rgba(0,0,0,0.50) inset;
+ -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.50) inset;
+ box-shadow: 0 0 10px rgba(0,0,0,0.50) inset;
+ background-clip: padding-box;
+ background-image: -webkit-gradient(linear, 0% 0%, 100% 0%, color-stop(50%, red), color-stop(50%, orange), color-stop(100%, orange));
+ background-image: -moz-linear-gradient(left, red 50%, orange 50%, orange 100%);
+ background-image: linear-gradient(left, red 50%, orange 50%, orange 100%);
+}
+html.js .toggle-enable.enabled {
+ background-image: -webkit-gradient(linear, 0% 0%, 100% 0%, color-stop(50%, orange), color-stop(50%, green), color-stop(100%, green));
+ background-image: -moz-linear-gradient(left, orange 50%, green 50%, green 100%);
+ background-image: linear-gradient(left, orange 50%, green 50%, green 100%);
+}
+html.js .toggle-enable.disabled {
+ background: #ccc;
+ border-color: #ddd;
+ cursor: auto;
+}
+html.js .toggle-enable div {
+ position: relative;
+ color: #777;
+ width: 26px;
+ -moz-border-radius: 2px;
+ -webkit-border-radius: 2px;
+ -khtml-border-radius: 2px;
+ border-radius: 2px;
+ background: white;
+ text-shadow: 1px 1px 0 white;
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #FEFEFE), color-stop(100%, #EAEAEA));
+ background-image: -moz-linear-gradient(top, #FEFEFE 0%, #EAEAEA 100%);
+ background-image: linear-gradient(top, #FEFEFE 0%, #EAEAEA 100%);
+ -webkit-transition: left 0.2s;
+ -mox-transition: left 0.2s;
+ -o-transition: left 0.2s;
+ transition: left 0.2s;
+}
+html.js .toggle-enable.disabled div {
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #FEFEFE), color-stop(100%, #EEEEEE));
+ background-image: -moz-linear-gradient(top, #FEFEFE 0%, #EEEEEE 100%);
+ background-image: linear-gradient(top, #FEFEFE 0%, #EEEEEE 100%);
+}
+html.js .toggle-enable div:after,
+html.js .toggle-enable div:before {
+ color: white;
+ text-shadow: none;
+ width: 25px;
+ position: absolute;
+ top: 0;
+ font-size: 9px;
+ font-weight: bold;
+}
+html.js .toggle-enable div:before {
+ content: "OFF";
+ left: -24px;
+}
+html.js .toggle-enable div:after {
+ content: "ON";
+ right: -24px;
+}
+html.js .toggle-enable.off div {
+ left: 24px;
+}
+
+#module-filter-tabs.top-fixed {
+ position: fixed;
+ top: 0;
+}
+#module-filter-tabs.bottom-fixed {
+ position: fixed;
+ bottom: 0;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/modules.css b/sites/all/modules/contrib/admin/module_filter/css/modules.css
new file mode 100644
index 0000000..0659825
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/css/modules.css
@@ -0,0 +1,53 @@
+#system-modules table {
+ table-layout: fixed;
+}
+#system-modules th.checkbox {
+ width: 8%;
+}
+#system-modules th.name {
+ width: 25%;
+}
+#system-modules th.version {
+ width: 10%;
+}
+#system-modules th.links {
+ width: 15%;
+}
+#system-modules td {
+ vertical-align: top;
+}
+#system-modules .expand.inner {
+ background: transparent url(../images/collapsed.png) left 0.6em no-repeat;
+ margin-left: -12px;
+ padding-left: 12px;
+}
+#system-modules .expanded.expand.inner {
+ background: transparent url(../images/expanded.png) left 0.6em no-repeat;
+}
+#system-modules .description {
+ cursor: pointer;
+}
+#system-modules .description .inner {
+ overflow: hidden; /* truncates descriptions if too long */
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+#system-modules .description .inner.expanded > * {
+ cursor: auto;
+}
+#system-modules .description .requirements,
+#system-modules .description .links {
+ display: none;
+}
+#system-modules .description .expanded.inner {
+ overflow: visible;
+ white-space: normal;
+}
+#system-modules .description .expanded .requirements,
+#system-modules .description .expanded .links {
+ display: block;
+}
+#system-modules .requirements {
+ padding: 5px 0;
+ max-width: 490px;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/css/update_status.css b/sites/all/modules/contrib/admin/module_filter/css/update_status.css
new file mode 100644
index 0000000..c0bee44
--- /dev/null
+++ b/sites/all/modules/contrib/admin/module_filter/css/update_status.css
@@ -0,0 +1,18 @@
+#module-filter-update-status-form {
+ float: right;
+}
+.module-filter-inputs-wrapper label {
+ display: inline;
+}
+.module-filter-inputs-wrapper .form-item-module-filter-name {
+ margin-bottom: 0;
+ padding-bottom: 0;
+ text-align: right;
+}
+#module-filter-show-wrapper .form-item {
+ padding: 5px;
+}
+p.module-filter-no-results {
+ clear: both;
+ padding-top: 30px;
+}
diff --git a/sites/all/modules/contrib/admin/module_filter/images/collapsed.png b/sites/all/modules/contrib/admin/module_filter/images/collapsed.png
new file mode 100644
index 0000000..91f3fd4
Binary files /dev/null and b/sites/all/modules/contrib/admin/module_filter/images/collapsed.png differ
diff --git a/sites/all/modules/contrib/admin/module_filter/images/expanded.png b/sites/all/modules/contrib/admin/module_filter/images/expanded.png
new file mode 100644
index 0000000..46f39ec
Binary files /dev/null and b/sites/all/modules/contrib/admin/module_filter/images/expanded.png differ
diff --git a/sites/all/modules/contrib/admin/module_filter/js/dynamic_position.js b/sites/all/modules/contrib/admin/module_filter/js/dynamic_position.js
index 10c66b4..41c5731 100644
--- a/sites/all/modules/contrib/admin/module_filter/js/dynamic_position.js
+++ b/sites/all/modules/contrib/admin/module_filter/js/dynamic_position.js
@@ -1,33 +1,48 @@
(function($) {
- Drupal.behaviors.moduleFilterDynamicPosition = {
- attach: function() {
- $(window).scroll(function() {
+
+Drupal.behaviors.moduleFilterDynamicPosition = {
+ attach: function(context) {
+ var $window = $(window);
+
+ $('#module-filter-wrapper', context).once('dynamic-position', function() {
+ // Move the submit button just below the tabs.
+ $('#module-filter-tabs').append($('#module-filter-submit'));
+
+ var positionSubmit = function() {
+ var $tabs = $('#module-filter-tabs');
+ var $submit = $('#module-filter-submit', $tabs);
+
// Vertical movement.
- var top = $('#module-filter-tabs').offset().top;
- var bottom = top + $('#module-filter-tabs').height();
- var windowHeight = $(window).height();
- if (((bottom - windowHeight) > ($(window).scrollTop() - $('#module-filter-submit').height())) && $(window).scrollTop() + windowHeight - $('#module-filter-submit').height() - $('#all-tab').height() > top) {
- $('#module-filter-submit').removeClass('fixed-top').addClass('fixed fixed-bottom');
+ var bottom = $tabs.offset().top + $tabs.outerHeight();
+ if ($submit.hasClass('fixed-bottom')) {
+ bottom += $submit.height();
}
- else if (bottom < $(window).scrollTop()) {
- $('#module-filter-submit').removeClass('fixed-bottom').addClass('fixed fixed-top');
+ if (bottom >= $window.height() + $window.scrollTop()) {
+ $submit.addClass('fixed fixed-bottom');
+ $tabs.css('padding-bottom', $submit.height());
}
else {
- $('#module-filter-submit').removeClass('fixed fixed-bottom fixed-top');
+ $submit.removeClass('fixed fixed-bottom');
+ $tabs.css('padding-bottom', 0);
}
// Horizontal movement.
- if ($('#module-filter-submit').hasClass('fixed-bottom') || $('#module-filter-submit').hasClass('fixed-top')) {
- var left = $('#module-filter-tabs').offset().left - $(window).scrollLeft();
- if (left != $('#module-filter-submit').offset().left - $(window).scrollLeft()) {
- $('#module-filter-submit').css('left', left);
+ if ($submit.hasClass('fixed-bottom') || $submit.hasClass('fixed-top')) {
+ var left = $tabs.offset().left - $window.scrollLeft();
+ if (left != $submit.offset().left - $window.scrollLeft()) {
+ $submit.css('left', left);
}
}
- });
- $(window).trigger('scroll');
- $(window).resize(function() {
- $(window).trigger('scroll');
- });
- }
+ };
+
+ // Control the positioning.
+ $window.scroll(positionSubmit);
+ $window.resize(positionSubmit);
+ var moduleFilter = $('input[name="module_filter[name]"]').data('moduleFilter');
+ moduleFilter.element.bind('moduleFilter:adjustHeight', positionSubmit);
+ moduleFilter.adjustHeight();
+ });
}
+};
+
})(jQuery);
diff --git a/sites/all/modules/contrib/admin/module_filter/js/module_filter.js b/sites/all/modules/contrib/admin/module_filter/js/module_filter.js
index 5c807f1..4fcf6e6 100644
--- a/sites/all/modules/contrib/admin/module_filter/js/module_filter.js
+++ b/sites/all/modules/contrib/admin/module_filter/js/module_filter.js
@@ -1,120 +1,274 @@
-
(function ($) {
- var moduleFilterTimeOut;
- var moduleFilterTextFilter = '';
- Drupal.behaviors.moduleFilter = {
- attach: function() {
- $("#module-filter-wrapper").show();
- $('input[name="module_filter[name]"]').focus();
- $('input[name="module_filter[name]"]').keyup(function(e) {
- switch (e.which) {
- case 13:
- if (moduleFilterTimeOut) {
- clearTimeout(moduleFilterTimeOut);
- }
+Drupal.ModuleFilter = {};
- moduleFilter(moduleFilterTextFilter);
- break;
- default:
- if (moduleFilterTextFilter != $(this).val()) {
- moduleFilterTextFilter = this.value;
- if (moduleFilterTimeOut) {
- clearTimeout(moduleFilterTimeOut);
- }
+Drupal.ModuleFilter.explode = function(string) {
+ var queryArray = string.match(/([a-zA-Z]+\:(\w+|"[^"]+")*)|\w+|"[^"]+"/g);
+ if (!queryArray) {
+ queryArray = new Array();
+ }
+ var i = queryArray.length;
+ while (i--) {
+ queryArray[i] = queryArray[i].replace(/"/g, "");
+ }
+ return queryArray;
+};
- moduleFilterTimeOut = setTimeout('moduleFilter("' + moduleFilterTextFilter + '")', 500);
- }
- break;
+Drupal.ModuleFilter.getState = function(key) {
+ if (!Drupal.ModuleFilter.state) {
+ Drupal.ModuleFilter.state = {};
+ var cookie = $.cookie('DrupalModuleFilter');
+ var query = cookie ? cookie.split('&') : [];
+ if (query) {
+ for (var i in query) {
+ // Extra check to avoid js errors in Chrome, IE and Safari when
+ // combined with JS like twitter's widget.js.
+ // See http://drupal.org/node/798764.
+ if (typeof(query[i]) == 'string' && query[i].indexOf('=') != -1) {
+ var values = query[i].split('=');
+ if (values.length === 2) {
+ Drupal.ModuleFilter.state[values[0]] = values[1];
+ }
}
- });
- $('input[name="module_filter[name]"]').keypress(function(e) {
- if (e.which == 13) e.preventDefault();
- });
-
- $('#edit-module-filter-show-enabled').change(function() {
- moduleFilter($('input[name="module_filter[name]"]').val());
- });
- $('#edit-module-filter-show-disabled').change(function() {
- moduleFilter($('input[name="module_filter[name]"]').val());
- });
- $('#edit-module-filter-show-required').change(function() {
- moduleFilter($('input[name="module_filter[name]"]').val());
- });
- $('#edit-module-filter-show-unavailable').change(function() {
- moduleFilter($('input[name="module_filter[name]"]').val());
- });
+ }
}
}
+ return Drupal.ModuleFilter.state[key] ? Drupal.ModuleFilter.state[key] : false;
+};
- moduleFilter = function(string) {
- stringLowerCase = string.toLowerCase();
+Drupal.ModuleFilter.setState = function(key, value) {
+ var existing = Drupal.ModuleFilter.getState(key);
+ if (existing != value) {
+ Drupal.ModuleFilter.state[key] = value;
+ var query = [];
+ for (var i in Drupal.ModuleFilter.state) {
+ query.push(i + '=' + Drupal.ModuleFilter.state[i]);
+ }
+ $.cookie('DrupalModuleFilter', query.join('&'), { expires: 7, path: '/' });
+ }
+};
- $("fieldset table tbody tr td label > strong").each(function(i) {
- var $row = $(this).parents('tr');
- var module = $(this).text();
- var moduleLowerCase = module.toLowerCase();
- var $fieldset = $row.parents('fieldset');
+Drupal.ModuleFilter.Filter = function(element, selector, options) {
+ var self = this;
- if (string != '') {
- if ($fieldset.hasClass('collapsed')) {
- $fieldset.removeClass('collapsed');
+ this.element = element;
+ this.text = $(this.element).val();
+
+ this.settings = Drupal.settings.moduleFilter;
+
+ this.selector = selector;
+
+ this.options = $.extend({
+ delay: 500,
+ striping: false,
+ childSelector: null,
+ empty: Drupal.t('No results'),
+ rules: new Array()
+ }, options);
+ if (this.options.wrapper == undefined) {
+ this.options.wrapper = $(self.selector).parent();
+ }
+
+ // Add clear button.
+ this.element.after('
';
+ }
+}
diff --git a/sites/all/modules/contrib/dev/ctools/API.txt b/sites/all/modules/contrib/dev/ctools/API.txt
index e0441d6..b698b79 100644
--- a/sites/all/modules/contrib/dev/ctools/API.txt
+++ b/sites/all/modules/contrib/dev/ctools/API.txt
@@ -3,6 +3,9 @@ Current API Version: 2.0.8
Please note that the API version is an internal number and does not match release numbers. It is entirely possible that releases will not increase the API version number, and increasing this number too often would burden contrib module maintainers who need to keep up with API changes.
This file contains a log of changes to the API.
+API Version 2.0.9
+Changed import permissions to use the new 'use ctools import' permission.
+
API Version 2.0.8
Introduce ctools_class_add().
Introduce ctools_class_remove().
diff --git a/sites/all/modules/contrib/dev/ctools/CHANGELOG.txt b/sites/all/modules/contrib/dev/ctools/CHANGELOG.txt
deleted file mode 100644
index c5bd5e6..0000000
--- a/sites/all/modules/contrib/dev/ctools/CHANGELOG.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-Current API VERSION: 2.0. See API.txt for more information.
-
-ctools 7.x-1.x-dev
-==================
-#1008120: "New custom content" shows empty form if custom content panes module is not enabled.
-#999302 by troky: Fix jump menu. Apparently this wasn't actually committed the last time it was committed.
-#1065976 by tekante and David_Rothstein: Reset plugin static cache during module enable to prevent stale data from harming export ui.
-#1016510 by EclipseGC: Make the taxonomy system page functional.
-
-ctools 7.x-1.x-alpha2 (05-Jan-2011)
-===================================
-
-#911396 by alex_b: Prevent notices in export UI.
-#919768 by mikey_p: Allow url options to be sent to ctools_ajax_command_url().
-#358953 by cedarm: Allow term context to return lowercase, spaces to dashes versions of terms.
-#931434 by EclipseGc: Argument plugin for node revision ID.
-#910656: CTools AJAX sample wizard demo "domesticated" checkbox value not stored.
-#922442 by EugenMayer, neclimdul and voxpelli: Make sure ctools_include can handle '' or NULL directory.
-#919956 by traviss359: Correct example in wizard advanced help.
-#942968: Fix taxonomy term access rule with tag term vocabs.
-#840344: node add argument had crufty code causing notices.
-#944462 by longhairedgit: Invalid character in regex causes rare notice.
-#938778 by dereine: Fix profile content type for D7 updates.
-Add detach event to modal close so that wysiwyg can detach the editor.
-Variant titles showing up as blank if more than one variant on a page.
-#940016: token support was not yet updated for D7.
-#940446: Skip validation on back and cancel buttons in all wizards.
-#954492: Redirect not always working in wizard.inc
-#955348: Lack of redirect on "Update" button in Page Manager causing data loss sometimes.
-#941778: Update and save button should not appear in the "Add variant" path.
-#955070 by EclipseGc: Update ctools internal page tokens to work properly on content all content.
-#956890 by EclipseGc: Update views_content to not use views dependency since that is gone.
-#954728 by EclipseGc: Update node template page function name to not collide with new hook_node_view().
-#946534 by EclipseGc: Add support for field content on all entitities.
-#952586 by EclipseGc: Fix node_author content type.
-#959206: If a context is not set when rendering content, attempt to guess the context (fixes Views panes where "From context" was added but pane was never edited.)
-#961654 by benshell: drupal_alter() only supports 4 arguments.
-#911362 by alex_b: Facilitate plugin cache resets for tests.
-#945360 by naxoc: node_tag_new() not updated to D7.
-#953804 by EclipseGc: Fix node comment rendering.
-#953542 by EclipseGc: Fix node rendering.
-#953776 by EclipseGc: Fix node link rendering.
-#954772 by EclipseGc: Fix node build mode selection in node content type.
-#954762 by EclipseGc: Fix comment forbidden theme call.
-#954894 by EclipseGc: Fix breadcrumb content type.
-#955180 by EclipseGc: Fix page primary navigation type.
-#957190 by EclipseGc: Fix page secondary navigation type.
-#957194 by EclipseGc: Remove mission content type, since D7 no longer has a site mission.
-#957348 by EclipseGc: Fix search form URL path.
-#952586 by andypost: Use format_username for displaying unlinked usernames.
-#963800 by benshell: Fix query to fetch custom block title.
-#983496 by Amitaibu: Fix term argument to use proper load function.
-#989484 by Amitaibu: Fix notice in views plugin.
-#982496: Fix token context.
-#995026: Fix export UI during enable/disable which would throw notices and not properly set/unset menu items.
-#998870 by Amitaibu: Fix notice when content has no icon by using function already designed for that.
-#983576 by Amitaibu: Node view fallback task showed white screen.
-#1004644 by pillarsdotnet: Update a missed theme() call to D7.
-#1006162 by aspilicious: .info file cleanup.
-#998312 by dereine: Support the expanded/hidden options that Views did for dependent.js
-#955030: Remove no longer supported footer message content type.
-Fix broken query in term context config.
-#992022 by pcambra: Fix node autocomplete.
-#946302 by BerdArt and arywyr: Fix PHP 5.3 reference error.
-#980528 by das-peter: Notice fix with entity settings.
-#999302 by troky: ctools_jump_menu() needed updating to new form parameters.
-#964174: stylizer plugin theme delegation was in the wrong place, causing errors.
-#991658 by burlap: Fully load the "user" context for the logged in user because not all fields are in $user.
-#1014866 by das-peter: Smarter title panes, notice fix on access plugin descriptions.
-#1015662 by troky: plugin .info files were not using correct filepaths.
-#941780 by EclipseGc: Restore the "No blocks" functionality.
-#951048 by EclipseGc: Tighter entity integration so that new entities are automatic contexts and relationships.
-#941800 by me and aspilicious: Use Drupal 7 #machine_name automation on page manager pages and all export_ui defaults.
-Disabled exportables and pages not properly greyed out.
-#969208 by me and benshell: Get user_view and user profile working.
-#941796: Recategorize blocks
-
-ctools 7.x-1.x-alpha1
-=====================
-
-Changelog reset for 7.x
-Basic conversion done during sprint.
diff --git a/sites/all/modules/contrib/dev/ctools/UPGRADE.txt b/sites/all/modules/contrib/dev/ctools/UPGRADE.txt
index 844ecce..2fbfa4f 100644
--- a/sites/all/modules/contrib/dev/ctools/UPGRADE.txt
+++ b/sites/all/modules/contrib/dev/ctools/UPGRADE.txt
@@ -60,4 +60,4 @@ Upgrading from ctools-6.x-1.x to ctools-7.x-2.x:
For all of these forms, the separate settings #trees in the form are now
gone, so form ids may be adjusted. Also, these are now all real forms
- using CTools form wizard instead of fake subforms as previously.
\ No newline at end of file
+ using CTools form wizard instead of fake subforms as previously.
diff --git a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info
index d27ea9a..9bb3394 100644
--- a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info
+++ b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.info
@@ -4,9 +4,8 @@ core = 7.x
dependencies[] = ctools
package = Chaos tool suite
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.module b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.module
index afb15b9..1050caa 100644
--- a/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.module
+++ b/sites/all/modules/contrib/dev/ctools/bulk_export/bulk_export.module
@@ -137,7 +137,7 @@ function bulk_export_export($cli = FALSE, $options = array()) {
// Add hook_ctools_plugin_api at the top of the module code, if there is any.
if ($api_code) {
foreach ($api_code as $api_hook => $text) {
- $api = "\n/**\n";
+ $api = "\n/**\n";
$api .= " * Implements hook_$api_hook().\n";
$api .= " */\n";
$api .= "function {$module_name}_$api_hook(\$module, \$api) {\n";
@@ -148,7 +148,7 @@ function bulk_export_export($cli = FALSE, $options = array()) {
}
if ($module_code) {
- $module = " fieldset {
+ clear: none;
+}
+
div.ctools-modal-content .resizable-textarea {
width: auto;
margin-left: 15em;
diff --git a/sites/all/modules/contrib/dev/ctools/css/stylizer.css b/sites/all/modules/contrib/dev/ctools/css/stylizer.css
index a16ec78..fc8dcb2 100644
--- a/sites/all/modules/contrib/dev/ctools/css/stylizer.css
+++ b/sites/all/modules/contrib/dev/ctools/css/stylizer.css
@@ -1,4 +1,3 @@
-
/* Farbtastic placement */
.color-form {
max-width: 50em;
@@ -32,7 +31,8 @@
clear: left; /* LTR */
width: 14em;
}
-.color-form .form-text, .color-form .form-select {
+.color-form .form-text,
+.color-form .form-select {
float: left; /* LTR */
}
.color-form .form-text {
@@ -84,7 +84,7 @@
cursor: default;
}
-.ctools-style-icons .form-item {
+.ctools-style-icons .form-item {
width: 100px;
float: left;
margin: 0 3px !important;
diff --git a/sites/all/modules/contrib/dev/ctools/css/wizard.css b/sites/all/modules/contrib/dev/ctools/css/wizard.css
index d42a2db..ab80def 100644
--- a/sites/all/modules/contrib/dev/ctools/css/wizard.css
+++ b/sites/all/modules/contrib/dev/ctools/css/wizard.css
@@ -1,4 +1,3 @@
-
.wizard-trail {
font-size: 120%;
}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.api.php b/sites/all/modules/contrib/dev/ctools/ctools.api.php
index a7ab783..4481291 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.api.php
+++ b/sites/all/modules/contrib/dev/ctools/ctools.api.php
@@ -17,9 +17,9 @@
* Inform CTools about plugin types.
*
* @return array
- * An array of plugin types, keyed by the type name.
- * See the advanced help topic 'plugins-creating' for details of the array
- * properties.
+ * An array of plugin types, keyed by the type name.
+ * See the advanced help topic 'plugins-creating' for details of the array
+ * properties.
*/
function hook_ctools_plugin_type() {
$plugins['my_type'] = array(
@@ -65,6 +65,7 @@ function hook_ctools_plugin_type() {
* directory location is being requested.
* @param string $plugin_type
* The name of the plugin type for which a base directory is being requested.
+ *
* @return string
* The path where CTools' plugin system should search for plugin files,
* relative to your module's root. Omit leading and trailing slashes.
@@ -94,7 +95,7 @@ function hook_ctools_plugin_directory($owner, $plugin_type) {
// Yes, this is exactly like Form 2 - just a different reasoning for it.
return "plugins/$plugin_type";
}
- // Finally, if nothing matches, it's safe to return nothing at all (or NULL).
+ // Finally, if nothing matches, it's safe to return nothing at all (== NULL).
}
/**
@@ -155,7 +156,7 @@ function hook_ctools_api_hook_alter(&$list) {
* allow to use it in the math expression api.
*
* @param $functions
- * An array which has the functions as value.
+ * An array which has the functions as value.
*/
function hook_ctools_math_expression_functions_alter(&$functions) {
// Allow to convert from degrees to radiant.
@@ -199,7 +200,13 @@ function hook_ctools_render_alter(&$info, &$page, &$context) {
* or categories or to rename content on specific sites.
*/
function hook_ctools_content_subtype_alter($subtype, $plugin) {
- $subtype['render last'] = TRUE;
+ // Force a particular subtype of a particular plugin to render last.
+ if ($plugin['module'] === 'some_plugin_module'
+ && $plugin['name'] === 'some_plugin_name'
+ && $subtype['subtype_id'] === 'my_subtype_id'
+ ) {
+ $subtype['render last'] = TRUE;
+ }
}
/**
@@ -225,6 +232,28 @@ function hook_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) {
}
}
+/**
+ * Alter the conversion of context items by ctools context plugin convert()s.
+ *
+ * @param ctools_context $context
+ * The current context plugin object. If this implemented a 'convert'
+ * function, the value passed in has been processed by that function.
+ * @param string $converter
+ * A string associated with the plugin type, identifying the operation.
+ * @param string $value
+ * The value being converted; this is the only return from the function.
+ * @param $converter_options
+ * Array of key-value pairs to pass to a converter function from higher
+ * levels.
+ *
+ * @see ctools_context_convert_context()
+ */
+function hook_ctools_context_converter_alter($context, $converter, &$value, $converter_options) {
+ if ($converter === 'mystring') {
+ $value = 'fixed';
+ }
+}
+
/**
* Alter the definition of entity context plugins.
*
@@ -263,6 +292,22 @@ function hook_ctools_cleanstring_CLEAN_ID_alter(&$settings) {
$settings['lower case'] = TRUE;
}
+/**
+ * Let other modules modify the context handler before it is rendered.
+ *
+ * @param object $handler
+ * A handler for a current task and subtask.
+ * @param array $contexts
+ * An associative array of contexts.
+ * @param array $args
+ * An array for current args.
+ *
+ * @see ctools_context_handler_pre_render()
+ */
+function ctools_context_handler_pre_render($handler, $contexts, $args) {
+ $handler->conf['css_id'] = 'my-id';
+}
+
/**
* @} End of "addtogroup hooks".
*/
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.info b/sites/all/modules/contrib/dev/ctools/ctools.info
index 8a7b0b6..188b55d 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools.info
@@ -3,12 +3,24 @@ description = A library of helpful tools by Merlin of Chaos.
core = 7.x
package = Chaos tool suite
files[] = includes/context.inc
+files[] = includes/css-cache.inc
files[] = includes/math-expr.inc
files[] = includes/stylizer.inc
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Tests.
+files[] = tests/context.test
+files[] = tests/css.test
+files[] = tests/css_cache.test
+files[] = tests/ctools.plugins.test
+files[] = tests/ctools.test
+files[] = tests/math_expression.test
+files[] = tests/math_expression_stack.test
+files[] = tests/object_cache.test
+files[] = tests/object_cache_unit.test
+files[] = tests/page_tokens.test
+
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.install b/sites/all/modules/contrib/dev/ctools/ctools.install
index 1f961f1..d50bc9f 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.install
+++ b/sites/all/modules/contrib/dev/ctools/ctools.install
@@ -12,24 +12,25 @@
function ctools_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
+ $t = get_t();
$requirements['ctools_css_cache'] = array(
- 'title' => t('CTools CSS Cache'),
+ 'title' => $t('CTools CSS Cache'),
'severity' => REQUIREMENT_OK,
- 'value' => t('Exists'),
+ 'value' => $t('Exists'),
);
$path = 'public://ctools/css';
if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
- $requirements['ctools_css_cache']['description'] = t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path)));
+ $requirements['ctools_css_cache']['description'] = $t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path)));
$requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR;
- $requirements['ctools_css_cache']['value'] = t('Unable to create');
+ $requirements['ctools_css_cache']['value'] = $t('Unable to create');
}
if (!function_exists('error_get_last')) {
- $requirements['ctools_php_52']['title'] = t('CTools PHP requirements');
- $requirements['ctools_php_52']['description'] = t('CTools requires certain features only available in PHP 5.2.0 or higher.');
+ $requirements['ctools_php_52']['title'] = $t('CTools PHP requirements');
+ $requirements['ctools_php_52']['description'] = $t('CTools requires certain features only available in PHP 5.2.0 or higher.');
$requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING;
- $requirements['ctools_php_52']['value'] = t('PHP !version', array('!version' => phpversion()));
+ $requirements['ctools_php_52']['value'] = $t('PHP !version', array('!version' => phpversion()));
}
}
@@ -37,10 +38,34 @@ function ctools_requirements($phase) {
}
/**
- * Implements hook_schemea
+ * Implements hook_schema().
*/
function ctools_schema() {
- return ctools_schema_2();
+ return ctools_schema_4();
+}
+
+/**
+ * Version 4 of the CTools schema.
+ */
+function ctools_schema_4() {
+ $schema = ctools_schema_3();
+
+ // Removed due to alternative database configuration issues.
+ // @see https://www.drupal.org/project/ctools/issues/2941920
+
+ return $schema;
+}
+
+/**
+ * Version 3 of the CTools schema.
+ */
+function ctools_schema_3() {
+ $schema = ctools_schema_2();
+
+ // Update the 'obj' field to be 128 bytes long:
+ $schema['ctools_object_cache']['fields']['obj']['length'] = 128;
+
+ return $schema;
}
/**
@@ -49,7 +74,7 @@ function ctools_schema() {
function ctools_schema_2() {
$schema = ctools_schema_1();
- // update the 'name' field to be 128 bytes long:
+ // Update the 'name' field to be 128 bytes long:
$schema['ctools_object_cache']['fields']['name']['length'] = 128;
// Update the 'data' field to be type 'blob'.
@@ -83,10 +108,10 @@ function ctools_schema_2() {
'serialize' => TRUE,
),
'filter' => array(
- 'type' => 'int',
- 'size' => 'tiny',
- 'description' => 'Whether or not this CSS needs to be filtered.',
- ),
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'description' => 'Whether or not this CSS needs to be filtered.',
+ ),
),
'primary key' => array('cid'),
);
@@ -141,6 +166,21 @@ function ctools_schema_1() {
return $schema;
}
+/**
+ * Implements hook_install().
+ */
+function ctools_install() {
+ // Activate our custom cache handler for the CSS cache.
+ variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function ctools_uninstall() {
+ variable_del('cache_class_cache_ctools_css');
+}
+
/**
* Enlarge the ctools_object_cache.name column to prevent truncation and weird
* errors.
@@ -170,7 +210,7 @@ function ctools_update_6003() {
if ($result) {
db_delete('system')->condition('name', 'panels_views')->execute();
module_enable(array('views_content'), TRUE);
- }
+ }
}
/**
@@ -189,7 +229,7 @@ function ctools_update_6005() {
}
/**
- * ctools_custom_content table was originally here, but is now moved to
+ * The ctools_custom_content table was originally here, but is now moved to
* its own module.
*/
function ctools_update_6007() {
@@ -203,17 +243,57 @@ function ctools_update_6007() {
}
/**
- * ctools_object_cache needs to be defined as a blob.
+ * The ctools_object_cache needs to be defined as a blob.
*/
function ctools_update_6008() {
db_delete('ctools_object_cache')
->execute();
db_change_field('ctools_object_cache', 'data', 'data', array(
- 'type' => 'blob',
- 'size' => 'big',
- 'description' => 'Serialized data being stored.',
- 'serialize' => TRUE,
- )
+ 'type' => 'blob',
+ 'size' => 'big',
+ 'description' => 'Serialized data being stored.',
+ 'serialize' => TRUE,
+ )
);
}
+
+/**
+ * Enable the custom CSS cache handler.
+ */
+function ctools_update_7000() {
+ variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
+}
+
+/**
+ * Increase the length of the ctools_object_cache.obj column.
+ */
+function ctools_update_7001() {
+ db_change_field('ctools_object_cache', 'obj', 'obj', array(
+ 'type' => 'varchar',
+ 'length' => '128',
+ 'not null' => TRUE,
+ 'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
+ ));
+}
+
+/**
+ * Increase the length of the ctools_object_cache.name column to 255.
+ */
+function ctools_update_7002() {
+ // Removed due to alternative database configuration issues.
+ // @see https://www.drupal.org/project/ctools/issues/2941920
+}
+
+/**
+ * Revert the length of the ctools_object_cache.name column back to 128.
+ */
+function ctools_update_7003() {
+ db_delete('ctools_object_cache')->execute();
+ db_change_field('ctools_object_cache', 'name', 'name', array(
+ 'type' => 'varchar',
+ 'length' => '128',
+ 'not null' => TRUE,
+ 'description' => 'The name of the object this cache is attached to.',
+ ));
+}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools.module b/sites/all/modules/contrib/dev/ctools/ctools.module
index f014e74..62f2919 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools.module
+++ b/sites/all/modules/contrib/dev/ctools/ctools.module
@@ -9,7 +9,24 @@
* must be implemented in the module file.
*/
-define('CTOOLS_API_VERSION', '2.0.7');
+define('CTOOLS_API_VERSION', '2.0.9');
+
+/**
+ * The current working ctools version.
+ *
+ * In a release, it should be 7.x-1.x, which should match what drush make will
+ * create. In a dev format, it should be 7.x-1.(x+1)-dev, which will allow
+ * modules depending on new features in ctools to depend on ctools > 7.x-1.x.
+ *
+ * To define a specific version of CTools as a dependency for another module,
+ * simply include a dependency line in that module's info file, e.g.:
+ * ; Requires CTools v7.x-1.4 or newer.
+ * dependencies[] = ctools (>=1.4)
+ *
+ * @deprecated in CTools 1.15 and will be removed before CTools 2.0.0.
+ * Use the version provided by the drupal.org packaging system.
+ */
+define('CTOOLS_MODULE_VERSION', '7.x-1.13');
/**
* Test the CTools API version.
@@ -61,6 +78,9 @@ define('CTOOLS_API_VERSION', '2.0.7');
* The minimum version of CTools necessary for your software to run with it.
* @param $maximum
* The maximum version of CTools allowed for your software to run with it.
+ *
+ * @return bool
+ * TRUE if the running ctools is usable, FALSE otherwise.
*/
function ctools_api_version($minimum, $maximum = NULL) {
if (version_compare(CTOOLS_API_VERSION, $minimum, '<')) {
@@ -75,8 +95,7 @@ function ctools_api_version($minimum, $maximum = NULL) {
}
// -----------------------------------------------------------------------
-// General utility functions
-
+// General utility functions.
/**
* Include .inc files as necessary.
*
@@ -104,6 +123,7 @@ function ctools_api_version($minimum, $maximum = NULL) {
* @param $dir
* Optional subdirectory containing the include file.
*/
+
function ctools_include($file, $module = 'ctools', $dir = 'includes') {
static $used = array();
@@ -133,8 +153,8 @@ function ctools_form_include(&$form_state, $file, $module = 'ctools', $dir = 'in
/**
* Add an arbitrary path to the $form_state so it can work with form cache.
*
- * module_load_include uses an unfortunately annoying syntax to work, making it
- * difficult to translate the more simple $path + $file syntax.
+ * The module_load_include() function uses an unfortunately annoying syntax to
+ * work, making it difficult to translate the more simple $path + $file syntax.
*/
function ctools_form_include_file(&$form_state, $filename) {
if (!isset($form_state['build_info']['args'])) {
@@ -158,6 +178,9 @@ function ctools_form_include_file(&$form_state, $filename) {
* Optional module containing the include.
* @param $dir
* Optional subdirectory containing the include file.
+ *
+ * @return string
+ * A string containing the appropriate path from drupal root.
*/
function ctools_image_path($image, $module = 'ctools', $dir = 'images') {
return drupal_get_path('module', $module) . "/$dir/" . $image;
@@ -197,6 +220,9 @@ function ctools_add_css($file, $module = 'ctools', $dir = 'css') {
* Optional module containing the include.
* @param $dir
* Optional subdirectory containing the include file.
+ *
+ * @return string
+ * A string containing the appropriate path from drupal root.
*/
function ctools_attach_css($file, $module = 'ctools', $dir = 'css') {
return drupal_get_path('module', $module) . "/$dir/$file.css";
@@ -235,6 +261,9 @@ function ctools_add_js($file, $module = 'ctools', $dir = 'js') {
* Optional module containing the include.
* @param $dir
* Optional subdirectory containing the include file.
+ *
+ * @return string
+ * A string containing the appropriate path from drupal root.
*/
function ctools_attach_js($file, $module = 'ctools', $dir = 'js') {
return drupal_get_path('module', $module) . "/$dir/$file.js";
@@ -253,16 +282,29 @@ function ctools_get_roles() {
return user_roles();
}
-/*
- * Break x,y,z and x+y+z into an array. Numeric only.
+/**
+ * Parse integer sequences of the form "x,y,z" or "x+y+z" into separate values.
+ *
+ * A string with integers separated by comma (,) is reported as an 'and' set;
+ * separation by a plus sign (+) or a space ( ) is an 'or' set. The meaning
+ * of this is up to the caller. Negative or fractional numbers are not
+ * recognised.
+ *
+ * Additional space characters within or around the sequence are not allowed.
*
* @param $str
* The string to parse.
*
- * @return $object
- * An object containing
- * - operator: Either 'and' or 'or'
- * - value: An array of numeric values.
+ * @return object
+ * An object containing the properties:
+ *
+ * - operator: Either 'and' or 'or' when there are multiple matched values.
+ * Absent when invalid_input is TRUE or there is only one value.
+ * - value: An array of integers (never strings) from $str. An empty array is
+ * returned if the input is empty. A single integer input is returned
+ * as a single value, but no 'operator' is defined.
+ * - invalid_input: TRUE if input could not be parsed and the values array
+ * will contain just -1. This property is otherwise absent.
*/
function ctools_break_phrase($str) {
$object = new stdClass();
@@ -272,7 +314,7 @@ function ctools_break_phrase($str) {
$object->operator = 'or';
$object->value = preg_split('/[+ ]/', $str);
}
- else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) {
+ elseif (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) {
$object->operator = 'and';
$object->value = explode(',', $str);
}
@@ -290,7 +332,7 @@ function ctools_break_phrase($str) {
// Doubly ensure that all values are numeric only.
foreach ($object->value as $id => $value) {
- $object->value[$id] = intval($value);
+ $object->value[$id] = (int) $value;
}
return $object;
@@ -298,25 +340,31 @@ function ctools_break_phrase($str) {
/**
* Set a token/value pair to be replaced later in the request, specifically in
- * ctools_preprocess_page().
+ * ctools_page_token_processing().
*
- * @param $token
+ * @param string $token
* The token to be replaced later, during page rendering. This should
- * ideally be a string inside of an HTML comment, so that if there is
- * no replacement, the token will not render on the page.
- * @param $type
+ * ideally be a string inside of an HTML comment, so that if there is
+ * no replacement, the token will not render on the page.
+ * If $token is NULL, the token set is not changed, but is still
+ * returned.
+ * @param string $type
* The type of the token. Can be either 'variable', which will pull data
- * directly from the page variables
- * @param $argument
- * If $type == 'variable' then argument should be the key to fetch from
- * the $variables. If $type == 'callback' then it should either be the
- * callback, or an array that will be sent to call_user_func_array().
+ * directly from the page variables, or 'callback', which causes a function
+ * to be called to calculate the value. No other values are supported.
+ * @param string|array $argument
+ * For $type of:
+ * - 'variable': argument should be the key to fetch from the $variables.
+ * - 'callback': then it should either be the callback function name as a
+ * string, or an array that will be sent to call_user_func_array(). Argument
+ * arrays must not use array keys (i.e. $a[0] is the first and $a[1] the
+ * second element, etc.)
*
- * @return
+ * @return array
* A array of token/variable names to be replaced.
*/
function ctools_set_page_token($token = NULL, $type = NULL, $argument = NULL) {
- static $tokens = array();
+ $tokens = &drupal_static('ctools_set_page_token', array());
if (isset($token)) {
$tokens[$token] = array($type, $argument);
@@ -325,13 +373,32 @@ function ctools_set_page_token($token = NULL, $type = NULL, $argument = NULL) {
}
/**
- * Easily set a token from the page variables.
+ * Reset the defined page tokens within this request.
+ *
+ * Introduced for simpletest purposes. Normally not needed.
+ */
+function ctools_reset_page_tokens() {
+ drupal_static_reset('ctools_set_page_token');
+}
+
+/**
+ * Set a replacement token from the containing element's children during #post_render.
*
* This function can be used like this:
- * $token = ctools_set_variable_token('tabs');
+ * $token = ctools_set_variable_token('tabs');
*
- * $token will then be a simple replacement for the 'tabs' about of the
- * variables available in the page template.
+ * The token "" would then be replaced by the value of
+ * this element's (sibling) render array key 'tabs' during post-render (or be
+ * deleted if there was no such key by that point).
+ *
+ * @param string $token
+ * The token string for the page callback, e.g. 'title'.
+ *
+ * @return string
+ * The constructed token.
+ *
+ * @see ctools_set_callback_token()
+ * @see ctools_page_token_processing()
*/
function ctools_set_variable_token($token) {
$string = '';
@@ -340,10 +407,45 @@ function ctools_set_variable_token($token) {
}
/**
- * Easily set a token from the page variables.
+ * Set a replacement token from the value of a function during #post_render.
*
* This function can be used like this:
- * $token = ctools_set_variable_token('id', 'mymodule_myfunction');
+ * $token = ctools_set_callback_token('id', 'mymodule_myfunction');
+ *
+ * Or this (from its use in ctools_page_title_content_type_render):
+ * $token = ctools_set_callback_token('title', array(
+ * 'ctools_page_title_content_type_token', $conf['markup'], $conf['id'], $conf['class']
+ * )
+ * );
+ *
+ * The token (e.g: "")
+ * would then be replaced during post-render by the return value of:
+ *
+ * ctools_page_title_content_type_token($value_markup, $value_id, $value_class);
+ *
+ * @param string $token
+ * The token string for the page callback, e.g. 'title'.
+ *
+ * @param string|array $callback
+ * For callback functions that require no args, the name of the function as a
+ * string; otherwise an array of two or more elements: the function name
+ * followed by one or more function arguments.
+ *
+ * NB: the value of $callback must be a procedural (non-class) function that
+ * passes the php function_exists() check.
+ *
+ * The callback function itself will be called with args dependent
+ * on $callback. If:
+ * - $callback is a string, the function is called with a reference to the
+ * render array;
+ * - $callback is an array, the function is called with $callback merged
+ * with an array containing a reference to the render array.
+ *
+ * @return string
+ * The constructed token.
+ *
+ * @see ctools_set_variable_token()
+ * @see ctools_page_token_processing()
*/
function ctools_set_callback_token($token, $callback) {
// If the callback uses arguments they are considered in the token.
@@ -367,6 +469,60 @@ function ctools_set_no_blocks($blocks = FALSE) {
$status = $blocks;
}
+/**
+ * Wrapper function to create UUIDs via ctools, falls back on UUID module
+ * if it is enabled. This code is a copy of uuid.inc from the uuid module.
+ *
+ * @see http://php.net/uniqid#65879
+ */
+function ctools_uuid_generate() {
+ if (!module_exists('uuid')) {
+ ctools_include('uuid');
+
+ $callback = drupal_static(__FUNCTION__);
+
+ if (empty($callback)) {
+ if (function_exists('uuid_create') && !function_exists('uuid_make')) {
+ $callback = '_ctools_uuid_generate_pecl';
+ }
+ elseif (function_exists('com_create_guid')) {
+ $callback = '_ctools_uuid_generate_com';
+ }
+ else {
+ $callback = '_ctools_uuid_generate_php';
+ }
+ }
+ return $callback();
+ }
+ else {
+ return uuid_generate();
+ }
+}
+
+/**
+ * Check that a string appears to be in the format of a UUID.
+ *
+ * @see http://drupal.org/project/uuid
+ *
+ * @param $uuid
+ * The string to test.
+ *
+ * @return
+ * TRUE if the string is well formed.
+ */
+function ctools_uuid_is_valid($uuid = '') {
+ if (empty($uuid)) {
+ return FALSE;
+ }
+ if (function_exists('uuid_is_valid') || module_exists('uuid')) {
+ return uuid_is_valid($uuid);
+ }
+ else {
+ ctools_include('uuid');
+ return uuid_is_valid($uuid);
+ }
+}
+
/**
* Add an array of classes to the body.
*
@@ -401,6 +557,8 @@ function ctools_class_add($classes, $hook = 'html') {
*/
function ctools_class_remove($classes, $hook = 'html') {
if (!is_array($classes)) {
+ // @todo Consider using explode(' ', $classes);
+ // @todo Consider checking that $classes is a string before adding.
$classes = array($classes);
}
@@ -413,12 +571,35 @@ function ctools_class_remove($classes, $hook = 'html') {
}
}
-// -----------------------------------------------------------------------
-// Drupal core hooks
+/**
+ * Reset the storage used for ctools_class_add and ctools_class_remove.
+ *
+ * @see ctools_class_add()
+ * @see ctools_class_remove()
+ */
+function ctools_class_reset() {
+ drupal_static_reset('ctools_process_classes');
+}
+/**
+ * Return the classes for the body (added by ctools_class_add).
+ *
+ * @return array
+ * A copy of the array of classes to add to the body tag. If none have been
+ * added, this will be an empty array.
+ *
+ * @see ctools_class_add()
+ */
+function ctools_get_classes() {
+ return drupal_static('ctools_process_classes', array());
+}
+
+// -----------------------------------------------------------------------
+// Drupal core hooks.
/**
* Implement hook_init to keep our global CSS at the ready.
*/
+
function ctools_init() {
ctools_add_css('ctools');
// If we are sure that CTools' AJAX is in use, change the error handling.
@@ -437,7 +618,7 @@ function ctools_init() {
* Shutdown handler used during ajax operations to help catch fatal errors.
*/
function ctools_shutdown_handler() {
- if (function_exists('error_get_last') AND ($error = error_get_last())) {
+ if (function_exists('error_get_last') && ($error = error_get_last())) {
switch ($error['type']) {
case E_ERROR:
case E_CORE_ERROR:
@@ -483,6 +664,19 @@ function ctools_menu() {
return $items;
}
+/**
+ * Implements hook_permission().
+ */
+function ctools_permission() {
+ return array(
+ 'use ctools import' => array(
+ 'title' => t('Use CTools importer'),
+ 'description' => t('The import functionality allows users to execute arbitrary PHP code, so extreme caution must be taken.'),
+ 'restrict access' => TRUE,
+ ),
+ );
+}
+
/**
* Implementation of hook_cron. Clean up old caches.
*/
@@ -493,24 +687,16 @@ function ctools_cron() {
}
/**
- * Ensure the CTools CSS cache is flushed whenever hook_flush_caches is invoked.
+ * Implements hook_flush_caches().
*/
function ctools_flush_caches() {
- // Do not actually flush caches if running on cron. Drupal uses this hook
- // in an inconsistent fashion and it does not necessarily mean to *flush*
- // caches when running from cron. Instead it's just getting a list of cache
- // tables and may not do any flushing.
- if (!empty($GLOBALS['locks']['cron'])) {
- return;
- }
-
- ctools_include('css');
- ctools_css_flush_caches();
+ // Only return the CSS cache bin if it has been activated, to avoid
+ // drupal_flush_all_caches() from trying to truncate a non-existing table.
+ return variable_get('cache_class_cache_ctools_css', FALSE) ? array('cache_ctools_css') : array();
}
/**
* Implements hook_element_info_alter().
- *
*/
function ctools_element_info_alter(&$type) {
ctools_include('dependent');
@@ -545,12 +731,33 @@ function ctools_registry_files_alter(&$files, $indexed_modules) {
}
// -----------------------------------------------------------------------
-// CTools hook implementations.
+// FAPI hooks that must be in the .module file.
+/**
+ * Alter the comment form to get a little more control over it.
+ */
+function ctools_form_comment_form_alter(&$form, &$form_state) {
+ if (!empty($form_state['ctools comment alter'])) {
+ // Force the form to post back to wherever we are.
+ $form['#action'] = url($_GET['q'], array('fragment' => 'comment-form'));
+ if (empty($form['#submit'])) {
+ $form['#submit'] = array('comment_form_submit');
+ }
+ $form['#submit'][] = 'ctools_node_comment_form_submit';
+ }
+}
+
+function ctools_node_comment_form_submit(&$form, &$form_state) {
+ $form_state['redirect'][0] = $_GET['q'];
+}
+
+// -----------------------------------------------------------------------
+// CTools hook implementations.
/**
* Implementation of hook_ctools_plugin_directory() to let the system know
* where all our own plugins are.
*/
+
function ctools_ctools_plugin_directory($owner, $plugin_type) {
if ($owner == 'ctools') {
return 'plugins/' . $plugin_type;
@@ -571,11 +778,11 @@ function ctools_ctools_plugin_type() {
// -----------------------------------------------------------------------
// Drupal theme preprocess hooks that must be in the .module file.
-
/**
* A theme preprocess function to automatically allow panels-based node
* templates based upon input when the panel was configured.
*/
+
function ctools_preprocess_node(&$vars) {
// The 'ctools_template_identifier' attribute of the node is added when the pane is
// rendered.
@@ -585,7 +792,25 @@ function ctools_preprocess_node(&$vars) {
}
}
+/**
+ * Implements hook_page_alter().
+ *
+ * Last ditch attempt to remove sidebar regions if the "no blocks"
+ * functionality has been activated.
+ *
+ * @see ctools_block_list_alter()
+ */
function ctools_page_alter(&$page) {
+ $check = drupal_static('ctools_set_no_blocks', TRUE);
+ if (!$check) {
+ foreach ($page as $region_id => $region) {
+ // @todo -- possibly we can set configuration for this so that users can
+ // specify which blocks will not get rendered.
+ if (strpos($region_id, 'sidebar') !== FALSE) {
+ unset($page[$region_id]);
+ }
+ }
+ }
$page['#post_render'][] = 'ctools_page_token_processing';
}
@@ -601,15 +826,16 @@ function ctools_page_token_processing($children, $elements) {
list($type, $argument) = $key;
switch ($type) {
case 'variable':
- $tokens[$token] = isset($variables[$argument]) ? $variables[$argument] : '';
+ $tokens[$token] = isset($elements[$argument]) ? $elements[$argument] : '';
break;
+
case 'callback':
if (is_string($argument) && function_exists($argument)) {
- $tokens[$token] = $argument($variables);
+ $tokens[$token] = $argument($elements);
}
if (is_array($argument) && function_exists($argument[0])) {
$function = array_shift($argument);
- $argument = array_merge(array(&$variables), $argument);
+ $argument = array_merge(array(&$elements), $argument);
$tokens[$token] = call_user_func_array($function, $argument);
}
break;
@@ -631,7 +857,7 @@ function ctools_process(&$variables, $hook) {
return;
}
- $classes = drupal_static('ctools_process_classes', array());
+ $classes = ctools_get_classes();
// Process the classses to add.
if (!empty($classes[$hook]['add'])) {
@@ -652,7 +878,6 @@ function ctools_process(&$variables, $hook) {
// -----------------------------------------------------------------------
// Menu callbacks that must be in the .module file.
-
/**
* Determine if the current user has access via a plugin.
*
@@ -676,6 +901,7 @@ function ctools_process(&$variables, $hook) {
* @return
* TRUE if access is granted, false if otherwise.
*/
+
function ctools_access_menu($access) {
// Short circuit everything if there are no access tests.
if (empty($access['plugins'])) {
@@ -704,7 +930,7 @@ function ctools_access_menu($access) {
* An indexed array of zero or more permission strings to be checked by
* user_access().
*
- * @return
+ * @return bool
* Iff all checks pass will this function return TRUE. If an invalid argument
* is passed (e.g., not a string), this function errs on the safe said and
* returns FALSE.
@@ -733,6 +959,15 @@ function ctools_js_load($js) {
return 0;
}
+/**
+ * Provides the default value for %ctools_js.
+ *
+ * This allows drupal_valid_path() to work with %ctools_js.
+ */
+function ctools_js_to_arg($arg) {
+ return empty($arg) || $arg == '%' ? 'nojs' : $arg;
+}
+
/**
* Menu _load hook.
*
@@ -757,7 +992,6 @@ function ctools_export_ui_load($item_name, $plugin_name) {
// -----------------------------------------------------------------------
// Caching callbacks on behalf of export-ui.
-
/**
* Menu access callback for various tasks of export-ui.
*/
@@ -801,7 +1035,7 @@ function ctools_export_ui_ctools_access_get($argument) {
}
/**
- * Callback for access control ajax form on behalf of export ui
+ * Callback for access control ajax form on behalf of export ui.
*
* Returns the cached access config and contexts used.
* Note that this is assuming that access will be in $item->access -- if it
@@ -834,8 +1068,9 @@ function ctools_menu_local_tasks_alter(&$data, $router_item, $root_path) {
}
/**
- * Implement hook_block_list_alter() to potentially remove blocks.
+ * Implements hook_block_list_alter().
*
+ * Used to potentially remove blocks.
* This exists in order to replicate Drupal 6's "no blocks" functionality.
*/
function ctools_block_list_alter(&$blocks) {
@@ -852,11 +1087,25 @@ function ctools_block_list_alter(&$blocks) {
}
/**
- * Implement hook_modules_enabled to clear static caches for detecting new plugins
+ * Implements hook_modules_enabled().
+ *
+ * Clear caches for detecting new plugins.
*/
function ctools_modules_enabled($modules) {
ctools_include('plugins');
ctools_get_plugins_reset();
+ cache_clear_all('ctools_plugin_files:', 'cache', TRUE);
+}
+
+/**
+ * Implements hook_modules_disabled().
+ *
+ * Clear caches for removing disabled plugins.
+ */
+function ctools_modules_disabled($modules) {
+ ctools_include('plugins');
+ ctools_get_plugins_reset();
+ cache_clear_all('ctools_plugin_files:', 'cache', TRUE);
}
/**
@@ -884,6 +1133,7 @@ function ctools_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) {
case 'entity_id:taxonomy_term':
$plugin['no ui'] = TRUE;
break;
+
case 'entity:user':
$plugin = ctools_get_context('user');
unset($plugin['no ui']);
@@ -903,3 +1153,53 @@ function ctools_ctools_entity_context_alter(&$plugin, &$entity, $plugin_id) {
}
}
}
+
+/**
+ * Implements hook_field_create_field().
+ */
+function ctools_field_create_field($field) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_create_instance().
+ */
+function ctools_field_create_instance($instance) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_delete_field().
+ */
+function ctools_field_delete_field($field) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_delete_instance().
+ */
+function ctools_field_delete_instance($instance) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_update_field().
+ */
+function ctools_field_update_field($field, $prior_field, $has_data) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Implements hook_field_update_instance().
+ */
+function ctools_field_update_instance($instance, $prior_instance) {
+ ctools_flush_field_caches();
+}
+
+/**
+ * Clear field related caches.
+ */
+function ctools_flush_field_caches() {
+ // Clear caches of 'Entity field' content type plugin.
+ cache_clear_all('ctools_entity_field_content_type_content_types', 'cache');
+}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info
index 1019253..3fc3556 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.info
@@ -4,9 +4,8 @@ core = 7.x
package = Chaos tool suite
dependencies[] = ctools
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.install b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.install
index 3f00877..70afb3c 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.install
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/ctools_access_ruleset.install
@@ -1,5 +1,9 @@
t('Custom rulesets are combinations of access plugins you can use for access control, selection criteria and pane visibility.'),
);
- // Load all mini panels and their displays.
+ // Load all mini panels and their displays.
ctools_include('export');
$items = ctools_export_crud_load_all('ctools_access_ruleset');
$count = 0;
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/access/ruleset.inc b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/access/ruleset.inc
index f8abea6..95f32c3 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/access/ruleset.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/access/ruleset.inc
@@ -35,7 +35,7 @@ function ctools_ruleset_ctools_access_merge_plugin($plugin, $parent, $item) {
$plugin['required context'] = array();
foreach ($item->requiredcontexts as $context) {
$info = ctools_get_context($context['name']);
- // TODO: allow an optional setting
+ // TODO: allow an optional setting.
$plugin['required context'][] = new ctools_context_required($context['identifier'], $info['context name']);
}
}
@@ -72,7 +72,7 @@ function ctools_ruleset_ctools_access_get_children($plugin, $parent) {
}
/**
- * Settings form for the 'by ruleset' access plugin
+ * Settings form for the 'by ruleset' access plugin.
*/
function ctools_ruleset_ctools_access_settings(&$form, &$form_state, $conf) {
if (!empty($form_state['plugin']['ruleset']->admin_description)) {
@@ -106,4 +106,3 @@ function ctools_ruleset_ctools_access_summary($conf, $context, $plugin) {
return check_plain($plugin['ruleset']->admin_title);
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc
index d2a1c60..2589ac3 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset.inc
@@ -1,5 +1,9 @@
'ctools_access_ruleset',
'access' => 'administer ctools access ruleset',
@@ -26,4 +30,3 @@ $plugin = array(
),
),
);
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php
index b181464..c9f8c20 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php
+++ b/sites/all/modules/contrib/dev/ctools/ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php
@@ -2,7 +2,7 @@
class ctools_access_ruleset_ui extends ctools_export_ui {
- function edit_form_context(&$form, &$form_state) {
+ public function edit_form_context(&$form, &$form_state) {
ctools_include('context-admin');
ctools_context_admin_includes();
ctools_add_css('ruleset');
@@ -27,7 +27,7 @@ class ctools_access_ruleset_ui extends ctools_export_ui {
ctools_context_add_relationship_form($module, $form, $form_state, $form['right']['relationships_table'], $form_state['item'], $name);
}
- function edit_form_rules(&$form, &$form_state) {
+ public function edit_form_rules(&$form, &$form_state) {
// The 'access' UI passes everything via $form_state, unlike the 'context' UI.
// The main difference is that one is about 3 years newer than the other.
ctools_include('context');
@@ -43,11 +43,12 @@ class ctools_access_ruleset_ui extends ctools_export_ui {
$form = ctools_access_admin_form($form, $form_state);
}
- function edit_form_rules_submit(&$form, &$form_state) {
+ public function edit_form_rules_submit(&$form, &$form_state) {
$form_state['item']->access['logic'] = $form_state['values']['logic'];
}
- function edit_form_submit(&$form, &$form_state) {
+ public function edit_form_submit(&$form, &$form_state) {
parent::edit_form_submit($form, $form_state);
}
+
}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css
index 8df17de..c312e99 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css
+++ b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/css/ctools-ajax-sample.css
@@ -1,52 +1,52 @@
div.ctools-sample-modal-content {
- background:none;
- border:0;
- color:#000000;
- margin:0;
- padding:0;
- text-align:left;
+ background: none;
+ border: 0;
+ color: #000;
+ margin: 0;
+ padding: 0;
+ text-align: left;
}
-div.ctools-sample-modal-content .modal-scroll{
- overflow:hidden;
- overflow-y:auto;
+div.ctools-sample-modal-content .modal-scroll {
+ overflow: hidden;
+ overflow-y: auto;
}
div.ctools-sample-modal-content #popups-overlay {
- background-color:transparent;
+ background-color: transparent;
}
div.ctools-sample-modal-content #popups-loading {
- width:248px;
- position:absolute;
- display:none;
- opacity:1;
+ width: 248px;
+ position: absolute;
+ display: none;
+ opacity: 1;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
- z-index:99;
+ z-index: 99;
}
div.ctools-sample-modal-content #popups-loading span.popups-loading-message {
- background:#FFF url(../images/loading-large.gif) no-repeat 8px center;
- display:block;
- color:#444444;
- font-family:Arial;
- font-size:22px;
- font-weight:bold;
- height:36px;
- line-height:36px;
- padding:0 40px;
+ background: #fff url(../images/loading-large.gif) no-repeat 8px center;
+ display: block;
+ color: #444;
+ font-family: Arial, serif;
+ font-size: 22px;
+ font-weight: bold;
+ height: 36px;
+ line-height: 36px;
+ padding: 0 40px;
}
div.ctools-sample-modal-content #popups-loading table,
div.ctools-sample-modal-content .popups-box table {
- margin:0px;
+ margin: 0;
}
div.ctools-sample-modal-content #popups-loading tbody,
div.ctools-sample-modal-content .popups-box tbody {
- border:none;
+ border: none;
}
div.ctools-sample-modal-content .popups-box tr {
- background-color:transparent;
+ background-color: transparent;
}
div.ctools-sample-modal-content td.popups-border {
background: url(../images/popups-border.png);
- background-color:transparent;
+ background-color: transparent;
border: none;
}
div.ctools-sample-modal-content td.popups-tl,
@@ -54,79 +54,94 @@ div.ctools-sample-modal-content td.popups-tr,
div.ctools-sample-modal-content td.popups-bl,
div.ctools-sample-modal-content td.popups-br {
background-repeat: no-repeat;
- height:10px;
- padding:0px;
+ height: 10px;
+ padding: 0;
+}
+div.ctools-sample-modal-content td.popups-tl {
+ background-position: 0 0;
}
-div.ctools-sample-modal-content td.popups-tl { background-position: 0px 0px; }
div.ctools-sample-modal-content td.popups-t,
div.ctools-sample-modal-content td.popups-b {
- background-position: 0px -40px;
+ background-position: 0 -40px;
background-repeat: repeat-x;
}
-div.ctools-sample-modal-content td.popups-tr { background-position: 0px -10px; width: 10px; }
+div.ctools-sample-modal-content td.popups-tr {
+ background-position: 0 -10px;
+ width: 10px;
+}
div.ctools-sample-modal-content td.popups-cl,
div.ctools-sample-modal-content td.popups-cr {
background-position: -10px 0;
background-repeat: repeat-y;
- width:10px;
+ width: 10px;
}
div.ctools-sample-modal-content td.popups-cl,
div.ctools-sample-modal-content td.popups-cr,
-div.ctools-sample-modal-content td.popups-c { padding:0; border: none; }
-div.ctools-sample-modal-content td.popups-c { background:#fff; }
-div.ctools-sample-modal-content td.popups-bl { background-position: 0px -20px; }
-div.ctools-sample-modal-content td.popups-br { background-position: 0px -30px; width: 10px; }
+div.ctools-sample-modal-content td.popups-c {
+ padding: 0;
+ border: none;
+}
+div.ctools-sample-modal-content td.popups-c {
+ background: #fff;
+}
+div.ctools-sample-modal-content td.popups-bl {
+ background-position: 0 -20px;
+}
+div.ctools-sample-modal-content td.popups-br {
+ background-position: 0 -30px;
+ width: 10px;
+}
div.ctools-sample-modal-content .popups-box,
div.ctools-sample-modal-content #popups-loading {
- border: 0px solid #454545;
- opacity:1;
- overflow:hidden;
- padding:0;
- background-color:transparent;
+ border: 0 solid #454545;
+ opacity: 1;
+ overflow: hidden;
+ padding: 0;
+ background-color: transparent;
}
div.ctools-sample-modal-content .popups-container {
- overflow:hidden;
- height:100%;
- background-color:#fff;
+ overflow: hidden;
+ height: 100%;
+ background-color: #fff;
}
div.ctools-sample-modal-content div.popups-title {
- -moz-border-radius-topleft: 0px;
- -webkit-border-radius-topleft: 0px;
- margin-bottom:0px;
- background-color:#ff7200;
- border:1px solid #ce5c00;
- padding:4px 10px 5px;
- color:white;
- font-size:1em;
- font-weight:bold;
+ -moz-border-radius-topleft: 0;
+ -webkit-border-radius-topleft: 0;
+ margin-bottom: 0;
+ background-color: #ff7200;
+ border: 1px solid #ce5c00;
+ padding: 4px 10px 5px;
+ color: white;
+ font-size: 1em;
+ font-weight: bold;
}
div.ctools-sample-modal-content .popups-body {
- background-color:#fff;
- padding:8px;
+ background-color: #fff;
+ padding: 8px;
}
div.ctools-sample-modal-content .popups-box .popups-buttons,
div.ctools-sample-modal-content .popups-box .popups-footer {
- background-color:#fff;
+ background-color: #fff;
}
div.ctools-sample-modal-content .popups-title a.close {
color: #fff;
- text-decoration:none;
+ text-decoration: none;
}
div.ctools-sample-modal-content .popups-close {
- font-size:120%;
- float:right;
- text-align:right;
+ font-size: 120%;
+ float: right;
+ text-align: right;
}
div.ctools-sample-modal-content .modal-loading-wrapper {
- width:220px;
- height:19px;
- margin:0 auto;
- margin-top:2%;
+ width: 220px;
+ height: 19px;
+ margin: 0 auto;
+ margin-top: 2%;
}
-div.ctools-sample-modal-content tbody{
- border:none;
+div.ctools-sample-modal-content tbody {
+ border: none;
}
div.ctools-sample-modal-content .modal-content .modal-throbber-wrapper img {
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info
index 03ccb34..c2a52df 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.info
@@ -4,9 +4,8 @@ package = Chaos tool suite
dependencies[] = ctools
core = 7.x
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.install b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.install
index 04325db..e0fdfc6 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.install
+++ b/sites/all/modules/contrib/dev/ctools/ctools_ajax_sample/ctools_ajax_sample.install
@@ -1,18 +1,18 @@
'Chaos Tools AJAX Demo',
- 'page callback' => 'ctools_ajax_sample_page',
- 'access callback' => TRUE,
- 'type' => MENU_NORMAL_ITEM,
+ 'title' => 'Chaos Tools AJAX Demo',
+ 'page callback' => 'ctools_ajax_sample_page',
+ 'access callback' => TRUE,
+ 'type' => MENU_NORMAL_ITEM,
);
$items['ctools_ajax_sample/simple_form'] = array(
'title' => 'Simple Form',
@@ -26,39 +26,39 @@ function ctools_ajax_sample_menu() {
'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/hello'] = array(
- 'title' => 'Hello World',
- 'page callback' => 'ctools_ajax_sample_hello',
- 'page arguments' => array(1),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Hello World',
+ 'page callback' => 'ctools_ajax_sample_hello',
+ 'page arguments' => array(1),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/tablenix/%'] = array(
- 'title' => 'Hello World',
- 'page callback' => 'ctools_ajax_sample_tablenix',
- 'page arguments' => array(1, 3),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Hello World',
+ 'page callback' => 'ctools_ajax_sample_tablenix',
+ 'page arguments' => array(1, 3),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/login'] = array(
- 'title' => 'Login',
- 'page callback' => 'ctools_ajax_sample_login',
- 'page arguments' => array(1),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Login',
+ 'page callback' => 'ctools_ajax_sample_login',
+ 'page arguments' => array(1),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/animal'] = array(
- 'title' => 'Animal',
- 'page callback' => 'ctools_ajax_sample_animal',
- 'page arguments' => array(1),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Animal',
+ 'page callback' => 'ctools_ajax_sample_animal',
+ 'page arguments' => array(1),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/%ctools_js/login/%'] = array(
- 'title' => 'Post-Login Action',
- 'page callback' => 'ctools_ajax_sample_login_success',
- 'page arguments' => array(1, 3),
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
+ 'title' => 'Post-Login Action',
+ 'page callback' => 'ctools_ajax_sample_login_success',
+ 'page arguments' => array(1, 3),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
);
$items['ctools_ajax_sample/jumped'] = array(
'title' => 'Successful Jumping',
@@ -104,11 +104,11 @@ function ctools_ajax_sample_theme() {
}
// ---------------------------------------------------------------------------
-// Page callbacks
-
+// Page callbacks.
/**
* Page callback to display links and render a container for AJAX stuff.
*/
+
function ctools_ajax_sample_page() {
global $user;
@@ -156,14 +156,14 @@ function ctools_ajax_sample_page() {
// The extra class points to the info in ctools-sample-style which we added
// to the settings, prefixed with 'ctools-modal'.
- $links[] = ctools_modal_text_button(t('Modal Login (custom style)'), 'ctools_ajax_sample/nojs/login', t('Login via modal'), 'ctools-modal-ctools-sample-style');
+ $links[] = ctools_modal_text_button(t('Modal Login (custom style)'), 'ctools_ajax_sample/nojs/login', t('Login via modal'), 'ctools-modal-ctools-sample-style');
}
// Four ways to do our animal picking wizard.
$button_form = ctools_ajax_sample_ajax_button_form();
$links[] = l(t('Wizard (no modal)'), 'ctools_ajax_sample/nojs/animal');
$links[] = ctools_modal_text_button(t('Wizard (default modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal'));
- $links[] = ctools_modal_text_button(t('Wizard (custom modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal'), 'ctools-modal-ctools-sample-style');
+ $links[] = ctools_modal_text_button(t('Wizard (custom modal)'), 'ctools_ajax_sample/nojs/animal', t('Pick an animal'), 'ctools-modal-ctools-sample-style');
$links[] = drupal_render($button_form);
$links[] = ctools_ajax_text_button(t('Hello world!'), "ctools_ajax_sample/nojs/hello", t('Replace text with "hello world"'));
@@ -176,9 +176,9 @@ function ctools_ajax_sample_page() {
// Create a table that we can have data removed from via AJAX.
$header = array(t('Row'), t('Content'), t('Actions'));
$rows = array();
- for($i = 1; $i < 11; $i++) {
+ for ($i = 1; $i < 11; $i++) {
$rows[] = array(
- 'class' => array('ajax-sample-row-'. $i),
+ 'class' => array('ajax-sample-row-' . $i),
'data' => array(
$i,
md5($i),
@@ -189,10 +189,10 @@ function ctools_ajax_sample_page() {
$output .= theme('table', array('header' => $header, 'rows' => $rows, array('class' => array('ajax-sample-table'))));
- // Show examples of ctools javascript widgets
- $output .= '
'. t('CTools Javascript Widgets') .'
';
+ // Show examples of ctools javascript widgets.
+ $output .= '
' . t('CTools Javascript Widgets') . '
';
- // Create a drop down menu
+ // Create a drop down menu.
$links = array();
$links[] = array('title' => t('Link 1'), 'href' => $_GET['q']);
$links[] = array('title' => t('Link 2'), 'href' => $_GET['q']);
@@ -201,16 +201,16 @@ function ctools_ajax_sample_page() {
$output .= '
' . t('Drop Down Menu') . '
';
$output .= theme('ctools_dropdown', array('title' => t('Click to Drop Down'), 'links' => $links));
- // Create a collapsible div
+ // Create a collapsible div.
$handle = t('Click to Collapse');
$content = 'Nulla ligula ante, aliquam at adipiscing egestas, varius vel arcu. Etiam laoreet elementum mi vel consequat. Etiam scelerisque lorem vel neque consequat quis bibendum libero congue. Nulla facilisi. Mauris a elit a leo feugiat porta. Phasellus placerat cursus est vitae elementum.';
- $output .= '
Login successful. You can now choose whether to ' . $inplace . ', or go to ' . $account . '.
');
}
print ajax_render($output);
exit;
@@ -283,7 +284,7 @@ function ctools_ajax_sample_login($js = NULL) {
*/
function ctools_ajax_sample_login_success($js, $action) {
if (!$js) {
- // we should never be here out of ajax context
+ // We should never be here out of ajax context.
return MENU_NOT_FOUND;
}
@@ -291,11 +292,11 @@ function ctools_ajax_sample_login_success($js, $action) {
ctools_add_js('ajax-responder');
$commands = array();
if ($action == 'inplace') {
- // stay here
+ // Stay here.
$commands[] = ctools_ajax_command_reload();
}
else {
- // bounce bounce
+ // Bounce bounce.
$commands[] = ctools_ajax_command_redirect('user');
}
print ajax_render($commands);
@@ -318,18 +319,18 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
'show back' => TRUE,
'show cancel' => TRUE,
'show return' => FALSE,
- 'next callback' => 'ctools_ajax_sample_wizard_next',
+ 'next callback' => 'ctools_ajax_sample_wizard_next',
'finish callback' => 'ctools_ajax_sample_wizard_finish',
'cancel callback' => 'ctools_ajax_sample_wizard_cancel',
- // this controls order, as well as form labels
+ // This controls order, as well as form labels.
'order' => array(
'start' => t('Choose animal'),
),
- // here we map a step to a form id.
+ // Here we map a step to a form id.
'forms' => array(
- // e.g. this for the step at wombat/create
+ // e.g. this for the step at wombat/create.
'start' => array(
- 'form id' => 'ctools_ajax_sample_start'
+ 'form id' => 'ctools_ajax_sample_start',
),
),
);
@@ -341,7 +342,6 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
// in creation.
//
// We skip all this here by just using an id of 1.
-
$object_id = 1;
if (empty($step)) {
@@ -406,7 +406,7 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
$commands[] = ajax_command_html('#ctools-sample', $animal);
$commands[] = ctools_modal_command_dismiss();
}
- else if (!empty($form_state['cancel'])) {
+ elseif (!empty($form_state['cancel'])) {
// If cancelling, return to the activity.
$commands[] = ctools_modal_command_dismiss();
}
@@ -420,7 +420,7 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
if ($output === FALSE || !empty($form_state['complete'])) {
return $animal;
}
- else if (!empty($form_state['cancel'])) {
+ elseif (!empty($form_state['cancel'])) {
drupal_goto('ctools_ajax_sample');
}
else {
@@ -430,11 +430,11 @@ function ctools_ajax_sample_animal($js = NULL, $step = NULL) {
}
// ---------------------------------------------------------------------------
-// Themes
-
+// Themes.
/**
* Theme function for main rendered output.
*/
+
function theme_ctools_ajax_sample_container($vars) {
$output = '
';
$output .= $vars['content'];
@@ -445,7 +445,6 @@ function theme_ctools_ajax_sample_container($vars) {
// ---------------------------------------------------------------------------
// Stuff needed for our little wizard.
-
/**
* Get a list of our animals and associated forms.
*
@@ -453,6 +452,7 @@ function theme_ctools_ajax_sample_container($vars) {
* which is often how it will work in the real world. If using CTools, what
* you would probably really have, here, is a set of plugins for each animal.
*/
+
function ctools_ajax_sample_animals() {
return array(
'sheep' => array(
@@ -478,10 +478,10 @@ function ctools_ajax_sample_animals() {
// ---------------------------------------------------------------------------
// Wizard caching helpers.
-
/**
* Store our little cache so that we can retain data from form to form.
*/
+
function ctools_ajax_sample_cache_set($id, $object) {
ctools_include('object-cache');
ctools_object_cache_set('ctools_ajax_sample', $id, $object);
@@ -495,7 +495,7 @@ function ctools_ajax_sample_cache_get($id) {
$object = ctools_object_cache_get('ctools_ajax_sample', $id);
if (!$object) {
// Create a default object.
- $object = new stdClass;
+ $object = new stdClass();
$object->type = 'unknown';
$object->name = '';
}
@@ -513,18 +513,18 @@ function ctools_ajax_sample_cache_clear($id) {
// ---------------------------------------------------------------------------
// Wizard in-between helpers; what to do between or after forms.
-
/**
* Handle the 'next' click on the add/edit pane form wizard.
*
* All we need to do is store the updated pane in the cache.
*/
+
function ctools_ajax_sample_wizard_next(&$form_state) {
ctools_ajax_sample_cache_set($form_state['object_id'], $form_state['object']);
}
/**
- * Handle the 'finish' click on teh add/edit pane form wizard.
+ * Handle the 'finish' click on the add/edit pane form wizard.
*
* All we need to do is set a flag so the return can handle adding
* the pane.
@@ -542,10 +542,10 @@ function ctools_ajax_sample_wizard_cancel(&$form_state) {
// ---------------------------------------------------------------------------
// Wizard forms for our simple info collection wizard.
-
/**
* Wizard start form. Choose an animal.
*/
+
function ctools_ajax_sample_start($form, &$form_state) {
$form_state['title'] = t('Choose animal');
@@ -713,7 +713,7 @@ function ctools_ajax_sample_show_raptor($object) {
}
/**
- * Helper function to provide a sample jump menu form
+ * Helper function to provide a sample jump menu form.
*/
function ctools_ajax_sample_jump_menu_form() {
$url = url('ctools_ajax_sample/jumped');
@@ -723,7 +723,7 @@ function ctools_ajax_sample_jump_menu_form() {
}
/**
- * Provide a message to the user that the jump menu worked
+ * Provide a message to the user that the jump menu worked.
*/
function ctools_ajax_sample_jump_menu_page() {
$return_link = l(t('Return to the examples page.'), 'ctools_ajax_sample');
@@ -732,7 +732,7 @@ function ctools_ajax_sample_jump_menu_page() {
}
/**
- * Provide a form for an example ajax modal button
+ * Provide a form for an example ajax modal button.
*/
function ctools_ajax_sample_ajax_button_form() {
$form = array();
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info
index d9c4567..2bc7348 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.info
@@ -4,9 +4,8 @@ core = 7.x
package = Chaos tool suite
dependencies[] = ctools
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.install b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.install
index b4512f2..dcf87e7 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.install
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/ctools_custom_content.install
@@ -1,5 +1,9 @@
type == 'custom') {
+ if (!isset($pane->configuration['name'])) {
+ $name_of_pane = $pane->subtype;
+ }
+ else {
+ $name_of_pane = $pane->configuration['name'];
+ }
+
+ $links['top']['edit_custom_content'] = array(
+ 'title' => t('Edit custom content pane'),
+ 'href' => url('admin/structure/ctools-content/list/' . $name_of_pane . '/edit', array('absolute' => TRUE)),
+ 'attributes' => array('target' => array('_blank')),
+ );
+ }
+}
+
/**
* Create callback for creating a new CTools custom content type.
*
@@ -60,7 +80,7 @@ function ctools_custom_content_panels_dashboard_blocks(&$vars) {
'description' => t('Custom content panes are basic HTML you enter that can be reused in all of your panels.'),
);
- // Load all mini panels and their displays.
+ // Load all mini panels and their displays.
ctools_include('export');
$items = ctools_export_crud_load_all('ctools_custom_content');
$count = 0;
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc
index 467dc58..c7933bc 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content.inc
@@ -1,5 +1,9 @@
'ctools_custom_content',
'access' => 'administer custom content',
@@ -17,4 +21,3 @@ $plugin = array(
'handler' => 'ctools_custom_content_ui',
);
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php
index 56fe4b2..e56f7a7 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php
+++ b/sites/all/modules/contrib/dev/ctools/ctools_custom_content/plugins/export_ui/ctools_custom_content_ui.class.php
@@ -2,7 +2,7 @@
class ctools_custom_content_ui extends ctools_export_ui {
- function edit_form(&$form, &$form_state) {
+ public function edit_form(&$form, &$form_state) {
// Correct for an error that came in because filter format changed.
if (is_array($form_state['item']->settings['body'])) {
$form_state['item']->settings['format'] = $form_state['item']->settings['body']['format'];
@@ -23,6 +23,22 @@ class ctools_custom_content_ui extends ctools_export_ui {
'#title' => t('Title'),
);
+ $form['title_heading'] = array(
+ '#title' => t('Title heading'),
+ '#type' => 'select',
+ '#default_value' => isset($form_state['item']->settings['title_heading']) ? $form_state['item']->settings['title_heading'] : 'h2',
+ '#options' => array(
+ 'h1' => t('h1'),
+ 'h2' => t('h2'),
+ 'h3' => t('h3'),
+ 'h4' => t('h4'),
+ 'h5' => t('h5'),
+ 'h6' => t('h6'),
+ 'div' => t('div'),
+ 'span' => t('span'),
+ ),
+ );
+
$form['body'] = array(
'#type' => 'text_format',
'#title' => t('Body'),
@@ -38,17 +54,18 @@ class ctools_custom_content_ui extends ctools_export_ui {
);
}
- function edit_form_submit(&$form, &$form_state) {
+ public function edit_form_submit(&$form, &$form_state) {
parent::edit_form_submit($form, $form_state);
// Since items in our settings are not in the schema, we have to do these manually:
$form_state['item']->settings['title'] = $form_state['values']['title'];
+ $form_state['item']->settings['title_heading'] = $form_state['values']['title_heading'];
$form_state['item']->settings['body'] = $form_state['values']['body']['value'];
$form_state['item']->settings['format'] = $form_state['values']['body']['format'];
$form_state['item']->settings['substitute'] = $form_state['values']['substitute'];
}
- function list_form(&$form, &$form_state) {
+ public function list_form(&$form, &$form_state) {
parent::list_form($form, $form_state);
$options = array('all' => t('- All -'));
@@ -65,7 +82,7 @@ class ctools_custom_content_ui extends ctools_export_ui {
);
}
- function list_filter($form_state, $item) {
+ public function list_filter($form_state, $item) {
if ($form_state['values']['category'] != 'all' && $form_state['values']['category'] != $item->category) {
return TRUE;
}
@@ -73,7 +90,7 @@ class ctools_custom_content_ui extends ctools_export_ui {
return parent::list_filter($form_state, $item);
}
- function list_sort_options() {
+ public function list_sort_options() {
return array(
'disabled' => t('Enabled, title'),
'title' => t('Title'),
@@ -83,21 +100,25 @@ class ctools_custom_content_ui extends ctools_export_ui {
);
}
- function list_build_row($item, &$form_state, $operations) {
- // Set up sorting
+ public function list_build_row($item, &$form_state, $operations) {
+ // Set up sorting.
switch ($form_state['values']['order']) {
case 'disabled':
$this->sorts[$item->name] = empty($item->disabled) . $item->admin_title;
break;
+
case 'title':
$this->sorts[$item->name] = $item->admin_title;
break;
+
case 'name':
$this->sorts[$item->name] = $item->name;
break;
+
case 'category':
$this->sorts[$item->name] = $item->category;
break;
+
case 'storage':
$this->sorts[$item->name] = $item->type . $item->admin_title;
break;
@@ -117,7 +138,7 @@ class ctools_custom_content_ui extends ctools_export_ui {
);
}
- function list_table_header() {
+ public function list_table_header() {
return array(
array('data' => t('Name'), 'class' => array('ctools-export-ui-name')),
array('data' => t('Title'), 'class' => array('ctools-export-ui-title')),
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/README.txt b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/README.txt
index 42edcdc..2f9b0ff 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/README.txt
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/README.txt
@@ -11,4 +11,4 @@ There are a number of ways to profit from this:
2. There is a sample panel. You can access it at /ctools_plugin_example/xxxx
to see how it works.
-3. There is Advanced Help at admin/advanced_help/ctools_plugin_example.
\ No newline at end of file
+3. There is Advanced Help at admin/advanced_help/ctools_plugin_example.
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info
index e4fa534..3f268db 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.info
@@ -7,9 +7,8 @@ dependencies[] = page_manager
dependencies[] = advanced_help
core = 7.x
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.x-1.3"
+; Information added by Drupal.org packaging script on 2019-02-08
+version = "7.x-1.15"
core = "7.x"
project = "ctools"
-datestamp = "1365013512"
-
+datestamp = "1549603691"
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.module b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.module
index 01d5338..a9a6080 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.module
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.module
@@ -1,9 +1,8 @@
.pages_default.inc
+ * .pages_default.inc.
*/
function ctools_plugin_example_ctools_plugin_api($module, $api) {
// @todo -- this example should explain how to put it in a different file.
@@ -71,7 +70,8 @@ function ctools_plugin_example_ctools_plugin_api($module, $api) {
}
/**
- * Just provide an explanation page for the admin section
+ * Just provide an explanation page for the admin section.
+ *
* @return unknown_type
*/
function ctools_plugin_example_explanation_page() {
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.pages_default.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.pages_default.inc
index 10a7619..ed3ffd7 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.pages_default.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/ctools_plugin_example.pages_default.inc
@@ -6,7 +6,7 @@
*/
/**
- * Default panels pages for CTools Plugin Example
+ * Default panels pages for CTools Plugin Example.
*
* To pick up this file, your module needs to implement
* hook_ctools_plugin_api() - See ctools_plugin_example_ctools_plugin_api() in
@@ -23,12 +23,10 @@
* @return
* Array of pages, normally exported from Panels.
*/
-
function ctools_plugin_example_default_page_manager_pages() {
- // begin exported panel.
-
- $page = new stdClass;
+ // Begin exported panel.
+ $page = new stdClass();
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
$page->api_version = 1;
$page->name = 'ctools_plugin_example';
@@ -37,31 +35,31 @@ function ctools_plugin_example_default_page_manager_pages() {
$page->admin_description = 'This panel provides no functionality to a working Drupal system. It\'s intended to display the various sample plugins provided by the CTools Plugin Example module. ';
$page->path = 'ctools_plugin_example/%sc';
$page->access = array(
- 'logic' => 'and',
+ 'logic' => 'and',
);
$page->menu = array(
- 'type' => 'normal',
- 'title' => 'CTools plugin example',
- 'name' => 'navigation',
- 'weight' => '0',
- 'parent' => array(
- 'type' => 'none',
- 'title' => '',
+ 'type' => 'normal',
+ 'title' => 'CTools plugin example',
'name' => 'navigation',
'weight' => '0',
- ),
+ 'parent' => array(
+ 'type' => 'none',
+ 'title' => '',
+ 'name' => 'navigation',
+ 'weight' => '0',
+ ),
);
$page->arguments = array(
- 'sc' => array(
- 'id' => 2,
- 'identifier' => 'simplecontext-arg',
- 'name' => 'simplecontext_arg',
- 'settings' => array(),
- ),
+ 'sc' => array(
+ 'id' => 2,
+ 'identifier' => 'simplecontext-arg',
+ 'name' => 'simplecontext_arg',
+ 'settings' => array(),
+ ),
);
$page->conf = array();
$page->default_handlers = array();
- $handler = new stdClass;
+ $handler = new stdClass();
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
$handler->api_version = 1;
$handler->name = 'page_ctools_panel_context';
@@ -70,44 +68,45 @@ function ctools_plugin_example_default_page_manager_pages() {
$handler->handler = 'panel_context';
$handler->weight = 0;
$handler->conf = array(
- 'title' => 'Panel',
- 'no_blocks' => FALSE,
- 'css_id' => '',
- 'css' => '',
- 'contexts' => array(
- '0' => array(
- 'name' => 'simplecontext',
- 'id' => 1,
- 'identifier' => 'Configured simplecontext (not from argument)',
- 'keyword' => 'configured_simplecontext',
- 'context_settings' => array(
- 'sample_simplecontext_setting' => 'default simplecontext setting',
- ),
- ),
- ),
- 'relationships' => array(
- '0' => array(
- 'context' => 'argument_simplecontext_arg_2',
- 'name' => 'relcontext_from_simplecontext',
- 'id' => 1,
- 'identifier' => 'Relcontext from simplecontext (from relationship)',
- 'keyword' => 'relcontext',
- ),
- ),
- 'access' => array(
- 'logic' => 'and',
- ),
+ 'title' => 'Panel',
+ 'no_blocks' => FALSE,
+ 'css_id' => '',
+ 'css' => '',
+ 'contexts' => array(
+ '0' => array(
+ 'name' => 'simplecontext',
+ 'id' => 1,
+ 'identifier' => 'Configured simplecontext (not from argument)',
+ 'keyword' => 'configured_simplecontext',
+ 'context_settings' => array(
+ 'sample_simplecontext_setting' => 'default simplecontext setting',
+ ),
+ ),
+ ),
+ 'relationships' => array(
+ '0' => array(
+ 'context' => 'argument_simplecontext_arg_2',
+ 'name' => 'relcontext_from_simplecontext',
+ 'id' => 1,
+ 'identifier' => 'Relcontext from simplecontext (from relationship)',
+ 'keyword' => 'relcontext',
+ ),
+ ),
+ 'access' => array(
+ 'logic' => 'and',
+ ),
+ 'pipeline' => 'standard',
);
- $display = new panels_display;
+ $display = new panels_display();
$display->layout = 'threecol_33_34_33_stacked';
$display->layout_settings = array();
$display->panel_settings = array(
- 'style' => 'rounded_corners',
- 'style_settings' => array(
- 'default' => array(
- 'corner_location' => 'pane',
- ),
- ),
+ 'style' => 'rounded_corners',
+ 'style_settings' => array(
+ 'default' => array(
+ 'corner_location' => 'pane',
+ ),
+ ),
);
$display->cache = array();
$display->title = 'CTools plugin example panel';
@@ -115,7 +114,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$display->title_pane = 1;
$display->content = array();
$display->panels = array();
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-1';
$pane->panel = 'left';
$pane->type = 'no_context_content_type';
@@ -135,7 +134,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 0;
$display->content['new-1'] = $pane;
$display->panels['left'][0] = 'new-1';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-2';
$pane->panel = 'left';
$pane->type = 'custom';
@@ -148,15 +147,15 @@ function ctools_plugin_example_default_page_manager_pages() {
'settings' => array(
'greater_than' => '1',
'arg_length' => '4',
- ),
+ ),
'context' => 'argument_simplecontext_arg_2',
- ),
- ),
+ ),
+ ),
);
$pane->configuration = array(
'title' => 'Long Arg Visibility Block',
'body' => 'This block will be here when the argument is longer than configured arg length. It uses the \'arg_length\' access plugin to test against the length of the argument used for Simplecontext.',
- 'format' => '1',
+ 'format' => 'filtered_html',
'substitute' => 1,
);
$pane->cache = array();
@@ -166,7 +165,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 1;
$display->content['new-2'] = $pane;
$display->panels['left'][1] = 'new-2';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-3';
$pane->panel = 'left';
$pane->type = 'custom';
@@ -179,15 +178,15 @@ function ctools_plugin_example_default_page_manager_pages() {
'settings' => array(
'greater_than' => '0',
'arg_length' => '4',
- ),
+ ),
'context' => 'argument_simplecontext_arg_2',
- ),
- ),
+ ),
+ ),
);
$pane->configuration = array(
'title' => 'Short Arg Visibility',
'body' => 'This block appears when the simplecontext argument is less than the configured length.',
- 'format' => '1',
+ 'format' => 'filtered_html',
'substitute' => 1,
);
$pane->cache = array();
@@ -197,7 +196,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 2;
$display->content['new-3'] = $pane;
$display->panels['left'][2] = 'new-3';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-4';
$pane->panel = 'middle';
$pane->type = 'simplecontext_content_type';
@@ -241,7 +240,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 0;
$display->content['new-4'] = $pane;
$display->panels['middle'][0] = 'new-4';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-5';
$pane->panel = 'middle';
$pane->type = 'simplecontext_content_type';
@@ -285,7 +284,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 1;
$display->content['new-5'] = $pane;
$display->panels['middle'][1] = 'new-5';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-6';
$pane->panel = 'middle';
$pane->type = 'custom';
@@ -299,7 +298,7 @@ function ctools_plugin_example_default_page_manager_pages() {
item1 is %sc:item1
item2 is %sc:item2
description is %sc:description',
- 'format' => '1',
+ 'format' => 'filtered_html',
'substitute' => 1,
);
$pane->cache = array();
@@ -309,7 +308,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 2;
$display->content['new-6'] = $pane;
$display->panels['middle'][2] = 'new-6';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-7';
$pane->panel = 'right';
$pane->type = 'relcontext_content_type';
@@ -353,7 +352,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->position = 0;
$display->content['new-7'] = $pane;
$display->panels['right'][0] = 'new-7';
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-8';
$pane->panel = 'top';
$pane->type = 'custom';
@@ -365,7 +364,7 @@ function ctools_plugin_example_default_page_manager_pages() {
'body' => 'The CTools Plugin Example module (and this panel page) are just here to demonstrate how to build CTools plugins.
',
- 'format' => '2',
+ 'format' => 'full_html',
'substitute' => 1,
);
$pane->cache = array();
@@ -378,12 +377,11 @@ function ctools_plugin_example_default_page_manager_pages() {
$handler->conf['display'] = $display;
$page->default_handlers[$handler->name] = $handler;
- // end of exported panel.
+ // End of exported panel.
$pages['ctools_plugin_example_demo_page'] = $page;
- // begin exported panel
-
- $page = new stdClass;
+ // Begin exported panel.
+ $page = new stdClass();
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
$page->api_version = 1;
$page->name = 'ctools_plugin_example_base';
@@ -396,7 +394,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$page->arguments = array();
$page->conf = array();
$page->default_handlers = array();
- $handler = new stdClass;
+ $handler = new stdClass();
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
$handler->api_version = 1;
$handler->name = 'page_ctools_plugin_example_base_panel_context';
@@ -405,14 +403,15 @@ function ctools_plugin_example_default_page_manager_pages() {
$handler->handler = 'panel_context';
$handler->weight = 0;
$handler->conf = array(
- 'title' => 'Panel',
- 'no_blocks' => FALSE,
- 'css_id' => '',
- 'css' => '',
- 'contexts' => array(),
- 'relationships' => array(),
+ 'title' => 'Panel',
+ 'no_blocks' => FALSE,
+ 'css_id' => '',
+ 'css' => '',
+ 'contexts' => array(),
+ 'relationships' => array(),
+ 'pipeline' => 'standard',
);
- $display = new panels_display;
+ $display = new panels_display();
$display->layout = 'onecol';
$display->layout_settings = array();
$display->panel_settings = array();
@@ -421,7 +420,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$display->hide_title = FALSE;
$display->content = array();
$display->panels = array();
- $pane = new stdClass;
+ $pane = new stdClass();
$pane->pid = 'new-1';
$pane->panel = 'middle';
$pane->type = 'custom';
@@ -431,7 +430,7 @@ function ctools_plugin_example_default_page_manager_pages() {
$pane->configuration = array(
'title' => 'Use this page with an argument',
'body' => 'This demo page works if you use an argument, like ctools_plugin_example/xxxxx.',
- 'format' => '1',
+ 'format' => 'filtered_html',
'substitute' => NULL,
);
$pane->cache = array();
@@ -443,9 +442,8 @@ function ctools_plugin_example_default_page_manager_pages() {
$display->panels['middle'][0] = 'new-1';
$handler->conf['display'] = $display;
$page->default_handlers[$handler->name] = $handler;
- // end exported panel.
-
+ // End exported panel.
$pages['base_page'] = $page;
return $pages;
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/arg_length.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/arg_length.inc
index 2a09eea..3b5d863 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/arg_length.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/arg_length.inc
@@ -59,7 +59,8 @@ function ctools_plugin_example_arg_length_ctools_access_check($conf, $context) {
*/
function ctools_plugin_example_arg_length_ctools_access_summary($conf, $context) {
return t('Simpletext argument must be !comp @length characters',
- array('!comp' => $conf['greater_than'] ? 'greater than' : 'less than or equal to',
- '@length' => $conf['arg_length']));
+ array(
+ '!comp' => $conf['greater_than'] ? 'greater than' : 'less than or equal to',
+ '@length' => $conf['arg_length'],
+ ));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/example_role.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/example_role.inc
index bbe364c..75721e8 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/example_role.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/access/example_role.inc
@@ -4,7 +4,7 @@
* @file
* Plugin to provide access control based upon role membership.
* This is directly from the ctools module, but serves as a good
- * example of an access plugin
+ * example of an access plugin.
*/
/**
@@ -73,4 +73,3 @@ function ctools_plugin_example_example_role_ctools_access_summary($conf, $contex
}
return format_plural(count($names), '@identifier must have role "@roles"', '@identifier can be one of "@roles"', array('@roles' => implode(', ', $names), '@identifier' => $context->identifier));
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc
index 51c7c60..7fb732c 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/arguments/simplecontext_arg.inc
@@ -2,7 +2,6 @@
/**
* @file
- *
* Sample plugin to provide an argument handler for a simplecontext.
*
* Given any argument to the page, simplecontext will get it
@@ -18,14 +17,12 @@
*/
$plugin = array(
'title' => t("Simplecontext arg"),
- // keyword to use for %substitution
+ // Keyword to use for %substitution.
'keyword' => 'simplecontext',
'description' => t('Creates a "simplecontext" from the arg.'),
'context' => 'simplecontext_arg_context',
- // 'settings form' => 'simplecontext_arg_settings_form',
-
// placeholder_form is used in panels preview, for example, so we can
- // preview without getting the arg from a URL
+ // preview without getting the arg from a URL.
'placeholder form' => array(
'#type' => 'textfield',
'#description' => t('Enter the simplecontext arg'),
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc
index 3c02ab8..48ce0f5 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/no_context_content_type.inc
@@ -5,7 +5,6 @@
* "No context" sample content type. It operates with no context at all. It would
* be basically the same as a 'custom content' block, but it's not even that
* sophisticated.
- *
*/
/**
@@ -33,7 +32,7 @@ $plugin = array(
'icon' => 'icon_example.png',
'category' => array(t('CTools Examples'), -9),
- // this example does not provide 'admin info', which would populate the
+ // This example does not provide 'admin info', which would populate the
// panels builder page preview.
);
@@ -56,7 +55,7 @@ function no_context_content_type_render($subtype, $conf, $args, $context) {
$ctools_help = theme('advanced_help_topic', array('module' => 'ctools', 'topic' => 'plugins', 'type' => 'title'));
$ctools_plugin_example_help = theme('advanced_help_topic', array('module' => 'ctools_plugin_example', 'topic' => 'Chaos-Tools--CTools--Plugin-Examples', 'type' => 'title'));
- // The title actually used in rendering
+ // The title actually used in rendering.
$block->title = check_plain("No-context content type");
$block->content = t("
Welcome to the CTools Plugin Example demonstration content type.
@@ -84,7 +83,6 @@ function no_context_content_type_render($subtype, $conf, $args, $context) {
* Note that if we had not provided an entry for this in hook_content_types,
* this could have had the default name
* ctools_plugin_example_no_context_content_type_edit_form.
- *
*/
function no_context_content_type_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc
index bf54dce..ced6411 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/relcontext_content_type.inc
@@ -1,6 +1,5 @@
array(t('CTools Examples'), -9),
'edit form' => 'relcontext_edit_form',
- // this example does not provide 'admin info', which would populate the
+ // This example does not provide 'admin info', which would populate the
// panels builder page preview.
-
);
/**
@@ -60,7 +58,7 @@ function relcontext_content_type_render($subtype, $conf, $args, $context) {
In our case, the configuration form (\$conf) has just one field, 'config_item_1;
and it's configured with:
");
- if (!empty($conf)) {
+ if (!empty($conf)) {
$block->content .= '
' . var_export($conf['config_item_1'], TRUE) . '
';
}
if (!empty($context)) {
@@ -77,7 +75,6 @@ function relcontext_content_type_render($subtype, $conf, $args, $context) {
/**
* 'Edit' callback for the content type.
* This example just returns a form.
- *
*/
function relcontext_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc
index a308683..e34fa18 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/content_types/simplecontext_content_type.inc
@@ -1,6 +1,5 @@
'simplecontext_content_type_edit_form',
'admin title' => 'ctools_plugin_example_simplecontext_content_type_admin_title',
- // presents a block which is used in the preview of the data.
+ // Presents a block which is used in the preview of the data.
// Pn Panels this is the preview pane shown on the panels building page.
'admin info' => 'ctools_plugin_example_simplecontext_content_type_admin_info',
'category' => array(t('CTools Examples'), -9),
@@ -103,7 +101,6 @@ function simplecontext_content_type_render($subtype, $conf, $args, $context) {
/**
* 'Edit' callback for the content type.
* This example just returns a form.
- *
*/
function simplecontext_content_type_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc
index 0c7ef11..61e25db 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/relcontext.inc
@@ -80,4 +80,3 @@ function relcontext_settings_form($conf, $external = FALSE) {
);
return $form;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc
index e19a842..0ee4658 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/contexts/simplecontext.inc
@@ -1,10 +1,8 @@
t("Simplecontext"),
'description' => t('A single "simplecontext" context, or data element.'),
- 'context' => 'ctools_plugin_example_context_create_simplecontext', // func to create context
+// Func to create context.
+ 'context' => 'ctools_plugin_example_context_create_simplecontext',
'context name' => 'simplecontext',
'settings form' => 'simplecontext_settings_form',
'keyword' => 'simplecontext',
@@ -69,7 +68,7 @@ function ctools_plugin_example_context_create_simplecontext($empty, $data = NULL
// This is used for keyword.
$context->title = $data;
$context->argument = $data;
- // Make up a bogus context
+ // Make up a bogus context.
$context->data = new stdClass();
$context->data->item1 = t("Item1");
$context->data->item2 = t("Item2");
@@ -102,8 +101,6 @@ function simplecontext_settings_form($conf, $external = FALSE) {
return $form;
}
-
-
/**
* Provide a list of sub-keywords.
*
@@ -125,10 +122,11 @@ function simplecontext_convert($context, $type) {
switch ($type) {
case 'item1':
return $context->data->item1;
+
case 'item2':
return $context->data->item2;
+
case 'description':
return $context->data->description;
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/panels.pages.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/panels.pages.inc
index d3022af..25422cf 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/panels.pages.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/panels.pages.inc
@@ -19,24 +19,24 @@ function ctools_plugin_example_default_panel_pages() {
$page->load_flags = 1;
$page->css_id = '';
$page->arguments = array(
- 0 =>
+ 0 =>
array(
- 'name' => 'simplecontext_arg',
- 'id' => 1,
- 'default' => '404',
- 'title' => '',
- 'identifier' => 'Simplecontext arg',
- 'keyword' => 'simplecontext',
+ 'name' => 'simplecontext_arg',
+ 'id' => 1,
+ 'default' => '404',
+ 'title' => '',
+ 'identifier' => 'Simplecontext arg',
+ 'keyword' => 'simplecontext',
),
);
$page->relationships = array(
- 0 =>
+ 0 =>
array(
- 'context' => 'argument_simplecontext_arg_1',
- 'name' => 'relcontext_from_simplecontext',
- 'id' => 1,
- 'identifier' => 'Relcontext from Simplecontext',
- 'keyword' => 'relcontext',
+ 'context' => 'argument_simplecontext_arg_1',
+ 'name' => 'relcontext_from_simplecontext',
+ 'id' => 1,
+ 'identifier' => 'Relcontext from Simplecontext',
+ 'keyword' => 'relcontext',
),
);
$page->no_blocks = '0';
@@ -58,14 +58,14 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'custom';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'title' => '"No Context Item"',
- 'body' => 'The "no context item" content type is here to demonstrate that you can create a content_type that does not require a context. This is probably the same as just creating a custom php block on the fly, and might serve the same purpose.',
- 'format' => '1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => '"No Context Item"',
+ 'body' => 'The "no context item" content type is here to demonstrate that you can create a content_type that does not require a context. This is probably the same as just creating a custom php block on the fly, and might serve the same purpose.',
+ 'format' => '1',
);
$pane->cache = array();
$display->content['new-1'] = $pane;
@@ -78,14 +78,14 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'description';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'item1' => 'one',
- 'item2' => 'two',
- 'item3' => 'three',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'item1' => 'one',
+ 'item2' => 'two',
+ 'item3' => 'three',
);
$pane->cache = array();
$display->content['new-2'] = $pane;
@@ -98,16 +98,16 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'custom';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'title' => 'Simplecontext',
- 'body' => 'The "Simplecontext" content and content type demonstrate a very basic context and how to display it.
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => 'Simplecontext',
+ 'body' => 'The "Simplecontext" content and content type demonstrate a very basic context and how to display it.
Simplecontext includes configuration, so it can get info from the config. It can also get its information to run from a simplecontext context, generated either from an arg to the panels page or via explicitly adding a context to the page.',
- 'format' => '1',
+ 'format' => '1',
);
$pane->cache = array();
$display->content['new-3'] = $pane;
@@ -119,17 +119,17 @@ function ctools_plugin_example_default_panel_pages() {
$pane->shown = '1';
$pane->subtype = 'description';
$pane->access = array(
- 0 => '2',
- 1 => '4',
+ 0 => '2',
+ 1 => '4',
);
$pane->configuration = array(
- 'context' => 'argument_simplecontext_arg_1',
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'config_item_1' => 'simplecontext called from arg',
+ 'context' => 'argument_simplecontext_arg_1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'config_item_1' => 'simplecontext called from arg',
);
$pane->cache = array();
$display->content['new-4'] = $pane;
@@ -142,14 +142,14 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'custom';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'title' => 'Relcontext',
- 'body' => 'The relcontext content_type gets its data from a relcontext, which is an example of a relationship. This panel should be run with an argument like "/xxx", which allows the simplecontext to get its context, and then the relcontext is configured in this panel to get (create) its data from the simplecontext.',
- 'format' => '1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => 'Relcontext',
+ 'body' => 'The relcontext content_type gets its data from a relcontext, which is an example of a relationship. This panel should be run with an argument like "/xxx", which allows the simplecontext to get its context, and then the relcontext is configured in this panel to get (create) its data from the simplecontext.',
+ 'format' => '1',
);
$pane->cache = array();
$display->content['new-5'] = $pane;
@@ -162,13 +162,13 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'description';
$pane->access = array();
$pane->configuration = array(
- 'context' => 'relationship_relcontext_from_simplecontext_1',
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'config_item_1' => 'default1',
+ 'context' => 'relationship_relcontext_from_simplecontext_1',
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'config_item_1' => 'default1',
);
$pane->cache = array();
$display->content['new-6'] = $pane;
@@ -181,13 +181,13 @@ function ctools_plugin_example_default_panel_pages() {
$pane->subtype = 'custom_php';
$pane->access = array();
$pane->configuration = array(
- 'style' => 'default',
- 'override_title' => 0,
- 'override_title_text' => '',
- 'css_id' => '',
- 'css_class' => '',
- 'title' => '',
- 'body' => '$arg = arg(1);
+ 'style' => 'default',
+ 'override_title' => 0,
+ 'override_title_text' => '',
+ 'css_id' => '',
+ 'css_class' => '',
+ 'title' => '',
+ 'body' => '$arg = arg(1);
$arg0 = arg(0);
if (!$arg) {
$block->content = <<displays = array();
$pages['ctools_plugin_example'] = $page;
-
return $pages;
}
diff --git a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc
index 6224621..087d5ec 100644
--- a/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc
+++ b/sites/all/modules/contrib/dev/ctools/ctools_plugin_example/plugins/relationships/relcontext_from_simplecontext.inc
@@ -1,9 +1,7 @@
'Space separated list of exportables you want to view.',
),
'options' => array(
- 'indent' => 'The string to use for indentation when dispalying the exportable export code. Defaults to \'\'.',
+ 'indent' => 'The string to use for indentation when displaying the exportable export code. Defaults to \'\'.',
'no-colour' => 'Remove any colour formatting from export string output. Ideal if you are sending the output of this command to a file.',
'module' => $module_text,
'all' => $all_text,
@@ -140,13 +140,14 @@ function ctools_drush_help($section) {
switch ($section) {
case 'meta:ctools:title':
return dt('CTools commands');
+
case 'meta:entity:summary':
return dt('CTools drush commands.');
}
}
/**
- * Drush callback: export
+ * Drush callback: export.
*/
function ctools_drush_export($module = 'foo') {
$error = FALSE;
@@ -338,7 +339,7 @@ function _ctools_drush_selection_screen(array $tables = array()) {
$build[$table_choice]['count'] = count($multi_select);
$selections[$table_choice] = array();
foreach ($multi_select as $key) {
- $selections[$table_choice][$key] = $key;
+ $selections[$table_choice][$key] = $key;
}
}
}
@@ -445,11 +446,13 @@ function ctools_drush_export_info() {
}
}
}
+
/**
* Drush callback: Acts as the hub for all op commands to keep
* all arg handling etc in one place.
*/
function ctools_drush_export_op_command() {
+ $args = func_get_args();
// Get all info for the current drush command.
$command = drush_get_command();
$op = '';
@@ -457,17 +460,20 @@ function ctools_drush_export_op_command() {
switch ($command['command']) {
case 'ctools-export-view':
$op = 'view';
- break;
+ break;
+
case 'ctools-export-revert':
// Revert is same as deleting. As any objects in the db are deleted.
$op = 'delete';
- break;
+ break;
+
case 'ctools-export-enable':
$op = 'enable';
- break;
+ break;
+
case 'ctools-export-disable':
$op = 'disable';
- break;
+ break;
}
if (!$op) {
@@ -475,7 +481,7 @@ function ctools_drush_export_op_command() {
}
if (drush_get_option('all', FALSE)) {
- $info = _ctools_drush_export_info('', TRUE);
+ $info = _ctools_drush_export_info(array(), TRUE);
$exportable_info = $info['exportables'];
$all = drush_confirm(dt('Are you sure you would like to !op all exportables on the system?',
@@ -490,7 +496,6 @@ function ctools_drush_export_op_command() {
}
}
else {
- $args = func_get_args();
// Table name should always be first arg...
$table_name = array_shift($args);
// Any additional args are assumed to be exportable names.
@@ -512,7 +517,6 @@ function ctools_drush_export_op_command() {
* @param $op
* @param $table_name
* @param $exportables
- *
*/
function ctools_drush_export_op($op = '', $table_name = '', $exportables = NULL) {
$objects = ctools_export_crud_load_multiple($table_name, array_keys($exportables));
@@ -538,7 +542,7 @@ function ctools_drush_export_op($op = '', $table_name = '', $exportables = NULL)
* @param $object_names
*
* @return
- * Array of exportable objects (filtered if necessary, by name etc..) or FALSE if not.
+ * Array of exportable objects (filtered if necessary, by name etc..) or FALSE if not.
*/
function _ctools_drush_export_op_command_logic($op = '', $table_name = NULL, array $object_names = array()) {
if (!$table_name) {
@@ -644,7 +648,7 @@ function _ctools_drush_export_info(array $table_names = array(), $load = FALSE)
return array('exportables' => $exportables, 'schemas' => $schemas);
}
-/*
+/**
* View a single object.
*
* @param $table_name
@@ -662,7 +666,7 @@ function _ctools_drush_export_view($table_name, $object) {
}
}
-/*
+/**
* Revert a single object.
*
* @param $table_name
@@ -681,7 +685,7 @@ function _ctools_drush_export_delete($table_name, $object) {
}
}
-/*
+/**
* Enable a single object.
*
* @param $table_name
@@ -701,7 +705,7 @@ function _ctools_drush_export_enable($table_name, $object) {
}
}
-/*
+/**
* Disable a single object.
*
* @param $table_name
@@ -723,9 +727,9 @@ function _ctools_drush_export_disable($table_name, $object) {
/**
* Filter a nested array of exportables by export module.
*
- * @param $exportables array
+ * @param array $exportables
* Passed by reference. A nested array of exportables, keyed by table name.
- * @param $export_module string
+ * @param string $export_module
* The name of the export module providing the exportable.
*/
function _ctools_drush_export_module_filter($exportables, $export_module) {
@@ -778,7 +782,7 @@ function _ctools_drush_object_is_disabled($object) {
/**
* Determine if an object is enabled.
*
- * @see _ctools_drush_object_is_disabled.
+ * @see _ctools_drush_object_is_disabled()
*/
function _ctools_drush_object_is_enabled($object) {
return (empty($object->disabled)) ? TRUE : FALSE;
@@ -835,7 +839,7 @@ function _ctools_drush_object_is_not_code_only($object) {
* Array of exportables to count.
*
* @return
- * Array of count data containing the following:
+ * Array of count data containing the following:
* 'total' - A total count of all exportables.
* 'exportables' - An array of exportable counts per table.
*/
@@ -867,26 +871,32 @@ function _ctools_drush_filter_exportables($exportables, $filter) {
// Show enabled exportables only.
case 'enabled':
$eval = '_ctools_drush_object_is_disabled';
- break;
+ break;
+
// Show disabled exportables only.
case 'disabled':
$eval = '_ctools_drush_object_is_enabled';
- break;
+ break;
+
// Show overridden exportables only.
case 'overridden':
$eval = '_ctools_drush_object_is_not_overridden';
- break;
+ break;
+
// Show database only exportables.
case 'database':
$eval = '_ctools_drush_object_is_not_db_only';
- break;
+ break;
+
// Show code only exportables.
case 'code':
$eval = '_ctools_drush_object_is_not_code_only';
- break;
+ break;
+
// Do nothing.
case 'all':
break;
+
default:
drush_log(dt('Invalid filter option. Available options are: enabled, disabled, overridden, database, and code.'), 'error');
return;
@@ -983,33 +993,42 @@ class shellColours {
'light_gray' => '47',
);
+ /**
+ * shellColours constructor.
+ */
private function __construct() {}
- // Returns coloured string
+ /**
+ * Returns coloured string.
+ */
public static function getColouredOutput($string, $foreground_colour = NULL, $background_colour = NULL) {
$coloured_string = "";
- // Check if given foreground colour found
+ // Check if given foreground colour found.
if ($foreground_colour) {
$coloured_string .= "\033[" . self::$foreground_colours[$foreground_colour] . "m";
}
- // Check if given background colour found
+ // Check if given background colour found.
if ($background_colour) {
$coloured_string .= "\033[" . self::$background_colours[$background_colour] . "m";
}
- // Add string and end colouring
- $coloured_string .= $string . "\033[0m";
+ // Add string and end colouring.
+ $coloured_string .= $string . "\033[0m";
return $coloured_string;
}
- // Returns all foreground colour names
+ /**
+ * Returns all foreground colour names.
+ */
public static function getForegroundColours() {
return array_keys(self::$foreground_colours);
}
- // Returns all background colour names
+ /**
+ * Returns all background colour names.
+ */
public static function getBackgroundColours() {
return array_keys(self::$background_colours);
}
diff --git a/sites/all/modules/contrib/dev/ctools/help/context-content.html b/sites/all/modules/contrib/dev/ctools/help/context-content.html
index 8af5df4..c1c6a35 100644
--- a/sites/all/modules/contrib/dev/ctools/help/context-content.html
+++ b/sites/all/modules/contrib/dev/ctools/help/context-content.html
@@ -116,6 +116,10 @@ The first form will always have required configuration added to it. These forms
required context [Optional]
Either a ctools_context_required or ctools_context_optional or array of contexts for this content. If omitted, no contexts are used.
+
+
create content access [Optional]
+
+
An optional callback to determine if a user can access this subtype. The callback will receive two arguments, the type and subtype.
Rendered content
diff --git a/sites/all/modules/contrib/dev/ctools/help/export.html b/sites/all/modules/contrib/dev/ctools/help/export.html
index 3a774e8..573c98a 100644
--- a/sites/all/modules/contrib/dev/ctools/help/export.html
+++ b/sites/all/modules/contrib/dev/ctools/help/export.html
@@ -154,8 +154,11 @@ function mymodule_schema() {
Bulk export callback to provide a list of exportable objects to be chosen for bulk exporting. Defaults to $module . '_' . $table . '_list' if the function exists. If it is not, a default listing function will be provided that will make a best effort to list the titles. See ctools_export_default_list().
to hook code callback
-
Function used to generate an export for the bulk export process. This is only necessary if the export is more complicated than simply listing the fields. Defaults to $module . '_' . $table . '_to_hook_code'.
+
Function used to generate an export for the bulk export process. This is only necessary if the export is more complicated than simply listing the fields. Defaults to $module . '_' . $table . '_to_hook_code'.
+
boolean
+
Explicitly indicate if a table field contains a boolean or not. The Schema API does not model the
+difference between a tinyint and a boolean type. Boolean values are stored in tinyint fields. This may cause mismatch errors when exporting a non-boolean value from a tinyint field. Add this to a tinyint field if it contains boolean data and can be exported. Defaults to TRUE.
create callback
CRUD callback to use to create a new exportable item in memory. If not provided, the default function will be used. The single argument is a boolean used to determine if defaults should be set on the object. This object will not be written to the database by this callback.
modalSize: an array of data to control the sizing of the modal. It can contain:
type: Either fixed or scale. If fixed, the modal will always be a fixed size. If scale the modal will scale to a percentage of the browser window. Default: scale.
-
width: If fixed the width in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
+
width: If fixed the width in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
height: If fixed the height in pixels. If scale the percentage of the screen expressed as a number less than zero. (For 80 percent, use .8, for example). Default: .8
addWidth: Any additional width to add to the modal in pixels. Only useful if the type is scale. Default: 0
addHeight: Any additional height to add to the modal in pixels. Only useful if the type is scale. Default: 0
@@ -168,7 +168,7 @@ function ctools_ajax_sample_login($js) {
function ctools_ajax_hello_world($js) {
$title = t('Greetings');
- $output = '<p>' . t('Hello world') . ''</p>';
+ $output = '<p>' . t('Hello world') . '</p>';
if ($js) {
ctools_modal_render($title, $output);
}
diff --git a/sites/all/modules/contrib/dev/ctools/help/plugins-creating.html b/sites/all/modules/contrib/dev/ctools/help/plugins-creating.html
index 29a9014..6d5b35f 100644
--- a/sites/all/modules/contrib/dev/ctools/help/plugins-creating.html
+++ b/sites/all/modules/contrib/dev/ctools/help/plugins-creating.html
@@ -24,6 +24,18 @@ The following information can be specified for each plugin type:
cache table
Defaults to:'cache'
If 'cache' is TRUE, then this value specifies the cache table where the cached plugin information will be stored.
+
classes
+
Defaults to:array()
+
An array of class identifiers(i.e. plugin array keys) which a plugin of this type uses to provide classes to the CTools autoloader. For example, if classes is set to array('class'), then CTools will search each $plugin['class'] for a class to autoload. Depending of the plugin structure, a class identifier may be either:
+
+
- a file name:
+
the file which holds the class with the name structure as: [filename].[class].php
+
in this case the class name can be different than the class identifier
+
- the class name:
+
if the class is in the same file as the $plugin
+
the plugin .inc file can have a different name than the class identifier
+
+
defaults
Defaults to:array()
An array of defaults that should be added to each plugin; this can be used to ensure that every plugin has the basic data necessary. These defaults will not ovewrite data supplied by the plugin. This could also be a function name, in which case the callback will be used to provide defaults. NOTE, however, that the callback-based approach is deprecated as it is redundant with the 'process' callback, and as such will be removed in later versions. Consequently, you should only use the array form for maximum cross-version compatibility.
diff --git a/sites/all/modules/contrib/dev/ctools/includes/action-links.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/action-links.theme.inc
index 3a2398a..f53f59c8 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/action-links.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/action-links.theme.inc
@@ -1,4 +1,5 @@
' . $links . '';
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/ajax.inc b/sites/all/modules/contrib/dev/ctools/includes/ajax.inc
index bb17bea..4d72d0c 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/ajax.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/ajax.inc
@@ -1,6 +1,10 @@
TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt)));
}
+/**
+ * Render an icon and related text as a link. This will automatically apply an AJAX class
+ * to the link and add the appropriate javascript to make this happen.
+ *
+ * Note: 'html' => true so be sure any text is vetted! Chances are these kinds of buttons will
+ * not use user input so this is a very minor concern.
+ *
+ * @param $text
+ * The text that will be displayed as the link.
+ * @param $image
+ * The icon image to include in the link.
+ * @param $dest
+ * The destination of the link.
+ * @param $alt
+ * The title text of the link.
+ * @param $class
+ * Any class to apply to the link. @todo this should be a options array.
+ * @param $type
+ * A type to use, in case a different behavior should be attached. Defaults
+ * to ctools-use-ajax.
+ */
+function ctools_ajax_icon_text_button($text, $image, $dest, $alt, $class = '', $type = 'use-ajax') {
+ drupal_add_library('system', 'drupal.ajax');
+ $rendered_image = theme('image', array('path' => $image));
+ $link_content = $rendered_image . "" . $text . "";
+ return l($link_content, $dest, array('html' => TRUE, 'attributes' => array('class' => array($type, $class), 'title' => $alt)));
+}
+
/**
* Set a single property to a value, on all matched elements.
*
@@ -57,17 +89,17 @@ function ctools_ajax_text_button($text, $dest, $alt, $class = '', $type = 'use-a
* @param $name
* The name or key: of the data attached to this selector.
* @param $value
- * The value of the data.
+ * The value of the data.
*/
function ctools_ajax_command_attr($selector, $name, $value) {
ctools_add_js('ajax-responder');
return array(
- 'command' => 'attr',
- 'selector' => $selector,
- 'name' => $name,
- 'value' => $value,
- );
- }
+ 'command' => 'attr',
+ 'selector' => $selector,
+ 'name' => $name,
+ 'value' => $value,
+ );
+}
/**
* Force a client-side redirect.
@@ -126,4 +158,3 @@ function ctools_ajax_render_error($error = '') {
print ajax_render($commands);
exit;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/cache.inc b/sites/all/modules/contrib/dev/ctools/includes/cache.inc
index 3918683..cace800 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/cache.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/cache.inc
@@ -2,7 +2,6 @@
/**
* @file
- *
* Plugins to handle cache-indirection.
*
* Simple plugin management to allow clients to more tightly control where
@@ -52,7 +51,6 @@
* @param string $mechanism
* A string containing the plugin name, and an optional data element to
* send to the plugin separated by two colons.
- *
* @param string $key
* The key used to identify the cache.
*
@@ -70,7 +68,6 @@ function ctools_cache_get($mechanism, $key) {
* @param string $mechanism
* A string containing the plugin name, and an optional data element to
* send to the plugin separated by two colons.
- *
* @param string $key
* The key used to identify the cache.
*
@@ -88,7 +85,6 @@ function ctools_cache_set($mechanism, $key, $object) {
* @param string $mechanism
* A string containing the plugin name, and an optional data element to
* send to the plugin separated by two colons.
- *
* @param string $key
* The key used to identify the cache.
*/
@@ -108,13 +104,10 @@ function ctools_cache_clear($mechanism, $key) {
* @param string $mechanism
* A string containing the plugin name, and an optional data element to
* send to the plugin separated by two colons.
- *
* @param string $key
* The key used to identify the cache.
- *
* @param string $op
* The operation to call, such as 'break' or 'finalize'.
- *
* @param mixed $object
* The cache data being operated on, in case it is necessary. This is
* optional so no references should be used.
@@ -150,7 +143,7 @@ function ctools_cache_operation($mechanism, $key, $op, $object = NULL) {
*/
function ctools_cache_find_plugin($mechanism) {
if (strpos($mechanism, '::') !== FALSE) {
- // use explode(2) to ensure that the data can contain double
+ // Use explode(2) to ensure that the data can contain double
// colons, just in case.
list($name, $data) = explode('::', $mechanism, 2);
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/cleanstring.inc b/sites/all/modules/contrib/dev/ctools/includes/cleanstring.inc
index 56b3e36..11ffcef 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/cleanstring.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/cleanstring.inc
@@ -1,5 +1,4 @@
$length) {
- $string = drupal_substr($string, 0, $length + 1); // leave one more character
- if ($last_break = strrpos($string, $separator)) { // space exists AND is not on position 0
+ // Leave one more character.
+ $string = drupal_substr($string, 0, $length + 1);
+ // Space exists AND is not on position 0.
+ if ($last_break = strrpos($string, $separator)) {
$string = substr($string, 0, $last_break);
}
else {
diff --git a/sites/all/modules/contrib/dev/ctools/includes/collapsible.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/collapsible.theme.inc
index f7bbbb3..81df4bc 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/collapsible.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/collapsible.theme.inc
@@ -30,8 +30,8 @@ function ctools_collapsible_theme(&$items) {
* Text to put in the handle/title area of the div.
* @param $content
* Text to put in the content area of the div, this is what will get
- * collapsed
- * @param $collapsed = FALSE
+ * collapsed.
+ * @param $collapsed
* If true, this div will start out collapsed.
*/
function theme_ctools_collapsible($vars) {
@@ -56,8 +56,8 @@ function theme_ctools_collapsible($vars) {
* Text to put in the handle/title area of the div.
* @param $content
* Text to put in the content area of the div, this is what will get
- * collapsed
- * @param $collapsed = FALSE
+ * collapsed.
+ * @param $collapsed
* If true, this div will start out collapsed.
*/
function theme_ctools_collapsible_remembered($vars) {
@@ -76,4 +76,3 @@ function theme_ctools_collapsible_remembered($vars) {
return $output;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/content.inc b/sites/all/modules/contrib/dev/ctools/includes/content.inc
index 890ec23..49c3565 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/content.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/content.inc
@@ -86,7 +86,7 @@ function ctools_content_process(&$plugin, $info) {
/**
* Fetch metadata on a specific content_type plugin.
*
- * @param $content type
+ * @param mixed $content
* Name of a panel content type.
*
* @return
@@ -146,7 +146,7 @@ function ctools_content_get_subtypes($type) {
if (is_array($function)) {
$subtypes = $function;
}
- else if (function_exists($function)) {
+ elseif (function_exists($function)) {
// Cast to array to prevent errors from non-array returns.
$subtypes = (array) $function($plugin);
}
@@ -155,6 +155,11 @@ function ctools_content_get_subtypes($type) {
// Walk through the subtypes and ensure minimal settings are
// retained.
foreach ($subtypes as $id => $subtype) {
+ // Ensure that the 'subtype_id' value exists.
+ if (!isset($subtype['subtype_id'])) {
+ $subtypes[$id]['subtype_id'] = $id;
+ }
+
// Use exact name since this is a modify by reference.
ctools_content_prepare_subtype($subtypes[$id], $plugin);
}
@@ -202,6 +207,13 @@ function ctools_content_get_subtype($type, $subtype_id) {
}
if ($subtype) {
+ // Ensure that the 'subtype_id' value exists. This is also done in
+ // ctools_content_get_subtypes(), but it wouldn't be called if the plugin
+ // provides the subtype through its own function.
+ if (!isset($subtype['subtype_id'])) {
+ $subtype['subtype_id'] = $subtype_id;
+ }
+
ctools_content_prepare_subtype($subtype, $plugin);
}
return $subtype;
@@ -217,6 +229,7 @@ function ctools_content_prepare_subtype(&$subtype, $plugin) {
}
}
+ // Trigger hook_ctools_content_subtype_alter().
drupal_alter('ctools_content_subtype', $subtype, $plugin);
}
@@ -241,9 +254,10 @@ function ctools_content_prepare_subtype(&$subtype, $plugin) {
* Any incoming content, if this display is a wrapper.
*
* @return
- * The content as rendered by the plugin. This content should be an array
- * with the following possible keys:
+ * The content as rendered by the plugin, or NULL.
+ * This content should be an object with the following possible properties:
* - title: The safe to render title of the content.
+ * - title_heading: The title heading.
* - content: The safe to render HTML content.
* - links: An array of links associated with the content suitable for
* theme('links').
@@ -293,21 +307,22 @@ function ctools_content_render($type, $subtype, $conf, $keywords = array(), $arg
$content->subtype = $subtype;
}
- // Override the title if configured to
+ // Override the title if configured to.
if (!empty($conf['override_title'])) {
// Give previous title as an available substitution here.
$keywords['%title'] = empty($content->title) ? '' : $content->title;
$content->original_title = $keywords['%title'];
$content->title = $conf['override_title_text'];
+ $content->title_heading = isset($conf['override_title_heading']) ? $conf['override_title_heading'] : 'h2';
}
if (!empty($content->title)) {
- // Perform substitutions
+ // Perform substitutions.
if (!empty($keywords) || !empty($context)) {
$content->title = ctools_context_keyword_substitute($content->title, $keywords, $context);
}
- // Sterilize the title
+ // Sterilize the title.
$content->title = filter_xss_admin($content->title);
// If a link is specified, populate.
@@ -318,7 +333,7 @@ function ctools_content_render($type, $subtype, $conf, $keywords = array(), $arg
else {
$url = $content->title_link;
}
- // set defaults so we don't bring up notices
+ // Set defaults so we don't bring up notices.
$url += array('href' => '', 'attributes' => array(), 'query' => array(), 'fragment' => '', 'absolute' => NULL, 'html' => TRUE);
$content->title = l($content->title, $url['href'], $url);
}
@@ -339,7 +354,16 @@ function ctools_content_editable($type, $subtype, $conf) {
return FALSE;
}
- if ($function = ctools_plugin_get_function($subtype, 'check editable')) {
+ $function = FALSE;
+
+ if (!empty($subtype['check editable'])) {
+ $function = ctools_plugin_get_function($subtype, 'check editable');
+ }
+ elseif (!empty($type['check editable'])) {
+ $function = ctools_plugin_get_function($type, 'check editable');
+ }
+
+ if ($function) {
return $function($type, $subtype, $conf);
}
@@ -362,7 +386,7 @@ function ctools_content_admin_title($type, $subtype, $conf, $context = NULL) {
if (is_array($type)) {
$plugin = $type;
}
- else if (is_string($type)) {
+ elseif (is_string($type)) {
$plugin = ctools_get_content_type($type);
}
else {
@@ -380,10 +404,10 @@ function ctools_content_admin_title($type, $subtype, $conf, $context = NULL) {
return $function($subtype, $conf, $pane_context);
}
- else if (isset($plugin['admin title'])) {
+ elseif (isset($plugin['admin title'])) {
return $plugin['admin title'];
}
- else if (isset($plugin['title'])) {
+ elseif (isset($plugin['title'])) {
return $plugin['title'];
}
}
@@ -418,7 +442,7 @@ function ctools_content_get_defaults($plugin, $subtype) {
if (isset($plugin['defaults'])) {
$defaults = $plugin['defaults'];
}
- else if (isset($subtype['defaults'])) {
+ elseif (isset($subtype['defaults'])) {
$defaults = $subtype['defaults'];
}
if (isset($defaults)) {
@@ -427,7 +451,7 @@ function ctools_content_get_defaults($plugin, $subtype) {
return $return;
}
}
- else if (is_array($defaults)) {
+ elseif (is_array($defaults)) {
return $defaults;
}
}
@@ -461,7 +485,7 @@ function ctools_content_admin_info($type, $subtype, $conf, $context = NULL) {
if (empty($output) || !is_object($output)) {
$output = new stdClass();
- // replace the _ with " " for a better output
+ // Replace the _ with " " for a better output.
$subtype = check_plain(str_replace("_", " ", $subtype));
$output->title = $subtype;
$output->content = t('No info available.');
@@ -470,7 +494,7 @@ function ctools_content_admin_info($type, $subtype, $conf, $context = NULL) {
}
/**
- * Add the default FAPI elements to the content type configuration form
+ * Add the default FAPI elements to the content type configuration form.
*/
function ctools_content_configure_form_defaults($form, &$form_state) {
$plugin = $form_state['plugin'];
@@ -504,8 +528,26 @@ function ctools_content_configure_form_defaults($form, &$form_state) {
'#size' => 35,
'#id' => 'override-title-textfield',
'#dependency' => array('override-title-checkbox' => array(1)),
- '#dependency_type' => 'disable',
+ '#dependency_type' => 'hidden',
);
+ $form['override_title_heading'] = array(
+ '#type' => 'select',
+ '#default_value' => isset($conf['override_title_heading']) ? $conf['override_title_heading'] : 'h2',
+ '#options' => array(
+ 'h1' => t('h1'),
+ 'h2' => t('h2'),
+ 'h3' => t('h3'),
+ 'h4' => t('h4'),
+ 'h5' => t('h5'),
+ 'h6' => t('h6'),
+ 'div' => t('div'),
+ 'span' => t('span'),
+ ),
+ '#id' => 'override-title-heading',
+ '#dependency' => array('override-title-checkbox' => array(1)),
+ '#dependency_type' => 'hidden',
+ );
+
$form['aligner_stop'] = array(
'#markup' => '
',
);
@@ -536,6 +578,7 @@ function ctools_content_configure_form_defaults_submit(&$form, &$form_state) {
if (isset($form_state['values']['override_title'])) {
$form_state['conf']['override_title'] = $form_state['values']['override_title'];
$form_state['conf']['override_title_text'] = $form_state['values']['override_title_text'];
+ $form_state['conf']['override_title_heading'] = $form_state['values']['override_title_heading'];
}
}
@@ -568,7 +611,7 @@ function ctools_content_form($op, $form_info, &$form_state, $plugin, $subtype_na
if (!empty($subtype['add form'])) {
_ctools_content_create_form_info($form_info, $subtype['add form'], $subtype, $subtype, $op);
}
- else if (!empty($plugin['add form'])) {
+ elseif (!empty($plugin['add form'])) {
_ctools_content_create_form_info($form_info, $plugin['add form'], $plugin, $subtype, $op);
}
}
@@ -578,7 +621,7 @@ function ctools_content_form($op, $form_info, &$form_state, $plugin, $subtype_na
if (!empty($subtype['edit form'])) {
_ctools_content_create_form_info($form_info, $subtype['edit form'], $subtype, $subtype, $op);
}
- else if (!empty($plugin['edit form'])) {
+ elseif (!empty($plugin['edit form'])) {
_ctools_content_create_form_info($form_info, $plugin['edit form'], $plugin, $subtype, $op);
}
}
@@ -597,7 +640,7 @@ function _ctools_content_create_form_info(&$form_info, $info, $plugin, $subtype,
if (empty($subtype['title'])) {
$title = t('Configure');
}
- else if ($op == 'add') {
+ elseif ($op == 'add') {
$title = t('Configure new !subtype_title', array('!subtype_title' => $subtype['title']));
}
else {
@@ -612,7 +655,7 @@ function _ctools_content_create_form_info(&$form_info, $info, $plugin, $subtype,
),
);
}
- else if (is_array($info)) {
+ elseif (is_array($info)) {
$form_info['order'] = array();
$form_info['forms'] = array();
$count = 0;
@@ -663,7 +706,7 @@ function ctools_content_get_available_types($contexts = NULL, $has_content = FAL
foreach ($plugins as $id => $plugin) {
foreach (ctools_content_get_subtypes($plugin) as $subtype_id => $subtype) {
- // exclude items that require content if we're saying we don't
+ // Exclude items that require content if we're saying we don't
// provide it.
if (!empty($subtype['requires content']) && !$has_content) {
continue;
@@ -687,6 +730,11 @@ function ctools_content_get_available_types($contexts = NULL, $has_content = FAL
}
}
+ // Check if the content type provides an access callback.
+ if (isset($subtype['create content access']) && function_exists($subtype['create content access']) && !$subtype['create content access']($plugin, $subtype)) {
+ continue;
+ }
+
// If we made it through all the tests, then we can use this content.
$available[$id][$subtype_id] = $subtype;
}
@@ -698,7 +746,6 @@ function ctools_content_get_available_types($contexts = NULL, $has_content = FAL
* Get an array of all content types that can be fed into the
* display editor for the add content list, regardless of
* availability.
- *
*/
function ctools_content_get_all_types() {
$plugins = ctools_get_content_types();
diff --git a/sites/all/modules/contrib/dev/ctools/includes/content.menu.inc b/sites/all/modules/contrib/dev/ctools/includes/content.menu.inc
index 93884fc..64d44b0 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/content.menu.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/content.menu.inc
@@ -23,68 +23,156 @@ function ctools_content_menu(&$items) {
/**
* Helper function for autocompletion of entity titles.
*/
-function ctools_content_autocomplete_entity($type, $string = '') {
- $entity = entity_get_info($type);
+function ctools_content_autocomplete_entity($entity_type, $string = '') {
if ($string != '') {
- // @todo verify the query logic here, it's untested.
- // Set up the query
- $query = db_select($entity['base table'], 'b');
- if ($entity['entity keys']['label']) {
- $query->fields('b', array($entity['entity keys']['id'], $entity['entity keys']['label']))->range(0, 10);
- }
- else {
- $query->fields('b', array($entity['entity keys']['id']))->range(0, 10);
+ $entity_info = entity_get_info($entity_type);
+
+ if (!module_exists('entity')) {
+ module_load_include('inc', 'ctools', 'includes/entity-access');
+ _ctools_entity_access($entity_info, $entity_type);
}
+ // We must query all ids, because if every one of the 10 don't have access
+ // the user may never be able to autocomplete a node title.
$preg_matches = array();
+ $matches = array();
$match = preg_match('/\[id: (\d+)\]/', $string, $preg_matches);
if (!$match) {
$match = preg_match('/^id: (\d+)/', $string, $preg_matches);
}
+ // If an ID match was found, use that ID rather than the whole string.
if ($match) {
- $query->condition('b.' . $entity['entity keys']['id'], $preg_matches[1]);
- }
- elseif ($entity['entity keys']['label']) {
- $query->condition('b.' . $entity['entity keys']['label'], '%' . db_like($string) . '%', 'LIKE');
- }
-
- $matches = array();
- if ($type == 'node') {
- if (!user_access('bypass node access')) {
- // If the user is able to view their own unpublished nodes, allow them
- // to see these in addition to published nodes.
- if (user_access('view own unpublished content')) {
- $query->condition(db_or()
- ->condition('b.status', NODE_PUBLISHED)
- ->condition('b.uid', $GLOBALS['user']->uid)
- );
- }
- else {
- // If not, restrict the query to published nodes.
- $query->condition('b.status', NODE_PUBLISHED);
- }
- }
-
- $query->addTag('node_access');
- $query->join('users', 'u', 'b.uid = u.uid');
- $query->addField('u', 'name', 'name');
-
- foreach ($query->execute() as $nodeish) {
- $name = empty($nodeish->name) ? variable_get('anonymous', t('Anonymous')) : check_plain($nodeish->name);
- $matches[$nodeish->title . " [id: $nodeish->nid]"] = '' . check_plain($nodeish->title) . '(' . t('by @user', array('@user' => $name)) . ')';
- }
+ $entity_id = $preg_matches[1];
+ $results = _ctools_getReferencableEntities($entity_type, $entity_info, $entity_id, '=', 1);
}
else {
- foreach ($query->execute() as $item) {
- $id = $item->{$entity['entity keys']['id']};
- if ($entity['entity keys']['label']) {
- $matches[$item->{$entity['entity keys']['label']} . " [id: $id]"] = '' . check_plain($item->{$entity['entity keys']['label']}) . '';
- }
- else {
- $matches["[id: $id]"] = '' . check_plain($item->{$entity['entity keys']['id']}) . '';
- }
+ // We cannot find results if the entity doesn't have a label to search.
+ if (!isset($entity_info['entity keys']['label'])) {
+ drupal_json_output(array("[id: NULL]" => '' . t('Entity Type !entity_type does not support autocomplete search.', array('!entity_type' => $entity_type)) . ''));
+ return;
}
+ $results = _ctools_getReferencableEntities($entity_type, $entity_info, $string, 'LIKE', 10);
}
+ foreach ($results as $entity_id => $result) {
+ $matches[$result['label'] . " [id: $entity_id]"] = '' . check_plain($result['label']) . '';
+ $matches[$result['label'] . " [id: $entity_id]"] .= isset($result['bundle']) ? ' (' . check_plain($result['bundle']) . ')' : '';
+ }
+
drupal_json_output($matches);
}
}
+
+/**
+ * Use EntityReference_SelectionHandler_Generic class to build our search query.
+ */
+function _ctools_buildQuery($entity_type, $entity_info, $match = NULL, $match_operator = 'CONTAINS') {
+ $base_table = $entity_info['base table'];
+ $label_key = $entity_info['entity keys']['label'];
+ $query = db_select($base_table)
+ ->fields($base_table, array($entity_info['entity keys']['id']));
+
+ if (isset($match)) {
+ if (isset($label_key)) {
+ $query->condition($base_table . '.' . $label_key, '%' . $match . '%', $match_operator);
+ }
+ // This should never happen, but double check just in case.
+ else {
+ return array();
+ }
+ }
+ // Add a generic entity access tag to the query.
+ $query->addTag('ctools');
+
+ // We have to perform two checks. First check is a query alter (with tags)
+ // in an attempt to only return results that have access. However, this is
+ // not full-proof since entities many not implement hook_access query tag.
+ // This is why we have a second check after entity load, before we display
+ // the label of an entity.
+ if ($entity_type == 'comment') {
+ // Adding the 'comment_access' tag is sadly insufficient for comments: core
+ // requires us to also know about the concept of 'published' and
+ // 'unpublished'.
+ if (!user_access('administer comments')) {
+ $query->condition('comment.status', COMMENT_PUBLISHED);
+ }
+
+ // Join to a node if the user does not have node access bypass permissions
+ // to obey node published permissions.
+ if (!user_access('bypass node access')) {
+ $node_alias = $query->innerJoin('node', 'n', '%alias.nid = comment.nid');
+ $query->condition($node_alias . '.status', NODE_PUBLISHED);
+ }
+ $query->addTag('node_access');
+ }
+ else {
+ $query->addTag($entity_type . '_access');
+ }
+
+ // Add the sort option.
+ if (isset($label_key)) {
+ $query->orderBy($base_table . '.' . $label_key, 'ASC');
+ }
+
+ return $query;
+}
+
+/**
+ * Private function to get referencable entities. Based on code from the
+ * Entity Reference module.
+ */
+function _ctools_getReferencableEntities($entity_type, $entity_info, $match = NULL, $match_operator = 'LIKE', $limit = 0) {
+ global $user;
+ $account = $user;
+ $options = array();
+ // We're an entity ID, return the id.
+ if (is_numeric($match) && $match_operator == '=') {
+ if ($entity = array_shift(entity_load($entity_type, array($match)))) {
+ if (isset($entity_info['access callback']) && function_exists($entity_info['access callback'])) {
+ if ($entity_info['access callback']('view', $entity, $account, $entity_type)) {
+ $label = entity_label($entity_type, $entity);
+ return array(
+ $match => array(
+ 'label' => !empty($label) ? $label : $entity->{$entity_info['entity keys']['id']},
+ 'bundle' => !empty($entity_info['entity keys']['bundle']) ? check_plain($entity->{$entity_info['entity keys']['bundle']}) : NULL,
+ ),
+ );
+ }
+ }
+ }
+ // If you don't have access, or an access callback or a valid entity, just
+ // Return back the Entity ID.
+ return array(
+ $match => array(
+ 'label' => $match,
+ 'bundle' => NULL,
+ ),
+ );
+ }
+
+ // We have matches, build a query to fetch the result.
+ if ($query = _ctools_buildQuery($entity_type, $entity_info, $match, $match_operator)) {
+ if ($limit > 0) {
+ $query->range(0, $limit);
+ }
+
+ $results = $query->execute();
+
+ if (!empty($results)) {
+ foreach ($results as $record) {
+ $entities = entity_load($entity_type, array($record->{$entity_info['entity keys']['id']}));
+ $entity = array_shift($entities);
+ if (isset($entity_info['access callback']) && function_exists($entity_info['access callback'])) {
+ if ($entity_info['access callback']('view', $entity, $account, $entity_type)) {
+ $label = entity_label($entity_type, $entity);
+ $options[$record->{$entity_info['entity keys']['id']}] = array(
+ 'label' => !empty($label) ? $label : $entity->{$entity_info['entity keys']['id']},
+ 'bundle' => !empty($entity_info['entity keys']['bundle']) ? check_plain($entity->{$entity_info['entity keys']['bundle']}) : NULL,
+ );
+ }
+ }
+ }
+ }
+ return $options;
+ }
+ return array();
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/content.plugin-type.inc b/sites/all/modules/contrib/dev/ctools/includes/content.plugin-type.inc
index a0debc3..0364a92 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/content.plugin-type.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/content.plugin-type.inc
@@ -14,4 +14,4 @@ function ctools_content_plugin_type(&$items) {
'path' => drupal_get_path('module', 'ctools') . '/includes',
),
);
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context-access-admin.inc b/sites/all/modules/contrib/dev/ctools/includes/context-access-admin.inc
index 76643cf..d8c4f3b 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context-access-admin.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context-access-admin.inc
@@ -245,10 +245,10 @@ function ctools_access_admin_form_submit($form, &$form_state) {
// --------------------------------------------------------------------------
// AJAX menu entry points.
-
/**
* AJAX callback to add a new access test to the list.
*/
+
function ctools_access_ajax_add($fragment = NULL, $name = NULL) {
ctools_include('ajax');
ctools_include('modal');
@@ -263,7 +263,7 @@ function ctools_access_ajax_add($fragment = NULL, $name = NULL) {
ctools_ajax_render_error();
}
- // Separate the fragment into 'module' and 'argument'
+ // Separate the fragment into 'module' and 'argument'.
if (strpos($fragment, '-') === FALSE) {
$module = $fragment;
$argument = NULL;
@@ -279,7 +279,7 @@ function ctools_access_ajax_add($fragment = NULL, $name = NULL) {
list($access, $contexts) = $function($argument);
- // Make sure we have the logged in user context
+ // Make sure we have the logged in user context.
if (!isset($contexts['logged-in-user'])) {
$contexts['logged-in-user'] = ctools_access_get_loggedin_context();
}
@@ -306,6 +306,9 @@ function ctools_access_ajax_add($fragment = NULL, $name = NULL) {
);
$output = ctools_modal_form_wrapper('ctools_access_ajax_edit_item', $form_state);
+ $access = $form_state['access'];
+ $access['plugins'][$id] = $form_state['test'];
+
if (!isset($output[0])) {
$function = $module . '_ctools_access_set';
if (function_exists($function)) {
@@ -333,7 +336,7 @@ function ctools_access_ajax_edit($fragment = NULL, $id = NULL) {
ctools_ajax_render_error();
}
- // Separate the fragment into 'module' and 'argument'
+ // Separate the fragment into 'module' and 'argument'.
if (strpos($fragment, '-') === FALSE) {
$module = $fragment;
$argument = NULL;
@@ -353,7 +356,7 @@ function ctools_access_ajax_edit($fragment = NULL, $id = NULL) {
ctools_ajax_render_error();
}
- // Make sure we have the logged in user context
+ // Make sure we have the logged in user context.
if (!isset($contexts['logged-in-user'])) {
$contexts['logged-in-user'] = ctools_access_get_loggedin_context();
}
@@ -367,12 +370,14 @@ function ctools_access_ajax_edit($fragment = NULL, $id = NULL) {
'contexts' => $contexts,
'title' => t('Edit criteria'),
'ajax' => TRUE,
- 'ajax' => TRUE,
'modal' => TRUE,
'modal return' => TRUE,
);
$output = ctools_modal_form_wrapper('ctools_access_ajax_edit_item', $form_state);
+ $access = $form_state['access'];
+ $access['plugins'][$id] = $form_state['test'];
+
if (!isset($output[0])) {
$function = $module . '_ctools_access_set';
if (function_exists($function)) {
@@ -452,7 +457,7 @@ function ctools_access_ajax_delete($fragment = NULL, $id = NULL) {
ajax_render_error();
}
- // Separate the fragment into 'module' and 'argument'
+ // Separate the fragment into 'module' and 'argument'.
if (strpos($fragment, '-') === FALSE) {
$module = $fragment;
$argument = NULL;
@@ -472,7 +477,7 @@ function ctools_access_ajax_delete($fragment = NULL, $id = NULL) {
unset($access['plugins'][$id]);
}
- // re-cache
+ // re-cache.
$function = $module . '_ctools_access_set';
if (function_exists($function)) {
$function($argument, $access);
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context-admin.inc b/sites/all/modules/contrib/dev/ctools/includes/context-admin.inc
index 7e5cd02..533c89f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context-admin.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context-admin.inc
@@ -376,11 +376,11 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
'path' => "ctools/context/ajax/add/$mechanism/$type/$cache_key/$name/%step",
'show cancel' => TRUE,
'default form' => 'ctools_edit_context_form_defaults',
- 'auto caching' => TRUE,
+ 'auto cache' => TRUE,
'cache mechanism' => $mechanism,
'cache key' => $cache_key,
// This is stating what the cache will be referred to in $form_state
- 'cache storage' => 'object',
+ 'cache location' => 'object',
);
if ($type == 'requiredcontext') {
@@ -395,7 +395,7 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
if (!empty($form_state['cancel'])) {
$output = array(ctools_modal_command_dismiss());
}
- else if (!empty($form_state['complete'])) {
+ elseif (!empty($form_state['complete'])) {
// Successful submit -- move temporary data to location.
// Create a reference to the place our context lives. Since this is fairly
@@ -416,12 +416,20 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
ctools_cache_operation($mechanism, $cache_key, 'finalize', $object);
// Very irritating way to update the form for our contexts.
- $arg_form_state = array('values' => array());
+ $arg_form_state = form_state_defaults() + array(
+ 'values' => array(),
+ 'process_input' => FALSE,
+ 'complete form' => array(),
+ );
+
+ $rel_form_state = $arg_form_state;
$arg_form = array(
'#post' => array(),
'#programmed' => FALSE,
'#tree' => FALSE,
+ '#parents' => array(),
+ '#array_parents' => array(),
);
// Build a chunk of the form to merge into the displayed form
@@ -446,6 +454,8 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
'#post' => array(),
'#programmed' => FALSE,
'#tree' => FALSE,
+ '#parents' => array(),
+ '#array_parents' => array(),
);
$rel_form['relationship'] = array(
@@ -460,7 +470,7 @@ function ctools_context_ajax_item_add($mechanism = NULL, $type = NULL, $cache_ke
$output = array();
if (!empty($available_relationships)) {
ctools_context_add_item_table_buttons('relationship', $mechanism, $rel_form, $available_relationships);
- $rel_form = form_builder('dummy_form_id', $rel_form, $arg_form_state);
+ $rel_form = form_builder('dummy_form_id', $rel_form, $rel_form_state);
$output[] = ajax_command_replace('div#ctools-relationships-table div.buttons', drupal_render($rel_form));
}
@@ -551,11 +561,11 @@ function ctools_context_ajax_item_edit($mechanism = NULL, $type = NULL, $cache_k
'path' => "ctools/context/ajax/configure/$mechanism/$type/$cache_key/$position/%step",
'show cancel' => TRUE,
'default form' => 'ctools_edit_context_form_defaults',
- 'auto caching' => TRUE,
+ 'auto cache' => TRUE,
'cache mechanism' => $mechanism,
'cache key' => $cache_key,
// This is stating what the cache will be referred to in $form_state
- 'cache storage' => 'object',
+ 'cache location' => 'object',
);
if ($type == 'requiredcontext') {
@@ -570,7 +580,7 @@ function ctools_context_ajax_item_edit($mechanism = NULL, $type = NULL, $cache_k
if (!empty($form_state['cancel'])) {
$output = array(ctools_modal_command_dismiss());
}
- else if (!empty($form_state['complete'])) {
+ elseif (!empty($form_state['complete'])) {
// successful submit
$ref[$position] = $conf;
if (isset($object->temporary)) {
@@ -582,8 +592,16 @@ function ctools_context_ajax_item_edit($mechanism = NULL, $type = NULL, $cache_k
$output = array();
$output[] = ctools_modal_command_dismiss();
+ $arg_form_state = form_state_defaults() + array(
+ 'values' => array(),
+ 'process_input' => FALSE,
+ 'complete form' => array(),
+ );
+
$arg_form = array(
'#post' => array(),
+ '#parents' => array(),
+ '#array_parents' => array(),
'#programmed' => FALSE,
'#tree' => FALSE,
);
@@ -639,7 +657,7 @@ function ctools_context_get_defaults($plugin_definition, $object, $type) {
if (isset($plugin_definition['defaults'])) {
$defaults = $plugin_definition['defaults'];
}
- else if (isset($subtype['defaults'])) {
+ elseif (isset($subtype['defaults'])) {
$defaults = $subtype['defaults'];
}
@@ -649,7 +667,7 @@ function ctools_context_get_defaults($plugin_definition, $object, $type) {
$conf += $settings;
}
}
- else if (is_array($defaults)) {
+ elseif (is_array($defaults)) {
$conf += $defaults;
}
}
@@ -718,6 +736,15 @@ function ctools_edit_context_form_defaults($form, &$form_state) {
'#default_value' => $conf['keyword'],
);
+ if ($type_info['key'] == 'requiredcontexts') {
+ $form['optional'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Context is optional'),
+ '#default_value' => !empty($form_state['conf']['optional']),
+ '#description' => t('This context need not be present for the component to function.'),
+ );
+ }
+
$form['#submit'][] = 'ctools_edit_context_form_defaults_submit';
return $form;
@@ -734,6 +761,9 @@ function ctools_edit_context_form_defaults_submit(&$form, &$form_state) {
$form_state['conf']['default'] = $form_state['values']['default'];
$form_state['conf']['title'] = $form_state['values']['title'];
}
+ if ($form_state['type info']['key'] == 'requiredcontexts') {
+ $form_state['conf']['optional'] = $form_state['values']['optional'];
+ }
$form_state['conf']['identifier'] = $form_state['values']['identifier'];
$form_state['conf']['keyword'] = $form_state['values']['keyword'];
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context-task-handler.inc b/sites/all/modules/contrib/dev/ctools/includes/context-task-handler.inc
index 37aa6df..ed4acad 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context-task-handler.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context-task-handler.inc
@@ -4,9 +4,9 @@
* @file
* Support for creating 'context' type task handlers.
*
- * Context task handlers expect the task to provide 0 or more contexts. The
- * task handler should use those contexts as selection rules, as well as
- * rendering with them.
+ * Context task handlers expect the task to provide 0 or more contexts. The task
+ * handler should use those contexts as selection rules, as well as rendering
+ * with them.
*
* The functions and forms in this file should be common to every context type
* task handler made.
@@ -31,6 +31,7 @@
* If TRUE then this renderer owns the page and can use theme('page')
* for no blocks; if false, output is returned regardless of any no
* blocks settings.
+ *
* @return
* Either the output or NULL if there was output, FALSE if no handler
* accepted the task. If $page is FALSE then the $info block is returned instead.
@@ -84,7 +85,7 @@ function ctools_context_handler_get_render_handler($task, $subtask, $handlers, $
*/
function ctools_context_handler_default_test($handler, $base_contexts, $args) {
ctools_include('context');
- // Add my contexts
+ // Add my contexts.
$contexts = ctools_context_handler_get_handler_contexts($base_contexts, $handler);
// Test.
@@ -128,7 +129,7 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte
'contexts' => $contexts,
'task' => $task,
'subtask' => $subtask,
- 'handler' => $handler
+ 'handler' => $handler,
);
drupal_alter('ctools_render', $info, $page, $context);
@@ -141,12 +142,15 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte
switch ($info['response code']) {
case 403:
return MENU_ACCESS_DENIED;
+
case 404:
return MENU_NOT_FOUND;
+
case 410:
drupal_add_http_header('Status', '410 Gone');
drupal_exit();
break;
+
case 301:
case 302:
case 303:
@@ -161,8 +165,8 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte
'query' => $info['query'],
'fragment' => $info['fragment'],
);
- return drupal_goto($info['destination'], $options, $info['response code']);
- // @todo -- should other response codes be supported here?
+ drupal_goto($info['destination'], $options, $info['response code']);
+ // @todo -- should other response codes be supported here?
}
}
@@ -222,7 +226,7 @@ function ctools_context_handler_render_handler($task, $subtask, $handler, $conte
}
/**
- * Default function to provide contextual link for a task as defined by the handler.
+ * Provides contextual link for a task as defined by the handler.
*
* This provides a simple link to th main content operation and is suitable
* for most normal handlers. Setting 'contextual link' to a function overrides
@@ -241,7 +245,7 @@ function ctools_task_handler_default_contextual_link($handler, $plugin, $context
if (is_array($plugin['tab operation'])) {
$trail = $plugin['tab operation'];
}
- else if (function_exists($plugin['tab operation'])) {
+ elseif (function_exists($plugin['tab operation'])) {
$trail = $plugin['tab operation']($handler, $contexts, $args);
}
}
@@ -251,7 +255,8 @@ function ctools_task_handler_default_contextual_link($handler, $plugin, $context
'href' => $path,
'title' => $title,
'query' => drupal_get_destination(),
- ));
+ ),
+ );
return $links;
}
@@ -259,17 +264,22 @@ function ctools_task_handler_default_contextual_link($handler, $plugin, $context
/**
* Called to execute actions that should happen before a handler is rendered.
*/
-function ctools_context_handler_pre_render($handler, $contexts, $args) { }
+function ctools_context_handler_pre_render($handler, $contexts, $args) {
+ foreach (module_implements('ctools_context_handler_pre_render') as $module) {
+ $function = $module . '_ctools_context_handler_pre_render';
+ $function($handler, $contexts, $args);
+ }
+}
/**
* Compare arguments to contexts for selection purposes.
*
- * @param $handler
+ * @param object $handler
* The handler in question.
- * @param $contexts
+ * @param object $contexts
* The context objects provided by the task.
*
- * @return
+ * @return bool
* TRUE if these contexts match the selection rules. NULL or FALSE
* otherwise.
*/
@@ -288,12 +298,15 @@ function ctools_context_handler_select($handler, $contexts) {
* These summary strings are used to communicate to the user what
* arguments the task handlers are selecting.
*
- * @param $task
+ * @param object $task
* The loaded task plugin.
- * @param $subtask
+ * @param object $subtask
* The subtask id.
- * @param $handler
+ * @param object $handler
* The handler to be checked.
+ *
+ * @return array
+ * Returns array of summary strings for arguments selected by task handlers.
*/
function ctools_context_handler_summary($task, $subtask, $handler) {
if (empty($handler->conf['access']['plugins'])) {
@@ -320,7 +333,6 @@ function ctools_context_handler_summary($task, $subtask, $handler) {
// the task handler, for example) but sometimes we need them separately
// (when a task has contexts loaded and is trying out the task handlers,
// for example). Therefore there are two paths we can take to getting contexts.
-
/**
* Load the contexts for a task, using arguments.
*
@@ -368,7 +380,7 @@ function ctools_context_handler_get_all_contexts($task, $subtask, $handler) {
* expects things in a certain, kind of clunky format.
*/
function ctools_context_handler_get_handler_object($handler) {
- $object = new stdClass;
+ $object = new stdClass();
$object->name = $handler->name;
$object->contexts = isset($handler->conf['contexts']) ? $handler->conf['contexts'] : array();
$object->relationships = isset($handler->conf['relationships']) ? $handler->conf['relationships'] : array();
@@ -382,7 +394,7 @@ function ctools_context_handler_get_handler_object($handler) {
* arguments from the task.
*/
function ctools_context_handler_get_task_object($task, $subtask, $handler) {
- $object = new stdClass;
+ $object = new stdClass();
$object->name = !empty($handler->name) ? $handler->name : 'temp';
$object->base_contexts = ctools_context_handler_get_base_contexts($task, $subtask, TRUE);
$object->arguments = ctools_context_handler_get_task_arguments($task, $subtask);
@@ -456,7 +468,7 @@ function ctools_context_handler_edit_criteria($form, &$form_state) {
ctools_modal_add_plugin_js(ctools_get_access_plugins());
ctools_include('context-access-admin');
$form_state['module'] = (isset($form_state['module'])) ? $form_state['module'] : 'page_manager_task_handler';
- // Encode a bunch of info into the argument so we can get our cache later
+ // Encode a bunch of info into the argument so we can get our cache later.
$form_state['callback argument'] = $form_state['task_name'] . '*' . $form_state['handler']->name;
$form_state['access'] = $form_state['handler']->conf['access'];
$form_state['no buttons'] = TRUE;
@@ -472,7 +484,7 @@ function ctools_context_handler_edit_criteria($form, &$form_state) {
}
/**
- * Submit handler for rules selection
+ * Submit handler for rules selection.
*/
function ctools_context_handler_edit_criteria_submit(&$form, &$form_state) {
$form_state['handler']->conf['access']['logic'] = $form_state['values']['logic'];
@@ -537,4 +549,3 @@ function ctools_context_handler_edit_context_submit(&$form, &$form_state) {
unset($form_state['page']->context_cache[$cache_name]);
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context.inc b/sites/all/modules/contrib/dev/ctools/includes/context.inc
index 93be748..0fc6208 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context.inc
@@ -2,7 +2,6 @@
/**
* @file
- *
* Contains code related to the ctools system of 'context'.
*
* Context, originally from Panels, is a method of packaging objects into
@@ -28,28 +27,104 @@
* of the context is important.
*/
class ctools_context {
- var $type = NULL;
- var $data = NULL;
- // The title of this object.
- var $title = '';
- // The title of the page if this object exists
- var $page_title = '';
- // The identifier (in the UI) of this object
- var $identifier = '';
- var $argument = NULL;
- var $keyword = '';
- var $original_argument = NULL;
- var $restrictions = array();
- var $empty = FALSE;
+ /**
+ * @var string|array
+ * A string naming this specific context type. The values 'any' and 'none'
+ * are special:
+ * - 'any': used in is_type() to match any other type.
+ * - 'none': used to signal the type is not defined.
+ */
+ public $type;
- function ctools_context($type = 'none', $data = NULL) {
- $this->type = $type;
- $this->data = $data;
+ /**
+ * @var mixed
+ * The data payload for this context object.
+ */
+ public $data;
+
+ /**
+ * @var string
+ * The title of this object.
+ */
+ public $title;
+
+ /**
+ * @var string
+ * The title of the page if this object exists
+ */
+ public $page_title;
+
+ /**
+ * @var string
+ * The identifier (in the UI) of this object.
+ */
+ public $identifier;
+
+ /**
+ * @var
+ */
+ public $argument;
+
+ /**
+ * @var string
+ */
+ public $keyword;
+
+ /**
+ * @var
+ */
+ public $original_argument;
+
+ /**
+ * @var array
+ */
+ public $restrictions;
+
+ /**
+ * @var bool
+ */
+ public $empty;
+
+ /**
+ * The ctools_context constructor.
+ *
+ * @param string $type
+ * The type name of this context. Should be unique. Use the machine_name
+ * conventions: lowercase, short, underscores and no spaces.
+ * @param mixed $data
+ * The data payload, if required for this context.
+ */
+ public function __construct($type = 'none', $data = NULL) {
+ $this->type = $type;
+ $this->data = $data;
$this->title = t('Unknown context');
+ $this->page_title = '';
+ $this->identifier = '';
+ $this->keyword = '';
+ $this->restrictions = array();
+ $this->empty = FALSE;
+ // Other vars are NULL.
}
- function is_type($type) {
- if ($type == 'any' || $this->type == 'any') {
+ /**
+ * Determine whether this object is of type @var $type .
+ *
+ * Both the internal value ($this->type) and the supplied value ($type) can
+ * be a string or an array of strings, and if one or both are arrays the match
+ * succeeds if at least one common element is found.
+ *
+ * Type names
+ *
+ * @param string|array $type
+ * 'type' can be:
+ * - 'any' to match all types (this is true of the internal value too).
+ * - an array of type name strings, when more than one type is acceptable.
+ *
+ * @return bool
+ * True if the type matches, False otherwise.
+ */
+ public function is_type($type) {
+ if ($type === 'any' || $this->type === 'any') {
return TRUE;
}
@@ -58,32 +133,71 @@ class ctools_context {
return (bool) array_intersect($a, $b);
}
- function get_argument() {
+ /**
+ * Return the argument.
+ *
+ * @return mixed
+ * The value of $argument.
+ */
+ public function get_argument() {
return $this->argument;
}
- function get_original_argument() {
+ /**
+ * Return the value of argument (or arg) variable as it was passed in.
+ *
+ * For example see ctools_plugin_load_function() and ctools_terms_context().
+ *
+ * @return mixed
+ * The original arg value.
+ */
+ public function get_original_argument() {
if (!is_null($this->original_argument)) {
return $this->original_argument;
}
return $this->argument;
}
- function get_keyword() {
+ /**
+ * Return the keyword.
+ *
+ * @return mixed
+ * The value of $keyword.
+ */
+ public function get_keyword() {
return $this->keyword;
}
- function get_identifier() {
+ /**
+ * Return the identifier.
+ *
+ * @return mixed
+ * The value of $identifier.
+ */
+ public function get_identifier() {
return $this->identifier;
}
- function get_title() {
+ /**
+ * Return the title.
+ *
+ * @return mixed
+ * The value of $title.
+ */
+ public function get_title() {
return $this->title;
}
- function get_page_title() {
+ /**
+ * Return the page title.
+ *
+ * @return mixed
+ * The value of $page_title.
+ */
+ public function get_page_title() {
return $this->page_title;
}
+
}
/**
@@ -91,39 +205,57 @@ class ctools_context {
* match a required context type.
*/
class ctools_context_required {
- var $keywords = '';
+ /**
+ * @var array
+ * Keyword strings associated with the context.
+ */
+ public $keywords;
/**
* If set, the title will be used in the selector to identify
* the context. This is very useful when multiple contexts
* are required to inform the user will be used for what.
*/
- var $title = NULL;
+ public $title;
/**
* Test to see if this context is required.
*/
- var $required = TRUE;
+ public $required = TRUE;
/**
* If TRUE, skip the check in ctools_context_required::select()
* for contexts whose names may have changed.
*/
- var $skip_name_check = FALSE;
+ public $skip_name_check = FALSE;
/**
+ * The ctools_context_required constructor.
*
- * @param $title
- * The first parameter should be the 'title' of the context for use
- * in UYI selectors when multiple contexts qualify.
- * @param ...
+ * Note: Constructor accepts a variable number of arguments, with optional
+ * type-dependent args at the end of the list and one required argument,
+ * the title. Note in particular that skip_name_check MUST be passed in as
+ * a boolean (and not, for example, as an integer).
+ *
+ * @param string $title
+ * The title of the context for use in UI selectors when multiple contexts
+ * qualify.
+ * @param string $keywords
* One or more keywords to use for matching which contexts are allowed.
+ * @param array $restrictions
+ * Array of context restrictions.
+ * @param bool $skip_name_check
+ * If True, skip the check in select() for contexts whose names may have
+ * changed.
*/
- function ctools_context_required($title) {
+ public function __construct($title) {
+ // If it was possible, using variadic syntax this should be:
+ // __construct($title, string ...$keywords, array $restrictions = NULL, bool $skip = NULL)
+ // but that form isn't allowed.
$args = func_get_args();
$this->title = array_shift($args);
- // If we have a boolean value at the end for $skip_name_check, store it
+ // If we have a boolean value at the end for $skip_name_check, store it.
if (is_bool(end($args))) {
$this->skip_name_check = array_pop($args);
}
@@ -133,20 +265,44 @@ class ctools_context_required {
$this->restrictions = array_pop($args);
}
- if (count($args) == 1) {
+ if (count($args) === 1) {
$args = array_shift($args);
}
$this->keywords = $args;
}
- function filter($contexts) {
+ /**
+ * Filter the contexts to determine which apply in the current environment.
+ *
+ * A context passes the filter if:
+ * - the context matches 'type' of the required keywords (uses
+ * ctools_context::is_type(), so includes 'any' matches, etc).
+ * - AND if restrictions are present, there are some common elements between
+ * the requirement and the context.
+ *
+ * @param array $contexts
+ * An array of ctools_context objects (or something which will cast to an
+ * array of them). The contexts to apply the filter on.
+ *
+ * @return array
+ * An array of context objects, keyed with the same keys used for $contexts,
+ * which pass the filter.
+ *
+ * @see ctools_context::is_type()
+ */
+ public function filter($contexts) {
$result = array();
- // See which of these contexts are valid
+ /**
+ * See which of these contexts are valid.
+ * @var ctools_context $context
+ */
foreach ((array) $contexts as $cid => $context) {
if ($context->is_type($this->keywords)) {
+
// Compare to see if our contexts were met.
if (!empty($this->restrictions) && !empty($context->restrictions)) {
+
foreach ($this->restrictions as $key => $values) {
// If we have a restriction, the context must either not have that
// restriction listed, which means we simply don't know what it is,
@@ -155,11 +311,16 @@ class ctools_context_required {
if (!is_array($values)) {
$values = array($values);
}
- if (!empty($context->restrictions[$key]) && !array_intersect($values, $context->restrictions[$key])) {
+
+ if (!empty($context->restrictions[$key])
+ && !array_intersect($values, $context->restrictions[$key])
+ ) {
+ // Break out to check next context; this one fails the filter.
continue 2;
}
}
}
+ // This context passes the filter.
$result[$cid] = $context;
}
}
@@ -167,16 +328,43 @@ class ctools_context_required {
return $result;
}
- function select($contexts, $context) {
+ /**
+ * Select one context from the list of contexts, accounting for changed IDs.
+ *
+ * Fundamentally, this returns $contexts[$context] or FALSE if that does not
+ * exist. Additional logic accounts for changes in context names and dealing
+ * with a $contexts parameter that is not an array.
+ *
+ * If we had requested a $context but that $context doesn't exist in our
+ * context list, there is a good chance that what happened is the context
+ * IDs changed. Look for another context that satisfies our requirements,
+ * unless $skip_name_check is set.
+ *
+ * @param ctools_context|array $contexts
+ * A context, or an array of ctools_context.
+ * @param string $context
+ * A context ID.
+ *
+ * @return bool|ctools_context
+ * The matching ctools_context, or False if no such context was found.
+ */
+ public function select($contexts, $context) {
+ // Easier to deal with a standalone object as a 1-element array of objects.
if (!is_array($contexts)) {
- $contexts = array($contexts);
+ if (is_object($contexts) && $contexts instanceof ctools_context) {
+ $contexts = array($contexts->id => $contexts);
+ }
+ else {
+ $contexts = array($contexts);
+ }
}
- // If we had requested a $context but that $context doesn't exist
- // in our context list, there is a good chance that what happened
- // is our context IDs changed. See if there's another context
- // that satisfies our requirements.
- if (!$this->skip_name_check && !empty($context) && !isset($contexts[$context])) {
+ // If we had requested a $context but that $context doesn't exist in our
+ // context list, there is a good chance that what happened is the context
+ // IDs changed. Check for another context that satisfies our requirements.
+ if (!$this->skip_name_check
+ && !empty($context) && !isset($contexts[$context])
+ ) {
$choices = $this->filter($contexts);
// If we got a hit, take the first one that matches.
@@ -191,6 +379,7 @@ class ctools_context_required {
}
return $contexts[$context];
}
+
}
/**
@@ -198,28 +387,73 @@ class ctools_context_required {
* can produce empty contexts to use as placeholders.
*/
class ctools_context_optional extends ctools_context_required {
- var $required = FALSE;
- function ctools_context_optional() {
- $args = func_get_args();
- call_user_func_array(array($this, 'ctools_context_required'), $args);
+
+ /**
+ * {@inheritdoc}
+ */
+ public $required = FALSE;
+
+ /**
+ * Add the 'empty' context to the existing set.
+ *
+ * @param array &$contexts
+ * An array of ctools_context objects.
+ */
+ public function add_empty(&$contexts) {
+ $context = new ctools_context('any');
+ $context->title = t('No context');
+ $context->identifier = t('No context');
+ $contexts['empty'] = $context;
}
/**
- * Add the 'empty' context which is possible for optional
+ * Filter the contexts to determine which apply in the current environment.
+ *
+ * As for ctools_context_required, but we add the empty context to those
+ * passed in so the check is optional (i.e. if nothing else matches, the
+ * empty context will, and so there will always be at least one matched).
+ *
+ * @param array $contexts
+ * An array of ctools_context objects (or something which will cast to an
+ * array of them). The contexts to apply the filter on.
+ *
+ * @return array
+ * An array of context objects, keyed with the same keys used for $contexts,
+ * which pass the filter.
+ *
+ * @see ctools_context::is_type()
*/
- function add_empty(&$contexts) {
- $context = new ctools_context('any');
- $context->title = t('No context');
- $context->identifier = t('No context');
- $contexts = array_merge(array('empty' => $context), $contexts);
- }
-
- function filter($contexts) {
+ public function filter($contexts) {
+ /**
+ * @todo We are assuming here that $contexts is actually an array, whereas
+ * ctools_context_required::filter only requires $contexts is convertible
+ * to an array.
+ */
$this->add_empty($contexts);
return parent::filter($contexts);
}
- function select($contexts, $context) {
+ /**
+ * Select and return one context from the list of applicable contexts.
+ *
+ * Fundamentally, this returns $contexts[$context] or the empty context if
+ * that does not exist.
+ *
+ * @param array $contexts
+ * The applicable contexts to check.
+ * @param string $context
+ * The context id to check for.
+ *
+ * @return bool|ctools_context
+ * The matching ctools_context, or False if no such context was found.
+ *
+ * @see ctools_context_required::select()
+ */
+ public function select($contexts, $context) {
+ /**
+ * @todo We are assuming here that $contexts is actually an array, whereas
+ * ctools_context_required::select permits ctools_context objects as well.
+ */
$this->add_empty($contexts);
if (empty($context)) {
return $contexts['empty'];
@@ -229,11 +463,12 @@ class ctools_context_optional extends ctools_context_required {
// Don't flip out if it can't find the context; this is optional, put
// in an empty.
- if ($result == FALSE) {
+ if ($result === FALSE) {
$result = $contexts['empty'];
}
return $result;
}
+
}
/**
@@ -248,20 +483,20 @@ class ctools_context_optional extends ctools_context_required {
* Since multiple contexts can be required, this function will accept either
* an array of all required contexts, or just a single required context object.
*
- * @param $contexts
+ * @param array $contexts
* A keyed array of all available contexts.
- * @param $required
- * A ctools_context_required or ctools_context_optional object, or an array
- * of such objects.
+ * @param array|ctools_context_required|ctools_context_optional $required
+ * A *_required or *_optional object, or an array of such objects, which
+ * define the selection condition.
*
- * @return
+ * @return array
* A keyed array of contexts that match the filter.
*/
function ctools_context_filter($contexts, $required) {
if (is_array($required)) {
$result = array();
- foreach ($required as $r) {
- $result = array_merge($result, _ctools_context_filter($contexts, $r));
+ foreach ($required as $item) {
+ $result = array_merge($result, _ctools_context_filter($contexts, $item));
}
return $result;
}
@@ -269,6 +504,21 @@ function ctools_context_filter($contexts, $required) {
return _ctools_context_filter($contexts, $required);
}
+/**
+ * Helper function for ctools_context_filter().
+ *
+ * Used to transform the required context during the merge into the final array.
+ *
+ * @internal This function DOES NOT form part of the CTools API.
+ *
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param ctools_context_required|ctools_context_optional $required
+ * A ctools_context_required or ctools_context_optional object, although if
+ * given something else will return an empty array.
+ *
+ * @return array
+ */
function _ctools_context_filter($contexts, $required) {
$result = array();
@@ -288,12 +538,17 @@ function _ctools_context_filter($contexts, $required) {
* If an array of required contexts is provided, one selector will be
* provided for each context.
*
- * @param $contexts
+ * @param array $contexts
* A keyed array of all available contexts.
- * @param $required
+ * @param array|ctools_context_required|ctools_context_optional $required
* The required context object or array of objects.
+ * @param array|string $default
+ * The default value for the select object, suitable for a #default_value
+ * render key. Where $required is an array, this is an array keyed by the
+ * same key values as $required for all keys where an empty string is not a
+ * suitable default. Otherwise it is just the default value.
*
- * @return
+ * @return array
* A form element, or NULL if there are no contexts that satisfy the
* requirements.
*/
@@ -301,8 +556,10 @@ function ctools_context_selector($contexts, $required, $default) {
if (is_array($required)) {
$result = array('#tree' => TRUE);
$count = 1;
- foreach ($required as $id => $r) {
- $result[] = _ctools_context_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++);
+ foreach ($required as $id => $item) {
+ $result[] = _ctools_context_selector(
+ $contexts, $item, isset($default[$id]) ? $default[$id] : '', $count++
+ );
}
return $result;
}
@@ -310,6 +567,27 @@ function ctools_context_selector($contexts, $required, $default) {
return _ctools_context_selector($contexts, $required, $default);
}
+/**
+ * Helper function for ctools_context_selector().
+ *
+ * @internal This function DOES NOT form part of the CTools API. Use the API
+ * function ctools_context_selector() instead.
+ *
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param ctools_context_required|ctools_context_optional $required
+ * The required context object.
+ * @param $default
+ * The default value for the select object, suitable for a #default_value
+ * render key.
+ * @param int $num
+ * If supplied and non-zero, the title of the select form element will be
+ * "Context $num", otherwise it will be "Context".
+ *
+ * @return array
+ * A form element, or NULL if there are no contexts that satisfy the
+ * requirements.
+ */
function _ctools_context_selector($contexts, $required, $default, $num = 0) {
$filtered = ctools_context_filter($contexts, $required);
$count = count($filtered);
@@ -328,13 +606,15 @@ function _ctools_context_selector($contexts, $required, $default, $num = 0) {
$title = $num ? t('Context %count', array('%count' => $num)) : t('Context');
}
- return array(
+ $form = array(
'#type' => 'select',
'#options' => $options,
'#title' => $title,
'#default_value' => $default,
);
}
+
+ return $form;
}
/**
@@ -351,8 +631,8 @@ function _ctools_context_selector($contexts, $required, $default, $num = 0) {
* @param $required
* The required context object or array of objects.
*
- * @return
- * TRUE if there are enough contexts, FALSE if there are not.
+ * @return bool
+ * True if there are enough contexts, otherwise False.
*/
function ctools_context_match_requirements($contexts, $required) {
if (!is_array($required)) {
@@ -385,8 +665,13 @@ function ctools_context_match_requirements($contexts, $required) {
* A keyed array of all available contexts.
* @param $required
* The required context object or array of objects.
+ * @param array|string $default
+ * The default value for the select object, suitable for a #default_value
+ * render key. Where $required is an array, this is an array keyed by the
+ * same key values as $required for all keys where an empty string is not a
+ * suitable default. Otherwise it is just the default value.
*
- * @return
+ * @return array
* A form element, or NULL if there are no contexts that satisfy the
* requirements.
*/
@@ -394,8 +679,11 @@ function ctools_context_converter_selector($contexts, $required, $default) {
if (is_array($required)) {
$result = array('#tree' => TRUE);
$count = 1;
- foreach ($required as $id => $r) {
- $result[] = _ctools_context_converter_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++);
+ foreach ($required as $id => $dependency) {
+ $default_id = isset($default[$id]) ? $default[$id] : '';
+ $result[] = _ctools_context_converter_selector(
+ $contexts, $dependency, $default_id, $count++
+ );
}
return $result;
}
@@ -403,17 +691,36 @@ function ctools_context_converter_selector($contexts, $required, $default) {
return _ctools_context_converter_selector($contexts, $required, $default);
}
+/**
+ * Helper function for ctools_context_converter_selector().
+ *
+ * @internal This function DOES NOT form part of the CTools API. Use the API
+ * function ctools_context_converter_selector() instead.
+ *
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param ctools_context $required
+ * The required context object.
+ * @param $default
+ * The default value for the select object, suitable for a #default_value
+ * render key.
+ * @param int $num
+ * If supplied and non-zero, the title of the select form element will be
+ * "Context $num", otherwise it will be "Context".
+ *
+ * @return array|null
+ * A form element, or NULL if there are no contexts that satisfy the
+ * requirements.
+ */
function _ctools_context_converter_selector($contexts, $required, $default, $num = 0) {
$filtered = ctools_context_filter($contexts, $required);
$count = count($filtered);
- $form = array();
-
if ($count > 1) {
// If there's more than one to choose from, create a select widget.
$options = array();
foreach ($filtered as $cid => $context) {
- if ($context->type == 'any') {
+ if ($context->type === 'any') {
$options[''] = t('No context');
continue;
}
@@ -443,10 +750,22 @@ function _ctools_context_converter_selector($contexts, $required, $default, $num
'#default_value' => $default,
);
}
+ else {
+ // Not enough choices to need a selector, so don't make one.
+ return NULL;
+ }
}
/**
* Get a list of converters available for a given context.
+ *
+ * @param string $cid
+ * A context ID.
+ * @param ctools_context $context
+ * The context for which converters are needed.
+ *
+ * @return array
+ * A list of context converters.
*/
function ctools_context_get_converters($cid, $context) {
if (empty($context->plugin)) {
@@ -458,6 +777,17 @@ function ctools_context_get_converters($cid, $context) {
/**
* Get a list of converters available for a given context.
+ *
+ * @internal This function DOES NOT form part of the CTools API. Use the API
+ * function ctools_context_get_converters() instead.
+ *
+ * @param string $id
+ * A context ID.
+ * @param string $plugin_name
+ * The name of the context plugin.
+ *
+ * @return array
+ * A list of context converters.
*/
function _ctools_context_get_converters($id, $plugin_name) {
$plugin = ctools_get_context($plugin_name);
@@ -469,7 +799,7 @@ function _ctools_context_get_converters($id, $plugin_name) {
if (is_array($plugin['convert list'])) {
$converters = $plugin['convert list'];
}
- else if ($function = ctools_plugin_get_function($plugin, 'convert list')) {
+ elseif ($function = ctools_plugin_get_function($plugin, 'convert list')) {
$converters = (array) $function($plugin);
}
@@ -489,7 +819,13 @@ function _ctools_context_get_converters($id, $plugin_name) {
}
/**
- * Get a list of all contexts + converters available.
+ * Get a list of all contexts converters available.
+ *
+ * For all contexts returned by ctools_get_contexts(), return the converter
+ * for all contexts that have one.
+ *
+ * @return array
+ * A list of context converters, keyed by the title of the converter.
*/
function ctools_context_get_all_converters() {
$contexts = ctools_get_contexts();
@@ -509,21 +845,24 @@ function ctools_context_get_all_converters() {
/**
* Let the context convert an argument based upon the converter that was given.
*
- * @param $context
- * The context object
- * @param $converter
- * The converter to use, which should be a string provided by the converter list.
- * @param $converter_options
- * A n array of options to pass on to the generation function. For contexts
+ * @param ctools_context $context
+ * The context object.
+ * @param string $converter
+ * The type of converter to use, which should be a string provided by the
+ * converter list function.
+ * @param array $converter_options
+ * An array of options to pass on to the generation function. For contexts
* that use token module, of particular use is 'sanitize' => FALSE which can
* get raw tokens. This should ONLY be used in values that will later be
* treated as unsafe user input since these values are by themselves unsafe.
* It is particularly useful to get raw values from Field API.
+ *
+ * @return string|null
*/
function ctools_context_convert_context($context, $converter, $converter_options = array()) {
// Contexts without plugins might be optional placeholders.
if (empty($context->plugin)) {
- return;
+ return NULL;
}
$value = $context->argument;
@@ -544,22 +883,35 @@ function ctools_context_convert_context($context, $converter, $converter_options
* Choose a context or contexts based upon the selection made via
* ctools_context_filter.
*
- * @param $contexts
- * A keyed array of all available contexts
- * @param $required
- * The required context object provided by the plugin
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param array|ctools_context_required $required
+ * The required context object(s) provided by the plugin.
* @param $context
- * The selection made using ctools_context_selector
+ * The selection made using ctools_context_selector().
+ *
+ * @return ctools_context|array|false
+ * Returns FALSE if $required is not an object, or array of objects, or
+ * the value of $required->select() for the context, or an array of those (if
+ * passed an array in $required).
*/
function ctools_context_select($contexts, $required, $context) {
if (is_array($required)) {
+
+ /**
+ * @var array $required
+ * Array of required context objects.
+ * @var ctools_context_required $item
+ * A required context object.
+ */
$result = array();
- foreach ($required as $id => $r) {
+ foreach ($required as $id => $item) {
+ // @todo What's the difference between the following and "empty($item)" ?
if (empty($required[$id])) {
continue;
}
- if (($result[] = _ctools_context_select($contexts, $r, $context[$id])) === FALSE) {
+ if (($result[] = _ctools_context_select($contexts, $item, $context[$id])) === FALSE) {
return FALSE;
}
}
@@ -569,6 +921,22 @@ function ctools_context_select($contexts, $required, $context) {
return _ctools_context_select($contexts, $required, $context);
}
+/**
+ * Helper function for calling the required context object's selection function.
+ *
+ * This function DOES NOT form part of the CTools API.
+ *
+ * @param array $contexts
+ * A keyed array of all available contexts.
+ * @param ctools_context_required $required
+ * The required context object provided by the plugin.
+ * @param $context
+ * The selection made using ctools_context_selector().
+ *
+ * @return ctools_context|bool
+ * FALSE if the $required is not an object. A ctools_context object if one
+ * matched.
+ */
function _ctools_context_select($contexts, $required, $context) {
if (!is_object($required)) {
return FALSE;
@@ -580,16 +948,14 @@ function _ctools_context_select($contexts, $required, $context) {
/**
* Create a new context object.
*
- * @param $type
+ * @param string $type
* The type of context to create; this loads a plugin.
- * @param $data
+ * @param mixed $data
* The data to put into the context.
- * @param $empty
- * Whether or not this context is specifically empty.
* @param $conf
* A configuration structure if this context was created via UI.
*
- * @return
+ * @return ctools_context
* A $context or NULL if one could not be created.
*/
function ctools_context_create($type, $data = NULL, $conf = FALSE) {
@@ -612,7 +978,7 @@ function ctools_context_create($type, $data = NULL, $conf = FALSE) {
* @param $type
* The type of context to create; this loads a plugin.
*
- * @return
+ * @return ctools_context
* A $context or NULL if one could not be created.
*/
function ctools_context_create_empty($type) {
@@ -629,8 +995,21 @@ function ctools_context_create_empty($type) {
/**
* Perform keyword and context substitutions.
+ *
+ * @param string $string
+ * The string in which to replace keywords.
+ * @param array $keywords
+ * Array of keyword-replacement pairs.
+ * @param array $contexts
+ *
+ * @param array $converter_options
+ * Options to pass on to ctools_context_convert_context(), defaults to an
+ * empty array.
+ *
+ * @return string
+ * The returned string, with substitutions performed.
*/
-function ctools_context_keyword_substitute($string, $keywords, $contexts, $converter_options = array()) {
+function ctools_context_keyword_substitute($string, $keywords, $contexts, array $converter_options = array()) {
// Ensure a default keyword exists:
$keywords['%%'] = '%';
@@ -653,7 +1032,7 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts, $conve
// If the keyword is already set by something passed in, don't try to
// overwrite it.
- if (!empty($keywords['%' . $keyword])) {
+ if (array_key_exists('%' . $keyword, $keywords)) {
continue;
}
@@ -673,14 +1052,21 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts, $conve
}
}
- if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) {
- $keywords['%' . $keyword] = '';
- }
- else if (!empty($converter)) {
- $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options);
+ if (!isset($context_keywords[$context])) {
+ $keywords['%' . $keyword] = '%' . $keyword;
}
else {
- $keywords['%' . $keyword] = $context_keywords[$keyword]->title;
+ if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) {
+ $keywords['%' . $keyword] = '';
+ }
+ else {
+ if (!empty($converter)) {
+ $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options);
+ }
+ else {
+ $keywords['%' . $keyword] = $context_keywords[$keyword]->title;
+ }
+ }
}
}
}
@@ -688,18 +1074,22 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts, $conve
}
/**
- * Determine a unique context ID for a context
+ * Determine a unique context ID for a context.
*
* Often contexts of many different types will be placed into a list. This
* ensures that even though contexts of multiple types may share IDs, they
* are unique in the final list.
*/
function ctools_context_id($context, $type = 'context') {
- if (!$context['id']) {
+ // If not set, FALSE or empty.
+ if (!isset($context['id']) || !$context['id']) {
$context['id'] = 1;
}
- return $type . '_' . $context['name'] . '_' . $context['id'];
+ // @todo is '' the appropriate default value?
+ $name = isset($context['name']) ? $context['name'] : '';
+
+ return $type . '_' . $name . '_' . $context['id'];
}
/**
@@ -707,42 +1097,46 @@ function ctools_context_id($context, $type = 'context') {
*
* This finds the next id available for the named object.
*
- * @param $objects
- * A list of context descriptor objects, i.e, arguments, relationships, contexts, etc.
- * @param $name
+ * @param array $objects
+ * A list of context descriptor objects, i.e, arguments, relationships,
+ * contexts, etc.
+ * @param string $name
* The name being used.
+ *
+ * @return int
+ * The next integer id available.
*/
function ctools_context_next_id($objects, $name) {
$id = 0;
- // Figure out which instance of this argument we're creating
+ // Figure out which instance of this argument we're creating.
if (!$objects) {
return $id + 1;
}
foreach ($objects as $object) {
- if (isset($object['name']) && $object['name'] == $name) {
- if ($object['id'] > $id) {
+ if (isset($object['name']) && $object['name'] === $name) {
+ if (isset($object['id']) && $object['id'] > $id) {
$id = $object['id'];
}
+ // @todo If obj has no 'id', should we increment local id? $id = $id + 1;
}
}
return $id + 1;
}
-
// ---------------------------------------------------------------------------
// Functions related to contexts from arguments.
-
/**
- * Fetch metadata on a specific argument plugin.
+ * Fetch metadata for a specific argument plugin.
*
* @param $argument
* Name of an argument plugin.
*
- * @return
+ * @return array
* An array with information about the requested argument plugin.
*/
+
function ctools_get_argument($argument) {
ctools_include('plugins');
return ctools_get_plugins('ctools', 'arguments', $argument);
@@ -751,7 +1145,7 @@ function ctools_get_argument($argument) {
/**
* Fetch metadata for all argument plugins.
*
- * @return
+ * @return array
* An array of arrays with information about all available argument plugins.
*/
function ctools_get_arguments() {
@@ -771,22 +1165,23 @@ function ctools_get_arguments() {
* - keyword: The keyword used for this argument for substitutions.
*
* @param $arg
- * The actual argument received. This is expected to be a string from a URL but
- * this does not have to be the only source of arguments.
+ * The actual argument received. This is expected to be a string from a URL
+ * but this does not have to be the only source of arguments.
* @param $empty
* If true, the $arg will not be used to load the context. Instead, an empty
* placeholder context will be loaded.
*
- * @return
+ * @return ctools_context
* A context object if one can be loaded.
*/
function ctools_context_get_context_from_argument($argument, $arg, $empty = FALSE) {
ctools_include('plugins');
if (empty($argument['name'])) {
- return;
+ return NULL;
}
- if ($function = ctools_plugin_load_function('ctools', 'arguments', $argument['name'], 'context')) {
+ $function = ctools_plugin_load_function('ctools', 'arguments', $argument['name'], 'context');
+ if ($function) {
// Backward compatibility: Merge old style settings into new style:
if (!empty($argument['settings'])) {
$argument += $argument['settings'];
@@ -798,8 +1193,8 @@ function ctools_context_get_context_from_argument($argument, $arg, $empty = FALS
if (is_object($context)) {
$context->identifier = $argument['identifier'];
$context->page_title = isset($argument['title']) ? $argument['title'] : '';
- $context->keyword = $argument['keyword'];
- $context->id = ctools_context_id($argument, 'argument');
+ $context->keyword = $argument['keyword'];
+ $context->id = ctools_context_id($argument, 'argument');
$context->original_argument = $arg;
if (!empty($context->empty)) {
@@ -815,6 +1210,12 @@ function ctools_context_get_context_from_argument($argument, $arg, $empty = FALS
/**
* Retrieve a list of empty contexts for all arguments.
+ *
+ * @param array $arguments
+ *
+ * @return array
+ *
+ * @see ctools_context_get_context_from_arguments()
*/
function ctools_context_get_placeholders_from_argument($arguments) {
$contexts = array();
@@ -830,19 +1231,21 @@ function ctools_context_get_placeholders_from_argument($arguments) {
/**
* Load the contexts for a given list of arguments.
*
- * @param $arguments
+ * @param array $arguments
* The array of argument definitions.
- * @param &$contexts
+ * @param array &$contexts
* The array of existing contexts. New contexts will be added to this array.
- * @param $args
+ * @param array $args
* The arguments to load.
*
- * @return
- * FALSE if an argument wants to 404.
+ * @return bool
+ * TRUE if all is well, FALSE if an argument wants to 404.
+ *
+ * @see ctools_context_get_context_from_argument()
*/
function ctools_context_get_context_from_arguments($arguments, &$contexts, $args) {
foreach ($arguments as $argument) {
- // pull the argument off the list.
+ // Pull the argument off the list.
$arg = array_shift($args);
$id = ctools_context_id($argument, 'argument');
@@ -857,7 +1260,10 @@ function ctools_context_get_context_from_arguments($arguments, &$contexts, $args
$context = $contexts[$id];
}
- if ((empty($context) || empty($context->data)) && !empty($argument['default']) && $argument['default'] == '404') {
+ if ((empty($context) || empty($context->data))
+ && !empty($argument['default'])
+ && $argument['default'] === '404'
+ ) {
return FALSE;
}
}
@@ -866,16 +1272,18 @@ function ctools_context_get_context_from_arguments($arguments, &$contexts, $args
// ---------------------------------------------------------------------------
// Functions related to contexts from relationships.
-
/**
- * Fetch metadata on a specific relationship plugin.
+ * Fetch plugin metadata for a specific relationship plugin.
*
- * @param $content type
+ * @param $relationship
* Name of a panel content type.
*
- * @return
+ * @return array
* An array with information about the requested relationship.
+ *
+ * @see ctools_get_relationships()
*/
+
function ctools_get_relationship($relationship) {
ctools_include('plugins');
return ctools_get_plugins('ctools', 'relationships', $relationship);
@@ -884,8 +1292,10 @@ function ctools_get_relationship($relationship) {
/**
* Fetch metadata for all relationship plugins.
*
- * @return
+ * @return array
* An array of arrays with information about all available relationships.
+ *
+ * @see ctools_get_relationship()
*/
function ctools_get_relationships() {
ctools_include('plugins');
@@ -893,8 +1303,9 @@ function ctools_get_relationships() {
}
/**
+ * Return a context from a relationship.
*
- * @param $relationship
+ * @param array $relationship
* The configuration of a relationship. It must contain the following data:
* - name: The name of the relationship plugin being used.
* - relationship_settings: The configuration based upon the plugin forms.
@@ -902,18 +1313,21 @@ function ctools_get_relationships() {
* defined by the UI.
* - keyword: The keyword used for this relationship for substitutions.
*
- * @param $source_context
+ * @param ctools_context $source_context
* The context this relationship is based upon.
- *
- * @param $placeholders
+ * @param bool $placeholders
* If TRUE, placeholders are acceptable.
*
- * @return
- * A context object if one can be loaded.
+ * @return ctools_context|null
+ * A context object if one can be loaded, otherwise NULL.
+ *
+ * @see ctools_context_get_relevant_relationships()
+ * @see ctools_context_get_context_from_relationships()
*/
function ctools_context_get_context_from_relationship($relationship, $source_context, $placeholders = FALSE) {
ctools_include('plugins');
- if ($function = ctools_plugin_load_function('ctools', 'relationships', $relationship['name'], 'context')) {
+ $function = ctools_plugin_load_function('ctools', 'relationships', $relationship['name'], 'context');
+ if ($function) {
// Backward compatibility: Merge old style settings into new style:
if (!empty($relationship['relationship_settings'])) {
$relationship += $relationship['relationship_settings'];
@@ -924,7 +1338,7 @@ function ctools_context_get_context_from_relationship($relationship, $source_con
if ($context) {
$context->identifier = $relationship['identifier'];
$context->page_title = isset($relationship['title']) ? $relationship['title'] : '';
- $context->keyword = $relationship['keyword'];
+ $context->keyword = $relationship['keyword'];
if (!empty($context->empty)) {
$context->placeholder = array(
'type' => 'relationship',
@@ -934,6 +1348,7 @@ function ctools_context_get_context_from_relationship($relationship, $source_con
return $context;
}
}
+ return NULL;
}
/**
@@ -947,18 +1362,24 @@ function ctools_context_get_context_from_relationship($relationship, $source_con
* @param $contexts
* An array of contexts used to figure out which relationships are relevant.
*
- * @return
+ * @return array
* An array of relationship keys that are relevant for the given set of
* contexts.
+ *
+ * @see ctools_context_filter()
+ * @see ctools_context_get_context_from_relationship()
+ * @see ctools_context_get_context_from_relationships()
*/
function ctools_context_get_relevant_relationships($contexts) {
$relevant = array();
$relationships = ctools_get_relationships();
- // Go through each relationship
+ // Go through each relationship.
foreach ($relationships as $rid => $relationship) {
// For each relationship, see if there is a context that satisfies it.
- if (empty($relationship['no ui']) && ctools_context_filter($contexts, $relationship['required context'])) {
+ if (empty($relationship['no ui'])
+ && ctools_context_filter($contexts, $relationship['required context'])
+ ) {
$relevant[$rid] = $relationship['title'];
}
}
@@ -967,7 +1388,7 @@ function ctools_context_get_relevant_relationships($contexts) {
}
/**
- * Fetch all active relationships
+ * Fetch all active relationships.
*
* @param $relationships
* An keyed array of relationship data including:
@@ -982,10 +1403,11 @@ function ctools_context_get_relevant_relationships($contexts) {
*
* @param $placeholders
* If TRUE, placeholders are acceptable.
+ *
+ * @see ctools_context_get_context_from_relationship()
+ * @see ctools_context_get_relevant_relationships()
*/
function ctools_context_get_context_from_relationships($relationships, &$contexts, $placeholders = FALSE) {
- $return = array();
-
foreach ($relationships as $rdata) {
if (!isset($rdata['context'])) {
continue;
@@ -1016,16 +1438,16 @@ function ctools_context_get_context_from_relationships($relationships, &$context
// ---------------------------------------------------------------------------
// Functions related to loading contexts from simple context definitions.
-
/**
* Fetch metadata on a specific context plugin.
*
- * @param $context
+ * @param string $context
* Name of a context.
*
- * @return
+ * @return array
* An array with information about the requested panel context.
*/
+
function ctools_get_context($context) {
static $gate = array();
ctools_include('plugins');
@@ -1049,7 +1471,7 @@ function ctools_get_context($context) {
/**
* Fetch metadata for all context plugins.
*
- * @return
+ * @return array
* An array of arrays with information about all available panel contexts.
*/
function ctools_get_contexts() {
@@ -1058,27 +1480,38 @@ function ctools_get_contexts() {
}
/**
+ * Return a context object from a context definition array.
*
- * @param $context
+ * The input $context contains the information needed to identify and invoke
+ * the context plugin and create the plugin context from that.
+ *
+ * @param array $context
* The configuration of a context. It must contain the following data:
* - name: The name of the context plugin being used.
* - context_settings: The configuration based upon the plugin forms.
* - identifier: The human readable identifier for this context, usually
* defined by the UI.
* - keyword: The keyword used for this context for substitutions.
- * @param $type
+ * @param string $type
* This is either 'context' which indicates the context will be loaded
- * from data in the settings, or 'required_context' which means the
+ * from data in the settings, or 'requiredcontext' which means the
* context must be acquired from an external source. This is the method
* used to pass pure contexts from one system to another.
+ * @param mixed $argument
+ * Optional information passed to the plugin context via the arg defined in
+ * the plugin's "placeholder name" field.
*
- * @return
+ * @return ctools_context|null
* A context object if one can be loaded.
+ *
+ * @see ctools_get_context()
+ * @see ctools_plugin_get_function()
*/
function ctools_context_get_context_from_context($context, $type = 'context', $argument = NULL) {
ctools_include('plugins');
$plugin = ctools_get_context($context['name']);
- if ($function = ctools_plugin_get_function($plugin, 'context')) {
+ $function = ctools_plugin_get_function($plugin, 'context');
+ if ($function) {
// Backward compatibility: Merge old style settings into new style:
if (!empty($context['context_settings'])) {
$context += $context['context_settings'];
@@ -1093,7 +1526,7 @@ function ctools_context_get_context_from_context($context, $type = 'context', $a
if ($return) {
$return->identifier = $context['identifier'];
$return->page_title = isset($context['title']) ? $context['title'] : '';
- $return->keyword = $context['keyword'];
+ $return->keyword = $context['keyword'];
if (!empty($context->empty)) {
$context->placeholder = array(
@@ -1105,6 +1538,8 @@ function ctools_context_get_context_from_context($context, $type = 'context', $a
return $return;
}
}
+
+ return NULL;
}
/**
@@ -1118,7 +1553,10 @@ function ctools_context_get_context_from_context($context, $type = 'context', $a
* Either 'context' or 'requiredcontext', which indicates whether the contexts
* are loaded from internal data or copied from an external source.
* @param $placeholders
- * If true, placeholders are acceptable.
+ * If True, placeholders are acceptable.
+ *
+ * @return array
+ * Array of contexts, keyed by context ID.
*/
function ctools_context_get_context_from_contexts($contexts, $type = 'context', $placeholders = FALSE) {
$return = array();
@@ -1137,17 +1575,20 @@ function ctools_context_get_context_from_contexts($contexts, $type = 'context',
/**
* Match up external contexts to our required contexts.
*
- * This function is used to create a list of contexts with proper
- * IDs based upon a list of required contexts.
+ * This function is used to create a list of contexts with proper IDs based
+ * upon a list of required contexts.
*
- * These contexts passed in should match the numeric positions of the
- * required contexts. The caller must ensure this has already happened
- * correctly as this function will not detect errors here.
+ * These contexts passed in should match the numeric positions of the required
+ * contexts. The caller must ensure this has already happened correctly as this
+ * function will not detect errors here.
*
* @param $required
* A list of required contexts as defined by the UI.
* @param $contexts
* A list of matching contexts as passed in from the calling system.
+ *
+ * @return array
+ * Array of contexts, keyed by context ID.
*/
function ctools_context_match_required_contexts($required, $contexts) {
$return = array();
@@ -1156,10 +1597,10 @@ function ctools_context_match_required_contexts($required, $contexts) {
}
foreach ($required as $r) {
- $context = clone(array_shift($contexts));
+ $context = clone array_shift($contexts);
$context->identifier = $r['identifier'];
$context->page_title = isset($r['title']) ? $r['title'] : '';
- $context->keyword = $r['keyword'];
+ $context->keyword = $r['keyword'];
$return[ctools_context_id($r, 'requiredcontext')] = $context;
}
@@ -1171,31 +1612,35 @@ function ctools_context_match_required_contexts($required, $contexts) {
*
* Not all of the types need to be supported by this object.
*
- * This function is not used to load contexts from external data, but may
- * be used to load internal contexts and relationships. Otherwise it can also
- * be used to generate a full set of placeholders for UI purposes.
+ * This function is not used to load contexts from external data, but may be
+ * used to load internal contexts and relationships. Otherwise it can also be
+ * used to generate a full set of placeholders for UI purposes.
*
- * @param $object
+ * @param object $object
* An object that contains some or all of the following variables:
*
- * - requiredcontexts: A list of UI configured contexts that are required
- * from an external source. Since these require external data, they will
- * only be added if $placeholders is set to TRUE, and empty contexts will
- * be created.
- * - arguments: A list of UI configured arguments that will create contexts.
- * Since these require external data, they will only be added if $placeholders
- * is set to TRUE.
- * - contexts: A list of UI configured contexts that have no external source,
- * and are essentially hardcoded. For example, these might configure a
- * particular node or a particular taxonomy term.
- * - relationships: A list of UI configured contexts to be derived from other
- * contexts that already exist from other sources. For example, these might
- * be used to get a user object from a node via the node author relationship.
- * @param $placeholders
- * If TRUE, this will generate placeholder objects for types this function
+ * - requiredcontexts: A list of UI configured contexts that are required
+ * from an external source. Since these require external data, they will
+ * only be added if $placeholders is set to TRUE, and empty contexts will
+ * be created.
+ * - arguments: A list of UI configured arguments that will create contexts.
+ * As these require external data, they will only be added if $placeholders
+ * is set to TRUE.
+ * - contexts: A list of UI configured contexts that have no external source,
+ * and are essentially hardcoded. For example, these might configure a
+ * particular node or a particular taxonomy term.
+ * - relationships: A list of UI configured contexts to be derived from other
+ * contexts that already exist from other sources. For example, these might
+ * be used to get a user object from a node via the node author
+ * relationship.
+ * @param bool $placeholders
+ * If True, this will generate placeholder objects for any types this function
* cannot load.
- * @param $contexts
+ * @param array $contexts
* An array of pre-existing contexts that will be part of the return value.
+ *
+ * @return array
+ * Merged output of all results of ctools_context_get_context_from_contexts().
*/
function ctools_context_load_contexts($object, $placeholders = TRUE, $contexts = array()) {
if (!empty($object->base_contexts)) {
@@ -1219,7 +1664,7 @@ function ctools_context_load_contexts($object, $placeholders = TRUE, $contexts =
$contexts += ctools_context_get_context_from_contexts($object->contexts, 'context', $placeholders);
}
- // add contexts from relationships
+ // Add contexts from relationships.
if (!empty($object->relationships) && is_array($object->relationships)) {
ctools_context_get_context_from_relationships($object->relationships, $contexts, $placeholders);
}
@@ -1238,7 +1683,7 @@ function ctools_context_load_contexts($object, $placeholders = TRUE, $contexts =
function ctools_context_get_form($contexts) {
if (!empty($contexts)) {
foreach ($contexts as $id => $context) {
- // if a form shows its id as being a 'required context' that means the
+ // If a form shows its id as being a 'required context' that means the
// the context is external to this display and does not count.
if (!empty($context->form_id) && substr($id, 0, 15) != 'requiredcontext') {
return $context;
@@ -1257,7 +1702,7 @@ function ctools_context_get_form($contexts) {
* The arguments. These will be acquired from $form_state['values'] and the
* keys must match the context IDs.
*
- * @return
+ * @return array
* A new $contexts array containing the replaced contexts. Not all contexts
* may be replaced if, for example, an argument was unable to be converted
* into a context.
@@ -1276,12 +1721,14 @@ function ctools_context_replace_placeholders($contexts, $arguments) {
$new_context = ctools_context_get_context_from_relationship($relationship, $contexts[$relationship['context']]);
}
break;
+
case 'argument':
if (isset($arguments[$cid]) && $arguments[$cid] !== '') {
$argument = $context->placeholder['conf'];
$new_context = ctools_context_get_context_from_argument($argument, $arguments[$cid]);
}
break;
+
case 'context':
if (!empty($arguments[$cid])) {
$context_info = $context->placeholder['conf'];
@@ -1330,32 +1777,37 @@ function ctools_context_replace_form(&$form, $contexts) {
if (is_array($plugin['placeholder form'])) {
$form[$cid] = $plugin['placeholder form'];
}
- else if (function_exists($plugin['placeholder form'])) {
- $widget = $plugin['placeholder form']($info);
- if ($widget) {
- $form[$cid] = $widget;
+ else {
+ if (function_exists($plugin['placeholder form'])) {
+ $widget = $plugin['placeholder form']($info);
+ if ($widget) {
+ $form[$cid] = $widget;
+ }
}
}
if (!empty($form[$cid])) {
- $form[$cid]['#title'] = t('@identifier (@keyword)', array('@keyword' => '%' . $context->keyword, '@identifier' => $context->identifier));
+ $form[$cid]['#title'] = t('@identifier (@keyword)', array(
+ '@keyword' => '%' . $context->keyword,
+ '@identifier' => $context->identifier,
+ ));
}
}
}
}
// ---------------------------------------------------------------------------
-// Functions related to loading access control plugins
-
+// Functions related to loading access control plugins.
/**
* Fetch metadata on a specific access control plugin.
*
* @param $name
* Name of a plugin.
*
- * @return
+ * @return array
* An array with information about the requested access control plugin.
*/
+
function ctools_get_access_plugin($name) {
ctools_include('plugins');
return ctools_get_plugins('ctools', 'access', $name);
@@ -1364,7 +1816,7 @@ function ctools_get_access_plugin($name) {
/**
* Fetch metadata for all access control plugins.
*
- * @return
+ * @return array
* An array of arrays with information about all available access control plugins.
*/
function ctools_get_access_plugins() {
@@ -1376,8 +1828,14 @@ function ctools_get_access_plugins() {
* Fetch a list of access plugins that are available for a given list of
* contexts.
*
- * if 'logged-in-user' is not in the list of contexts, it will be added as
+ * If 'logged-in-user' is not in the list of contexts, it will be added as
* this is required.
+ *
+ * @param array $contexts
+ * Array of ctools_context objects with which to select access plugins.
+ *
+ * @return array
+ * Array of applicable access plugins. Can be empty.
*/
function ctools_get_relevant_access_plugins($contexts) {
if (!isset($contexts['logged-in-user'])) {
@@ -1387,7 +1845,9 @@ function ctools_get_relevant_access_plugins($contexts) {
$all_plugins = ctools_get_access_plugins();
$plugins = array();
foreach ($all_plugins as $id => $plugin) {
- if (!empty($plugin['required context']) && !ctools_context_match_requirements($contexts, $plugin['required context'])) {
+ if (!empty($plugin['required context'])
+ && !ctools_context_match_requirements($contexts, $plugin['required context'])
+ ) {
continue;
}
$plugins[$id] = $plugin;
@@ -1400,17 +1860,19 @@ function ctools_get_relevant_access_plugins($contexts) {
* Create a context for the logged in user.
*/
function ctools_access_get_loggedin_context() {
- global $user;
- $context = ctools_context_create('entity:user', $user);
+ $context = ctools_context_create('entity:user', array('type' => 'current'), TRUE);
$context->identifier = t('Logged in user');
- $context->keyword = 'viewer';
- $context->id = 0;
+ $context->keyword = 'viewer';
+ $context->id = 0;
return $context;
}
/**
* Get a summary of an access plugin's settings.
+ *
+ * @return string
+ * The summary text.
*/
function ctools_access_summary($plugin, $contexts, $test) {
if (!isset($contexts['logged-in-user'])) {
@@ -1420,8 +1882,9 @@ function ctools_access_summary($plugin, $contexts, $test) {
$description = '';
if ($function = ctools_plugin_get_function($plugin, 'summary')) {
$required_context = isset($plugin['required context']) ? $plugin['required context'] : array();
- $context = isset($test['context']) ? $test['context'] : array();
- $description = $function($test['settings'], ctools_context_select($contexts, $required_context, $context), $plugin);
+ $context = isset($test['context']) ? $test['context'] : array();
+ $selected_context = ctools_context_select($contexts, $required_context, $context);
+ $description = $function($test['settings'], $selected_context, $plugin);
}
if (!empty($test['not'])) {
@@ -1433,10 +1896,23 @@ function ctools_access_summary($plugin, $contexts, $test) {
/**
* Get a summary of a group of access plugin's settings.
+ *
+ * @param $access
+ * An array of settings theoretically set by the user, including the array
+ * of plugins to check:
+ * - 'plugins': the array of plugin metadata info to check
+ * - 'logic': (optional) either 'and' or 'or', indicating how to combine
+ * restrictions. Defaults to 'or'.
+ * @param array $contexts
+ * An array of zero or more contexts that may be used to determine if
+ * the user has access.
+ *
+ * @return string
+ * The summary text. Can be NULL if there are no plugins defined.
*/
function ctools_access_group_summary($access, $contexts) {
- if (empty($access['plugins'])) {
- return;
+ if (empty($access['plugins']) || !is_array($access['plugins'])) {
+ return NULL;
}
$descriptions = array();
@@ -1445,21 +1921,29 @@ function ctools_access_group_summary($access, $contexts) {
$descriptions[] = ctools_access_summary($plugin, $contexts, $test);
}
- $separator = (isset($access['logic']) && $access['logic'] == 'and') ? t(', and ') : t(', or ');
+ $separator =
+ (isset($access['logic']) && $access['logic'] === 'and')
+ ? t(', and ') : t(', or ');
return implode($separator, $descriptions);
}
/**
- * Determine if the current user has access via plugin.
+ * Determine if the current user has access via a plugin.
*
- * @param $settings
- * An array of settings theoretically set by the user.
- * @param $contexts
+ * @param array $settings
+ * An array of settings theoretically set by the user, including the array
+ * of plugins to check:
+ * - 'plugins': the array of plugin metadata info to check
+ * - 'logic': (optional) either 'and' or 'or', indicating how to combine
+ * restrictions. The 'or' case is not fully implemented and returns the
+ * input contexts unchanged.
+ *
+ * @param array $contexts
* An array of zero or more contexts that may be used to determine if
* the user has access.
*
- * @return
- * TRUE if access is granted, false if otherwise.
+ * @return bool
+ * TRUE if access is granted, FALSE if otherwise.
*/
function ctools_access($settings, $contexts = array()) {
if (empty($settings['plugins'])) {
@@ -1498,15 +1982,15 @@ function ctools_access($settings, $contexts = array()) {
// Pass if 'or' and this rule passed.
return TRUE;
}
- else if (!$pass && $settings['logic'] == 'and') {
- // Fail if 'and' and htis rule failed.
+ elseif (!$pass && $settings['logic'] == 'and') {
+ // Fail if 'and' and this rule failed.
return FALSE;
}
}
// Return TRUE if logic was and, meaning all rules passed.
// Return FALSE if logic was or, meaning no rule passed.
- return $settings['logic'] == 'and';
+ return ($settings['logic'] === 'and');
}
/**
@@ -1515,7 +1999,7 @@ function ctools_access($settings, $contexts = array()) {
* @param $plugin
* The access plugin being used.
*
- * @return
+ * @return array
* A default configured test that should be placed in $access['plugins'];
*/
function ctools_access_new_test($plugin) {
@@ -1537,7 +2021,6 @@ function ctools_access_new_test($plugin) {
}
}
-
$default = NULL;
if (isset($plugin['default'])) {
$default = $plugin['default'];
@@ -1551,7 +2034,7 @@ function ctools_access_new_test($plugin) {
if (is_array($default)) {
$test['settings'] = $default;
}
- else if (function_exists($default)) {
+ elseif (function_exists($default)) {
$test['settings'] = $default();
}
else {
@@ -1565,11 +2048,23 @@ function ctools_access_new_test($plugin) {
/**
* Apply restrictions to contexts based upon the access control configured.
*
- * These restrictions allow the UI to not show content that may not
- * be relevant to all types of a particular context.
+ * These restrictions allow the UI to not show content that may not be relevant
+ * to all types of a particular context.
+ *
+ * @param array $settings
+ * Array of keys specifying the settings:
+ * - 'plugins': the array of plugin metadata info to check. If not set, or
+ * not an array, the function returns with no action.
+ * - 'logic': (optional) either 'and' or 'or', indicating how to combine
+ * restrictions. Defaults to 'and'.
+ * The 'or' case is not fully implemented and returns with no action if
+ * there is more than one plugin.
+ *
+ * @param array $contexts
+ * Array of available contexts.
*/
function ctools_access_add_restrictions($settings, $contexts) {
- if (empty($settings['plugins'])) {
+ if (empty($settings['plugins']) || !is_array($settings['plugins'])) {
return;
}
@@ -1578,17 +2073,23 @@ function ctools_access_add_restrictions($settings, $contexts) {
}
// We're not going to try to figure out restrictions on the or.
- if ($settings['logic'] == 'or' && count($settings['plugins']) > 1) {
+ if ($settings['logic'] === 'or' && count($settings['plugins']) > 1) {
return;
}
foreach ($settings['plugins'] as $test) {
$plugin = ctools_get_access_plugin($test['name']);
- if ($plugin && $function = ctools_plugin_get_function($plugin, 'restrictions')) {
+ // $plugin is 'array()' on error.
+ if ($plugin
+ && $function = ctools_plugin_get_function($plugin, 'restrictions')
+ ) {
$required_context = isset($plugin['required context']) ? $plugin['required context'] : array();
$context = isset($test['context']) ? $test['context'] : array();
$contexts = ctools_context_select($contexts, $required_context, $context);
- $function($test['settings'], $contexts);
+
+ if ($contexts !== FALSE) {
+ $function($test['settings'], $contexts);
+ }
}
}
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context.menu.inc b/sites/all/modules/contrib/dev/ctools/includes/context.menu.inc
index ee227cb..798d167 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context.menu.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context.menu.inc
@@ -25,7 +25,7 @@ function ctools_context_menu(&$items) {
'page callback' => 'ctools_context_ajax_item_delete',
) + $base;
- // For the access system
+ // For the access system.
$base['file'] = 'includes/context-access-admin.inc';
$items['ctools/context/ajax/access/add'] = array(
'page callback' => 'ctools_access_ajax_add',
diff --git a/sites/all/modules/contrib/dev/ctools/includes/context.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/context.theme.inc
index 8f660b8..d0d866f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/context.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/context.theme.inc
@@ -19,7 +19,6 @@ function ctools_context_theme(&$theme) {
);
$theme['ctools_context_item_form'] = array(
'render element' => 'form',
-// 'variables' => array('form' => NULL),
'file' => 'includes/context.theme.inc',
);
$theme['ctools_context_item_row'] = array(
@@ -27,7 +26,7 @@ function ctools_context_theme(&$theme) {
'file' => 'includes/context.theme.inc',
);
- // For the access plugin
+ // For the access plugin.
$theme['ctools_access_admin_add'] = array(
'render element' => 'form',
'file' => 'includes/context-access-admin.inc',
@@ -62,10 +61,10 @@ function theme_ctools_context_item_row($vars) {
function theme_ctools_context_item_form($vars) {
$form = $vars['form'];
- $output = '';
- $type = $form['#ctools_context_type'];
- $module = $form['#ctools_context_module'];
- $cache_key = $form['#cache_key'];
+ $output = '';
+ $type = $form['#ctools_context_type'];
+ $module = $form['#ctools_context_module'];
+ $cache_key = $form['#cache_key'];
$type_info = ctools_context_info($type);
@@ -104,17 +103,17 @@ function theme_ctools_context_item_form($vars) {
if (!empty($form['buttons'])) {
// Display the add context item.
- $row = array();
- $row[] = array('data' => render($form['buttons'][$type]['item']), 'class' => array('title'));
- $row[] = array('data' => render($form['buttons'][$type]['add']), 'class' => array('add'), 'width' => "60%");
- $output .= '
';
}
if (!empty($form['description'])) {
$output .= render($form['description']);
@@ -139,7 +138,7 @@ function theme_ctools_context_list($vars) {
$description = (!empty($vars['description'])) ? $vars['description'] : NULL;
$titles = array();
$output = '';
- $count = 1;
+ $count = 1;
$contexts = ctools_context_load_contexts($object);
@@ -209,7 +208,7 @@ function theme_ctools_context_list($vars) {
}
}
- // And relationships
+ // And relationships.
if (!empty($object->relationships)) {
foreach ($object->relationships as $relationship) {
$output .= '
';
@@ -253,15 +252,15 @@ function theme_ctools_context_list($vars) {
}
/**
- * ctools_context_list() but not in a table format because tabledrag
- * won't let us have tables within tables and still drag.
+ * The ctools_context_list() function but not in a table format because
+ * tabledrag won't let us have tables within tables and still drag.
*/
function theme_ctools_context_list_no_table($vars) {
$object = $vars['object'];
ctools_add_css('context');
$titles = array();
$output = '';
- $count = 1;
+ $count = 1;
// Describe 'built in' contexts.
if (!empty($object->base_contexts)) {
foreach ($object->base_contexts as $id => $context) {
@@ -312,7 +311,7 @@ function theme_ctools_context_list_no_table($vars) {
$count++;
}
}
- // And relationships
+ // And relationships.
if (!empty($object->relationships)) {
foreach ($object->relationships as $relationship) {
$output .= '
';
@@ -341,4 +340,3 @@ function theme_ctools_context_list_no_table($vars) {
return $output;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/css-cache.inc b/sites/all/modules/contrib/dev/ctools/includes/css-cache.inc
new file mode 100644
index 0000000..d88160b
--- /dev/null
+++ b/sites/all/modules/contrib/dev/ctools/includes/css-cache.inc
@@ -0,0 +1,52 @@
+key(array('cid' => $id))
->fields(array(
- 'cid' => $id,
'filename' => $filename,
'css' => $css,
'filter' => intval($filter),
@@ -149,11 +149,11 @@ function ctools_css_clear($id) {
*
* @param $css
* A chunk of well-formed CSS text to cache.
- * @param $filter
+ * @param bool $filter
* If TRUE the css will be filtered. If FALSE the text will be cached
* as-is.
*
- * @return $filename
+ * @return string
* The filename the CSS will be cached in.
*/
function ctools_css_cache($css, $filter = TRUE) {
@@ -164,7 +164,6 @@ function ctools_css_cache($css, $filter = TRUE) {
// Create the css/ within the files folder.
$path = 'public://ctools/css';
if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
-// if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
drupal_set_message(t('Unable to create CTools CSS cache directory. Check the permissions on your files directory.'), 'error');
return;
}
@@ -172,10 +171,12 @@ function ctools_css_cache($css, $filter = TRUE) {
// @todo Is this slow? Does it matter if it is?
$filename = $path . '/' . md5($css) . '.css';
- // This will do renames if the file already exists, ensuring we don't
- // accidentally overwrite other files who share the same md5. Yes this
- // is a very miniscule chance but it's safe.
- $filename = file_unmanaged_save_data($css, $filename);
+ // Generally md5 is considered unique enough to sign file downloads.
+ // So this replaces already existing files based on the assumption that two
+ // files with the same hash are identical content wise.
+ // If we rename, the cache folder can potentially fill up with thousands of
+ // files with the same content.
+ $filename = file_unmanaged_save_data($css, $filename, FILE_EXISTS_REPLACE);
return $filename;
}
@@ -211,7 +212,7 @@ function ctools_css_filter($css, $compressed = TRUE) {
* An array of css data, as produced by @see ctools_css_disassemble()
* disassembler and the @see ctools_css_filter_css_data() filter.
*
- * @return string $css
+ * @return string
* css optimized for human viewing.
*/
function ctools_css_assemble($css_data) {
@@ -241,7 +242,7 @@ function ctools_css_assemble($css_data) {
* An array of css data, as produced by @see ctools_css_disassemble()
* disassembler and the @see ctools_css_filter_css_data() filter.
*
- * @return string $css
+ * @return string
* css optimized for use.
*/
function ctools_css_compress($css_data) {
@@ -277,7 +278,7 @@ function ctools_css_compress($css_data) {
* @param string $css
* A string containing the css to be disassembled.
*
- * @return array $disassembled_css
+ * @return array
* An array of disassembled, slightly cleaned-up/formatted css statements.
*/
function ctools_css_disassemble($css) {
@@ -383,7 +384,6 @@ function _ctools_css_disassemble_declaration($declaration) {
* An array of disassembled, filtered CSS.
*/
function ctools_css_filter_css_data($css, $allowed_properties = array(), $allowed_values = array(), $allowed_values_regex = '', $disallowed_values_regex = '') {
-//function ctools_css_filter_css_data($css, &$filtered = NULL, $allowed_properties = array(), $allowed_values = array(), $allowed_values_regex = '', $disallowed_values_regex = '') {
// Retrieve the default list of allowed properties if none is provided.
$allowed_properties = !empty($allowed_properties) ? $allowed_properties : ctools_css_filter_default_allowed_properties();
// Retrieve the default list of allowed values if none is provided.
@@ -391,19 +391,18 @@ function ctools_css_filter_css_data($css, $allowed_properties = array(), $allowe
// Define allowed values regex if none is provided.
$allowed_values_regex = !empty($allowed_values_regex) ? $allowed_values_regex : '/(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)/';
// Define disallowed url() value contents, if none is provided.
- // $disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/[url|expression]\s*\(\s*[^\s)]+?\s*\)\s*/';
$disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/(url|expression)/';
foreach ($css as $selector_str => $declaration) {
foreach ($declaration as $property => $value) {
if (!in_array($property, $allowed_properties)) {
- // $filtered['properties'][$selector_str][$property] = $value;
+ // $filtered['properties'][$selector_str][$property] = $value;.
unset($css[$selector_str][$property]);
continue;
}
$value = str_replace('!important', '', $value);
if (preg_match($disallowed_values_regex, $value) || !(in_array($value, $allowed_values) || preg_match($allowed_values_regex, $value))) {
- // $filtered['values'][$selector_str][$property] = $value;
+ // $filtered['values'][$selector_str][$property] = $value;.
unset($css[$selector_str][$property]);
continue;
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/dependent.inc b/sites/all/modules/contrib/dev/ctools/includes/dependent.inc
index 74de919..20c25de 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/dependent.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/dependent.inc
@@ -44,7 +44,7 @@
*
* A fuller example, that hides the menu title when no menu is selected:
* @code
- *function ctools_dependent_example() {
+ * function ctools_dependent_example() {
* $form = array();
* $form['menu'] = array(
* '#type' => 'fieldset',
@@ -72,12 +72,12 @@
* );
*
* return system_settings_form($form);
- *}
+ * }
* @endcode
*
* An example for hiding checkboxes using #prefix and #suffix:
* @code
- *function ctools_dependent_example_checkbox() {
+ * function ctools_dependent_example_checkbox() {
* $form = array();
* $form['object'] = array(
* '#type' => 'fieldset',
@@ -111,7 +111,7 @@
* );
*
* return system_settings_form($form);
- *}
+ * }
* @endcode
*
* Deprecated:
@@ -125,7 +125,6 @@
/**
* Process callback to add dependency to form items.
- *
*/
function ctools_dependent_process($element, &$form_state, &$form) {
return $element;
diff --git a/sites/all/modules/contrib/dev/ctools/includes/dropbutton.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/dropbutton.theme.inc
index fcdd5a3..4b95ef0 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/dropbutton.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/dropbutton.theme.inc
@@ -75,7 +75,7 @@ function theme_links__ctools_dropbutton($vars) {
if (!empty($vars['links'])) {
$is_drop_button = (count($vars['links']) > 1);
- // Add needed files
+ // Add needed files.
if ($is_drop_button) {
ctools_add_js('dropbutton');
ctools_add_css('dropbutton');
@@ -86,7 +86,7 @@ function theme_links__ctools_dropbutton($vars) {
static $id = 0;
$id++;
- // Wrapping div
+ // Wrapping div.
$class = 'ctools-no-js';
$class .= ($is_drop_button) ? ' ctools-dropbutton' : '';
$class .= ' ctools-button';
@@ -98,21 +98,22 @@ function theme_links__ctools_dropbutton($vars) {
$output .= '
';
- // Add a twisty if this is a dropbutton
+ // Add a twisty if this is a dropbutton.
if ($is_drop_button) {
$vars['title'] = ($vars['title'] ? check_plain($vars['title']) : t('open'));
$output .= '
';
}
- // The button content
+ // The button content.
$output .= '
';
// Check for attributes. theme_links expects an array().
@@ -132,12 +133,11 @@ function theme_links__ctools_dropbutton($vars) {
// Call theme_links to render the list of links.
$output .= theme_links(array('links' => $vars['links'], 'attributes' => $vars['attributes'], 'heading' => ''));
- $output .= '
'; // ctools-content
- $output .= '
'; // ctools-dropbutton
+ $output .= ''; // ctools-content.
+ $output .= ''; // ctools-dropbutton.
return $output;
}
else {
return '';
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/dropdown.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/dropdown.theme.inc
index 7e748f5..b763687 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/dropdown.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/dropdown.theme.inc
@@ -44,20 +44,21 @@ function ctools_dropdown_theme(&$items) {
/**
* Create a dropdown menu.
*
- * @param $title
- * The text to place in the clickable area to activate the dropdown.
- * @param $links
- * A list of links to provide within the dropdown, suitable for use
- * in via Drupal's theme('links').
- * @param $image
- * If true, the dropdown link is an image and will not get extra decorations
- * that a text dropdown link will.
- * @param $class
- * An optional class to add to the dropdown's container div to allow you
- * to style a single dropdown however you like without interfering with
- * other dropdowns.
+ * @param array $variables
+ * An associative array containing:
+ * - title: The text to place in the clickable area to activate the dropdown.
+ * - links: A list of links to provide within the dropdown, suitable for use
+ * in via Drupal's theme('links').
+ * - image: If true, the dropdown link is an image and will not get extra
+ * decorations that a text dropdown link will.
+ * - class: An optional class to add to the dropdown's container div to allow
+ * you to style a single dropdown however you like without interfering with
+ * other dropdowns.
+ *
+ * @return string
+ * Returns HTML for a language configuration form.
*/
-function theme_ctools_dropdown($vars) {
+function theme_ctools_dropdown($vars) {
// Provide a unique identifier for every dropdown on the page.
static $id = 0;
$id++;
@@ -67,9 +68,7 @@ function theme_ctools_dropdown($vars) {
ctools_add_js('dropdown');
ctools_add_css('dropdown');
- $output = '';
-
- $output .= '
'; // dropdown
+ $output .= '';
+ $output .= '';
+ $output .= '';
+
return $output;
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/entity-access.inc b/sites/all/modules/contrib/dev/ctools/includes/entity-access.inc
new file mode 100644
index 0000000..69f2c33
--- /dev/null
+++ b/sites/all/modules/contrib/dev/ctools/includes/entity-access.inc
@@ -0,0 +1,154 @@
+nid);
+ if ($node->vid !== $default_revision->vid) {
+ return _node_revision_access($node, $op, $account);
+ }
+ else {
+ return node_access($op, $node, $account);
+ }
+ }
+ // No node is provided. Check for access to all nodes.
+ if (user_access('bypass node access', $account)) {
+ return TRUE;
+ }
+ if (!user_access('access content', $account)) {
+ return FALSE;
+ }
+ if ($op == 'view' && node_access_view_all_nodes($account)) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * Access callback for the user entity.
+ */
+function ctools_metadata_user_access($op, $entity = NULL, $account = NULL, $entity_type) {
+ $account = isset($account) ? $account : $GLOBALS['user'];
+ // Grant access to the users own user account and to the anonymous one.
+ if (isset($entity) && $op != 'delete' && (($entity->uid == $account->uid && $entity->uid) || (!$entity->uid && $op == 'view'))) {
+ return TRUE;
+ }
+ if (user_access('administer users', $account) || user_access('access user profiles', $account) && $op == 'view' && $entity->status) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * Access callback for the comment entity.
+ */
+function ctools_metadata_comment_access($op, $entity = NULL, $account = NULL) {
+ // When determining access to a comment, if comment has an associated node,
+ // the user must be able to view the node in order to access the comment.
+ if (isset($entity->nid)) {
+ if (!node_access('view', node_load($entity->nid), $account)) {
+ return FALSE;
+ }
+ }
+
+ // Comment administrators are allowed to perform all operations on all
+ // comments.
+ if (user_access('administer comments', $account)) {
+ return TRUE;
+ }
+
+ // Unpublished comments can never be accessed by non-admins.
+ if (isset($entity->status) && $entity->status == COMMENT_NOT_PUBLISHED) {
+ return FALSE;
+ }
+
+ if (user_access('access comments', $account) && $op == 'view') {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * Access callback for the taxonomy entities.
+ */
+function ctools_metadata_taxonomy_access($op, $entity = NULL, $account = NULL, $entity_type) {
+ if ($entity_type == 'taxonomy_vocabulary') {
+ return user_access('administer taxonomy', $account);
+ }
+ if (user_access('administer taxonomy', $account) || user_access('access content', $account) && $op == 'view') {
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/export-ui.inc b/sites/all/modules/contrib/dev/ctools/includes/export-ui.inc
index 16e57d6..72e5a2f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/export-ui.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/export-ui.inc
@@ -81,7 +81,6 @@ function ctools_export_ui_process(&$plugin, $info) {
// Add some default fields that appear often in exports
// If these use different keys they can easily be specified in the
// $plugin.
-
if (empty($plugin['export']['admin_title']) && !empty($schema['fields']['admin_title'])) {
$plugin['export']['admin_title'] = 'admin_title';
}
@@ -297,7 +296,6 @@ function ctools_export_ui_process(&$plugin, $info) {
);
// Define strings.
-
// For all strings, %title may be filled in at a later time via str_replace
// since we do not know the title now.
$plugin['strings'] += array(
@@ -335,7 +333,7 @@ function ctools_export_ui_process(&$plugin, $info) {
$plugin['strings']['confirmation']['delete'] += array(
'question' => t('Are you sure you want to delete %title?'),
- 'information' => t('This action will permanently remove this item from your database..'),
+ 'information' => t('This action will permanently remove this item from your database.'),
'success' => t('The item has been deleted.'),
);
@@ -414,6 +412,7 @@ function ctools_export_ui_plugin_base_path($plugin) {
* The id in the menu items from the plugin.
* @param $export_key
* The export key of the item being edited, if it exists.
+ *
* @return
* The menu path to the plugin's list.
*/
@@ -429,12 +428,11 @@ function ctools_export_ui_plugin_menu_path($plugin, $item_id, $export_key = NULL
* Helper function to include CTools plugins and get an export-ui exportable.
*
* @param $plugin_name
- * The plugin that should be laoded.
+ * The plugin that should be loaded.
*/
function ctools_get_export_ui($plugin_name) {
ctools_include('plugins');
return ctools_get_plugins('ctools', 'export_ui', $plugin_name);
-
}
/**
@@ -456,14 +454,14 @@ function ctools_export_ui_switcher_page($plugin_name, $op) {
$args = func_get_args();
$js = !empty($_REQUEST['js']);
- // Load the $plugin information
+ // Load the $plugin information.
$plugin = ctools_get_export_ui($plugin_name);
$handler = ctools_export_ui_get_handler($plugin);
if ($handler) {
$method = $op . '_page';
if (method_exists($handler, $method)) {
- // replace the first two arguments:
+ // Replace the first two arguments:
$args[0] = $js;
$args[1] = $_POST;
return call_user_func_array(array($handler, $method), $args);
diff --git a/sites/all/modules/contrib/dev/ctools/includes/export-ui.menu.inc b/sites/all/modules/contrib/dev/ctools/includes/export-ui.menu.inc
index d27bf15..0fda8c2 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/export-ui.menu.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/export-ui.menu.inc
@@ -1,5 +1,9 @@
array('handler'),
);
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/export.inc b/sites/all/modules/contrib/dev/ctools/includes/export.inc
index 0b2ef46..d2fff2f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/export.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/export.inc
@@ -4,7 +4,7 @@
* @file
* Contains code to make it easier to have exportable objects.
*
- * Documentation for exportable objects is contained in help/export.html
+ * Documentation for exportable objects is contained in help/export.html.
*/
/**
@@ -126,6 +126,7 @@ function ctools_export_crud_load_multiple($table, array $names) {
* If TRUE, the static cache of all objects will be flushed prior to
* loading all. This can be important on listing pages where items
* might have changed on the page load.
+ *
* @return
* An array of all loaded objects, keyed by the unique IDs of the export key.
*/
@@ -328,7 +329,6 @@ function ctools_export_crud_set_status($table, $object, $status) {
}
-
/**
* Enable a certain object.
*
@@ -426,7 +426,7 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
}
}
- // Build the query
+ // Build the query.
$query = db_select($table, 't__0')->fields('t__0');
$alias_count = 1;
if (!empty($schema['join'])) {
@@ -451,7 +451,7 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
if ($type == 'names') {
$query->condition($export['key'], $args, 'IN');
}
- else if ($type == 'conditions') {
+ elseif ($type == 'conditions') {
foreach ($args as $key => $value) {
if (isset($schema['fields'][$key])) {
$query->condition($key, $value);
@@ -499,7 +499,7 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
if ($defaults) {
foreach ($defaults as $object) {
if ($type == 'conditions') {
- // if this does not match all of our conditions, skip it.
+ // If this does not match all of our conditions, skip it.
foreach ($args as $key => $value) {
if (!isset($object->$key)) {
continue 2;
@@ -509,12 +509,12 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
continue 2;
}
}
- else if ($object->$key != $value) {
+ elseif ($object->$key != $value) {
continue 2;
}
}
}
- else if ($type == 'names') {
+ elseif ($type == 'names') {
if (!in_array($object->{$export['key']}, $args)) {
continue;
}
@@ -561,7 +561,6 @@ function ctools_export_load_object($table, $type = 'all', $args = array()) {
}
}
- // For conditions,
return $return;
}
@@ -807,10 +806,10 @@ function _ctools_export_get_some_defaults($table, $export, $names) {
function _ctools_export_unpack_object($schema, $data, $object = 'stdClass') {
if (is_string($object)) {
if (class_exists($object)) {
- $object = new $object;
+ $object = new $object();
}
else {
- $object = new stdClass;
+ $object = new stdClass();
}
}
@@ -873,14 +872,14 @@ function ctools_var_export($var, $prefix = '') {
$output .= $prefix . ')';
}
}
- else if (is_object($var) && get_class($var) === 'stdClass') {
+ elseif (is_object($var) && get_class($var) === 'stdClass') {
// var_export() will export stdClass objects using an undefined
// magic method __set_state() leaving the export broken. This
// workaround avoids this by casting the object as an array for
// export and casting it back to an object when evaluated.
$output = '(object) ' . ctools_var_export((array) $var, $prefix);
}
- else if (is_bool($var)) {
+ elseif (is_bool($var)) {
$output = $var ? 'TRUE' : 'FALSE';
}
else {
@@ -902,7 +901,8 @@ function ctools_export_object($table, $object, $indent = '', $identifier = NULL,
$output = $indent . '$' . $identifier . ' = new ' . get_class($object) . "();\n";
if ($schema['export']['can disable']) {
- $output .= $indent . '$' . $identifier . '->disabled = FALSE; /* Edit this to true to make a default ' . $identifier . ' disabled initially */' . "\n";
+ $disabled = !isset($object->disabled) || $object->disabled != TRUE ? 'FALSE' : 'TRUE';
+ $output .= $indent . '$' . $identifier . '->disabled = ' . $disabled . '; /* Edit this to true to make a default ' . $identifier . ' disabled initially */' . "\n";
}
if (!empty($schema['export']['api']['current_version'])) {
$output .= $indent . '$' . $identifier . '->api_version = ' . $schema['export']['api']['current_version'] . ";\n";
@@ -945,14 +945,20 @@ function ctools_export_object($table, $object, $indent = '', $identifier = NULL,
else {
$value = $object->$field;
if ($info['type'] == 'int') {
- $value = (isset($info['size']) && $info['size'] == 'tiny') ? (bool) $value : (int) $value;
+ if (isset($info['size']) && $info['size'] == 'tiny') {
+ $info['boolean'] = (!isset($info['boolean'])) ? $schema['export']['boolean'] : $info['boolean'];
+ $value = ($info['boolean']) ? (bool) $value : (int) $value;
+ }
+ else {
+ $value = (int) $value;
+ }
}
$output .= $indent . '$' . $identifier . '->' . $field . ' = ' . ctools_var_export($value, $indent) . ";\n";
}
}
- // And bottom additions here
+ // And bottom additions here.
foreach ($additions2 as $field => $value) {
$output .= $indent . '$' . $identifier . '->' . $field . ' = ' . ctools_var_export($value, $indent) . ";\n";
}
@@ -967,7 +973,12 @@ function ctools_export_object($table, $object, $indent = '', $identifier = NULL,
* that it's easily available.
*/
function ctools_export_get_schema($table) {
- $cache = &drupal_static(__FUNCTION__);
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['cache'] = &drupal_static(__FUNCTION__);
+ }
+ $cache = &$drupal_static_fast['cache'];
+
if (empty($cache[$table])) {
$schema = drupal_get_schema($table);
@@ -975,7 +986,7 @@ function ctools_export_get_schema($table) {
// simply hasn't been cached. If we've been asked, let's force the
// issue.
if (!$schema || empty($schema['export'])) {
- // force a schema reset:
+ // Force a schema reset:
$schema = drupal_get_schema($table, TRUE);
}
@@ -987,7 +998,7 @@ function ctools_export_get_schema($table) {
return array();
}
- // Add some defaults
+ // Add some defaults.
$schema['export'] += array(
'key' => 'name',
'key name' => 'Name',
@@ -1003,6 +1014,7 @@ function ctools_export_get_schema($table) {
'cache defaults' => FALSE,
'default cache bin' => 'cache',
'export type string' => 'type',
+ 'boolean' => TRUE,
);
// If the export definition doesn't have the "primary key" then the CRUD
@@ -1094,7 +1106,7 @@ function ctools_export_set_object_status($object, $new_status = TRUE) {
$export = $schema['export'];
$status = variable_get($export['status'], array());
- // Compare
+ // Compare.
if (!$new_status && $object->export_type & EXPORT_IN_DATABASE) {
unset($status[$object->{$export['key']}]);
}
@@ -1137,12 +1149,12 @@ function ctools_export_new_object($table, $set_defaults = TRUE) {
$schema = ctools_export_get_schema($table);
$export = $schema['export'];
- $object = new $export['object'];
+ $object = new $export['object']();
foreach ($schema['fields'] as $field => $info) {
if (isset($info['object default'])) {
$object->$field = $info['object default'];
}
- else if (isset($info['default'])) {
+ elseif (isset($info['default'])) {
$object->$field = $info['default'];
}
else {
@@ -1167,11 +1179,11 @@ function ctools_export_new_object($table, $set_defaults = TRUE) {
function ctools_export_to_hook_code(&$code, $table, $names = array(), $name = 'foo') {
$schema = ctools_export_get_schema($table);
$export = $schema['export'];
- // Use the schema-specified function for generating hook code, if one exists
+ // Use the schema-specified function for generating hook code, if one exists.
if (function_exists($export['to hook code callback'])) {
$output = $export['to hook code callback']($names, $name);
}
- // Otherwise, the following code generates basic hook code
+ // Otherwise, the following code generates basic hook code.
else {
$output = ctools_export_default_to_hook_code($schema, $table, $names, $name);
}
@@ -1215,7 +1227,7 @@ function ctools_export_default_to_hook_code($schema, $table, $names, $name) {
$output .= " \${$export['identifier']}s = array();\n\n";
foreach ($objects as $object) {
$output .= ctools_export_crud_export($table, $object, ' ');
- $output .= " \${$export['identifier']}s['" . check_plain($object->$export['key']) . "'] = \${$export['identifier']};\n\n";
+ $output .= " \${$export['identifier']}s['" . check_plain($object->{$export['key']}) . "'] = \${$export['identifier']};\n\n";
}
$output .= " return \${$export['identifier']}s;\n";
$output .= "}\n";
@@ -1223,6 +1235,7 @@ function ctools_export_default_to_hook_code($schema, $table, $names, $name) {
return $output;
}
+
/**
* Default function for listing bulk exportable objects.
*/
diff --git a/sites/all/modules/contrib/dev/ctools/includes/fields.inc b/sites/all/modules/contrib/dev/ctools/includes/fields.inc
index 162262c..0d3256f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/fields.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/fields.inc
@@ -5,7 +5,6 @@
* Extend core fields with some helper functions to reduce code complexity within views and ctools plugins.
*/
-
/**
* Fake an instance of a field.
*
@@ -75,14 +74,30 @@ function ctools_fields_get_field_formatter_settings_form($field, $formatter_type
$conf['formatter_settings'] += $formatter['settings'];
}
$function = $formatter['module'] . '_field_formatter_settings_form';
+
+ $instance = ctools_fields_fake_field_instance($field['field_name'], $view_mode, $formatter_type, $conf['formatter_settings']);
if (function_exists($function)) {
- $instance = ctools_fields_fake_field_instance($field['field_name'], $view_mode, $formatter_type, $conf['formatter_settings']);
$settings_form = $function($field, $instance, $view_mode, $form, $form_state);
- if ($settings_form) {
- $form['ctools_field_list']['#value'][] = $field;
- $form += $settings_form;
- }
}
+ if (empty($settings_form)) {
+ $settings_form = array();
+ }
+
+ // Allow other modules to alter the formatter settings form.
+ $context = array(
+ 'module' => $formatter['module'],
+ 'formatter' => $formatter,
+ 'field' => $field,
+ 'instance' => $instance,
+ 'view_mode' => $view_mode,
+ 'form' => $form,
+ 'form_state' => $form_state,
+ );
+ drupal_alter('field_formatter_settings_form', $settings_form, $context);
+
+ $settings_form['#tree'] = TRUE;
+ $form['ctools_field_list']['#value'][] = $field;
+ $form += $settings_form;
if (isset($field['cardinality']) && $field['cardinality'] != 1) {
list($prefix, $suffix) = explode('@count', t('Skip the first @count item(s)'));
@@ -124,7 +139,7 @@ function ctools_fields_get_field_formatter_settings_form($field, $formatter_type
*/
function ctools_fields_get_field_formatter_info($fields) {
$info = array();
- $field_info = module_invoke_all('field_formatter_info');
+ $field_info = field_info_formatter_types();
foreach ($fields as $field) {
foreach ($field_info as $format_name => $formatter_info) {
if (in_array($field['type'], $formatter_info['field types'])) {
@@ -132,7 +147,6 @@ function ctools_fields_get_field_formatter_info($fields) {
}
}
}
- drupal_alter('field_formatter_info', $info);
return $info;
}
@@ -196,15 +210,15 @@ function ctools_field_label($field_name) {
* - Otherwise NULL.
* @param $options
* An associative array of additional options, with the following keys:
- * - 'field_name': The name of the field whose operation should be
+ * - 'field_name': The name of the field whose operation should be
* invoked. By default, the operation is invoked on all the fields
* in the entity's bundle. NOTE: This option is not compatible with
* the 'deleted' option; the 'field_id' option should be used
* instead.
- * - 'field_id': The id of the field whose operation should be
+ * - 'field_id': The id of the field whose operation should be
* invoked. By default, the operation is invoked on all the fields
* in the entity's' bundles.
- * - 'default': A boolean value, specifying which implementation of
+ * - 'default': A boolean value, specifying which implementation of
* the operation should be invoked.
* - if FALSE (default), the field types implementation of the operation
* will be invoked (hook_field_[op])
@@ -212,10 +226,10 @@ function ctools_field_label($field_name) {
* will be invoked (field_default_[op])
* Internal use only. Do not explicitely set to TRUE, but use
* _field_invoke_default() instead.
- * - 'deleted': If TRUE, the function will operate on deleted fields
+ * - 'deleted': If TRUE, the function will operate on deleted fields
* as well as non-deleted fields. If unset or FALSE, only
* non-deleted fields are operated on.
- * - 'language': A language code or an array of language codes keyed by field
+ * - 'language': A language code or an array of language codes keyed by field
* name. It will be used to narrow down to a single value the available
* languages to act on.
*
@@ -328,7 +342,7 @@ function ctools_field_foreign_keys($field_name) {
$foreign_keys[$field_name] = $field['foreign keys'];
}
else {
- // try to fetch foreign keys from schema, as not everything
+ // Try to fetch foreign keys from schema, as not everything
// stores foreign keys properly in the field info.
$module = $field['module'];
diff --git a/sites/all/modules/contrib/dev/ctools/includes/jump-menu.inc b/sites/all/modules/contrib/dev/ctools/includes/jump-menu.inc
index a5f99aa..e2ae1cf 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/jump-menu.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/jump-menu.inc
@@ -8,7 +8,6 @@
* if javascript is in use. Each item is keyed to the href that the button
* should go to. With javascript, the page is immediately redirected. Without
* javascript, the form is submitted and a drupal_goto() is given.
- *
*/
/**
@@ -51,7 +50,7 @@ function ctools_jump_menu($form, &$form_state, $select, $options = array()) {
'hide' => TRUE,
);
- ctools_add_js('jump-menu');
+ $form['#attached']['js'][] = ctools_attach_js('jump-menu');
if (!empty($options['choose'])) {
$select = array('' => $options['choose']) + $select;
@@ -127,7 +126,7 @@ function ctools_jump_menu_submit($form, &$form_state) {
// This allows duplicate paths to be used in jump menus for multiple options.
$redirect_array = explode("::", $form_state['values']['jump']);
- if(isset($redirect_array[1]) && !empty($redirect_array[1])){
+ if (isset($redirect_array[1]) && !empty($redirect_array[1])) {
$redirect = $redirect_array[1];
}
else {
diff --git a/sites/all/modules/contrib/dev/ctools/includes/language.inc b/sites/all/modules/contrib/dev/ctools/includes/language.inc
index 9a7850b..a850670 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/language.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/language.inc
@@ -1,5 +1,9 @@
t("Current user's language"),
@@ -41,4 +44,4 @@ function ctools_language_list_all() {
);
$languages = array_merge($languages, ctools_language_list());
return $languages;
-}
\ No newline at end of file
+}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/math-expr.inc b/sites/all/modules/contrib/dev/ctools/includes/math-expr.inc
index beffb93..d82281e 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/math-expr.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/math-expr.inc
@@ -99,7 +99,10 @@ class ctools_math_expr {
'sqrt','abs','ln','log',
'time', 'ceil', 'floor', 'min', 'max', 'round');
- function ctools_math_expr() {
+ /**
+ * ctools_math_expr constructor.
+ */
+ function __construct() {
// make the variables a little more accurate
$this->v['pi'] = pi();
$this->v['e'] = exp(1);
@@ -271,7 +274,7 @@ class ctools_math_expr {
} elseif (in_array($op, $ops) and !$expecting_op) {
return $this->trigger("unexpected operator '$op'");
} else { // I don't even want to know what you did to get here
- return $this->trigger("an unexpected error occured");
+ return $this->trigger("an unexpected error occurred");
}
if ($index == strlen($expr)) {
if (in_array($op, $ops)) { // did we end with an operator? bad.
diff --git a/sites/all/modules/contrib/dev/ctools/includes/modal.inc b/sites/all/modules/contrib/dev/ctools/includes/modal.inc
index dfde0ac..18b216f 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/modal.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/modal.inc
@@ -55,9 +55,9 @@ function ctools_modal_add_js() {
'alt' => t('Close window'),
)),
'throbber' => theme('image', array(
- 'path' => ctools_image_path('throbber.gif'),
- 'title' => t('Loading...'),
- 'alt' => t('Loading'),
+ 'path' => ctools_image_path('throbber.gif'),
+ 'title' => t('Loading...'),
+ 'alt' => t('Loading'),
)),
),
);
@@ -66,6 +66,7 @@ function ctools_modal_add_js() {
drupal_add_library('system', 'jquery.form');
drupal_add_library('system', 'drupal.progress');
drupal_add_library('system', 'drupal.ajax');
+ drupal_add_library('system', 'ui');
ctools_add_js('modal');
ctools_add_css('modal');
@@ -84,7 +85,7 @@ function ctools_modal_add_plugin_js($plugins) {
if (file_exists($file)) {
$js[$file] = TRUE;
}
- else if (file(exists($subtype['path'] . '/' . $file))) {
+ elseif (file(exists($subtype['path'] . '/' . $file))) {
$js[$subtype['path'] . '/' . $file] = TRUE;
}
}
@@ -94,7 +95,7 @@ function ctools_modal_add_plugin_js($plugins) {
if (file_exists($file)) {
$css[$file] = TRUE;
}
- else if (file(exists($subtype['path'] . '/' . $file))) {
+ elseif (file(exists($subtype['path'] . '/' . $file))) {
$css[$subtype['path'] . '/' . $file] = TRUE;
}
}
@@ -139,7 +140,7 @@ function ctools_modal_command_dismiss() {
}
/**
- * Display loading screen in the modal
+ * Display loading screen in the modal.
*/
function ctools_modal_command_loading() {
return array(
@@ -187,18 +188,32 @@ function ctools_modal_text_button($text, $dest, $alt, $class = '') {
/**
* Wrap a form so that we can use it properly with AJAX. Essentially if the
* form wishes to render, it automatically does that, otherwise it returns
- * so we can see submission results.
+ * the render array so we can see submission results.
*
- * @return
+ * @param array $form
+ * An associative array containing the structure of the form.
+ * @param array $form_state
+ * An associative array containing the current state of the form.
+ * If the 'reset_html_ids' key is set to TRUE, it will prevent HTML IDs in
+ * forms from being incremented.
+ *
+ * @return mixed
* The output of the form, if it was rendered. If $form_state['ajax']
* is set, this will use ctools_modal_form_render so it will be
* a $command object suitable for ajax_render already.
*
- * The return will be NULL if the form was successfully submitted unless
- * you specifically set re_render = TRUE. If ajax is set the
- * form will never be redirected.
+ * If the form was not rendered, the raw render array will be returned.
+ *
+ * If ajax is set the form will never be redirected.
*/
function ctools_modal_form_wrapper($form_id, &$form_state) {
+ // Since this will run again on form rebuild while still in the modal, prevent
+ // form IDs from being incremented.
+ // @todo https://drupal.org/node/1305882
+ if (!empty($form_state['reset_html_ids']) && !empty($_POST['ajax_html_ids'])) {
+ unset($_POST['ajax_html_ids']);
+ }
+
// This won't override settings already in.
$form_state += array(
're_render' => FALSE,
@@ -206,8 +221,8 @@ function ctools_modal_form_wrapper($form_id, &$form_state) {
);
$output = drupal_build_form($form_id, $form_state);
- if (!empty($form_state['ajax']) && (!$form_state['executed'] || $form_state['rebuild'])) {
- return ctools_modal_form_render($form_state, $output);
+ if (!empty($form_state['ajax']) && (!$form_state['executed'] || $form_state['rebuild'])) {
+ return ctools_modal_form_render($form_state, $output);
}
return $output;
diff --git a/sites/all/modules/contrib/dev/ctools/includes/object-cache.inc b/sites/all/modules/contrib/dev/ctools/includes/object-cache.inc
index 29225b0..ef52f9a 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/object-cache.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/object-cache.inc
@@ -27,6 +27,7 @@
* defaults to session_id().
*
* @deprecated $skip_cache is deprecated in favor of drupal_static*
+ *
* @return
* The data that was cached.
*/
@@ -42,8 +43,11 @@ function ctools_object_cache_get($obj, $name, $skip_cache = FALSE, $sid = NULL)
}
if (!array_key_exists($key, $cache)) {
- $data = db_query('SELECT * FROM {ctools_object_cache} WHERE sid = :session_id AND obj = :object AND name = :name', array(':session_id' => $sid, ':object' => $obj, ':name' => $name))
- ->fetchObject();
+ $data = db_query('SELECT * FROM {ctools_object_cache} WHERE sid = :session_id AND obj = :object AND name = :name', array(
+ ':session_id' => $sid,
+ ':object' => $obj,
+ ':name' => md5($name),
+ ))->fetchObject();
if ($data) {
$cache[$key] = unserialize($data->data);
}
@@ -83,7 +87,7 @@ function ctools_object_cache_set($obj, $name, $cache, $sid = NULL) {
->fields(array(
'sid' => $sid,
'obj' => $obj,
- 'name' => $name,
+ 'name' => md5($name),
'data' => serialize($cache),
'updated' => REQUEST_TIME,
))
@@ -91,7 +95,7 @@ function ctools_object_cache_set($obj, $name, $cache, $sid = NULL) {
}
/**
- * Remove an object from the non-volatile ctools cache
+ * Remove an object from the non-volatile ctools cache.
*
* @param $obj
* A 128 character or less string to define what kind of object is being
@@ -103,7 +107,6 @@ function ctools_object_cache_set($obj, $name, $cache, $sid = NULL) {
* defaults to session_id().
*/
function ctools_object_cache_clear($obj, $name, $sid = NULL) {
-
if (!$sid) {
$sid = session_id();
}
@@ -111,13 +114,12 @@ function ctools_object_cache_clear($obj, $name, $sid = NULL) {
db_delete('ctools_object_cache')
->condition('sid', $sid)
->condition('obj', $obj)
- ->condition('name', $name)
+ ->condition('name', md5($name))
->execute();
// Ensure the static cache is emptied of this obj:name set.
drupal_static_reset('ctools_object_cache_get');
}
-
/**
* Determine if another user has a given object cached.
*
@@ -142,8 +144,11 @@ function ctools_object_cache_test($obj, $name, $sid = NULL) {
$sid = session_id();
}
- return db_query('SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid <> :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC', array(':session_id' => $sid, ':obj' => $obj, ':name' => $name))
- ->fetchObject();
+ return db_query('SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid <> :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC', array(
+ ':session_id' => $sid,
+ ':obj' => $obj,
+ ':name' => md5($name),
+ ))->fetchObject();
}
/**
@@ -162,6 +167,7 @@ function ctools_object_cache_test($obj, $name, $sid = NULL) {
* An array of objects containing the UID and updated date for each name found.
*/
function ctools_object_cache_test_objects($obj, $names) {
+ array_walk($names, 'md5');
return db_query("SELECT c.name, s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE c.obj = :obj AND c.name IN (:names) ORDER BY c.updated ASC", array(':obj' => $obj, ':names' => $names))
->fetchAllAssoc('name');
}
@@ -180,7 +186,7 @@ function ctools_object_cache_test_objects($obj, $names) {
function ctools_object_cache_clear_all($obj, $name) {
db_delete('ctools_object_cache')
->condition('obj', $obj)
- ->condition('name', $name)
+ ->condition('name', md5($name))
->execute();
// Ensure the static cache is emptied of this obj:name set.
$cache = &drupal_static('ctools_object_cache_get', array());
@@ -197,7 +203,8 @@ function ctools_object_cache_clear_all($obj, $name) {
*/
function ctools_object_cache_clean($age = NULL) {
if (empty($age)) {
- $age = 86400 * 7; // 7 days
+ // 7 days.
+ $age = 86400 * 7;
}
db_delete('ctools_object_cache')
->condition('updated', REQUEST_TIME - $age, '<')
diff --git a/sites/all/modules/contrib/dev/ctools/includes/page-wizard.inc b/sites/all/modules/contrib/dev/ctools/includes/page-wizard.inc
index a211361..9690aae 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/page-wizard.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/page-wizard.inc
@@ -1,5 +1,9 @@
plugin = $plugin;
if ($function = ctools_plugin_get_function($plugin, 'default cache')) {
$function($cache);
diff --git a/sites/all/modules/contrib/dev/ctools/includes/plugins-admin.inc b/sites/all/modules/contrib/dev/ctools/includes/plugins-admin.inc
index d4ead0a..c11fcfd 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/plugins-admin.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/plugins-admin.inc
@@ -10,6 +10,7 @@
*
* Implementing this
*/
+
/**
* Get a plugin configuration form.
*
@@ -100,7 +101,7 @@ function _ctools_plugin_configure_create_form_info(&$form_info, $plugin_definiti
if (empty($plugin_definition['title'])) {
$title = t('Configure');
}
- else if ($op == 'add') {
+ elseif ($op == 'add') {
$title = t('Configure new !plugin_title', array('!plugin_title' => $plugin_definition['title']));
}
else {
@@ -134,10 +135,10 @@ function _ctools_plugin_configure_create_form_info(&$form_info, $plugin_definiti
$form_info['forms']['form']['wrapper'] = 'ctools_plugins_default_form_wrapper';
}
}
- else if (is_array($info)) {
- if (empty($form_info['order'])) {
- $form_info['order'] = array();
- }
+ elseif (is_array($info)) {
+ if (empty($form_info['order'])) {
+ $form_info['order'] = array();
+ }
if (empty($form_info['forms'])) {
$form_info['forms'] = array();
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/plugins.inc b/sites/all/modules/contrib/dev/ctools/includes/plugins.inc
index 0363fcb..7b53ae1 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/plugins.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/plugins.inc
@@ -2,7 +2,6 @@
/**
* @file
- *
* Contains routines to organize and load plugins. It allows a special
* variation of the hook system so that plugins can be kept in separate
* .inc files, and can be either loaded all at once or loaded only when
@@ -70,7 +69,7 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
if (isset($info['version'])) {
$version = $info['version'];
}
- else if (isset($info['api'])) {
+ elseif (isset($info['api'])) {
$version = $info['api'];
}
@@ -79,7 +78,9 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
}
// Only process if version is between minimum and current, inclusive.
- if (version_compare($version, $minimum_version, '>=') && version_compare($version, $current_version, '<=')) {
+ if (($version == $minimum_version) || ($version == $current_version)
+ || (version_compare($version, $minimum_version, '>=')
+ && version_compare($version, $current_version, '<='))) {
if (!isset($info['path'])) {
$info['path'] = drupal_get_path('module', $module);
}
@@ -97,7 +98,7 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
}
// Only process if version is between minimum and current, inclusive.
- if (version_compare($info['version'], $minimum_version, '>=') && version_compare($info['version'], $current_version, '<=')) {
+ if (version_compare($info['version'], $minimum_version, '>=') && version_compare($info['version'], $current_version, '<=')) {
if (!isset($info['path'])) {
$info['path'] = '';
}
@@ -110,7 +111,7 @@ function ctools_plugin_api_info($owner, $api, $minimum_version, $current_version
}
// Allow other modules to hook in.
- drupal_alter($hook, $cache[$owner][$api]);
+ drupal_alter($hook, $cache[$owner][$api], $owner, $api);
}
return $cache[$owner][$api];
@@ -149,7 +150,7 @@ function ctools_plugin_api_include($owner, $api, $minimum_version, $current_vers
if (isset($plugin_info["$api file"])) {
$file = $plugin_info["$api file"];
}
- else if (isset($plugin_info['file'])) {
+ elseif (isset($plugin_info['file'])) {
$file = $plugin_info['file'];
}
else {
@@ -159,7 +160,7 @@ function ctools_plugin_api_include($owner, $api, $minimum_version, $current_vers
if (file_exists(DRUPAL_ROOT . "/$plugin_info[path]/$file")) {
require_once DRUPAL_ROOT . "/$plugin_info[path]/$file";
}
- else if (file_exists(DRUPAL_ROOT . "/$file")) {
+ elseif (file_exists(DRUPAL_ROOT . "/$file")) {
require_once DRUPAL_ROOT . "/$file";
}
$already_done[$owner][$api][$module] = TRUE;
@@ -182,7 +183,7 @@ function ctools_plugin_api_get_hook($owner, $api) {
if (function_exists($function = $owner . '_' . $api . '_hook_name')) {
$hook = $function();
}
- else if (function_exists($function = $owner . '_ctools_plugin_api_hook_name')) {
+ elseif (function_exists($function = $owner . '_ctools_plugin_api_hook_name')) {
$hook = $function();
}
@@ -198,29 +199,38 @@ function ctools_plugin_api_get_hook($owner, $api) {
/**
* Fetch a group of plugins by name.
*
- * @param $module
- * The name of the module that utilizes this plugin system. It will be
- * used to call hook_ctools_plugin_$plugin() to get more data about the plugin.
- * @param $type
+ * @param string $module
+ * The name of the module that utilizes this plugin system. It will be used to
+ * get more data about the plugin as defined on hook_ctools_plugin_type().
+ * @param string $type
* The type identifier of the plugin.
- * @param $id
+ * @param string $id
* If specified, return only information about plugin with this identifier.
* The system will do its utmost to load only plugins with this id.
*
- * @return
- * An array of information arrays about the plugins received. The contents
- * of the array are specific to the plugin.
+ * @return array
+ * An array of information arrays about the plugins received. The contents of
+ * the array are specific to the plugin.
*/
function ctools_get_plugins($module, $type, $id = NULL) {
// Store local caches of plugins and plugin info so we don't have to do full
- // lookups everytime.
- $plugins = &drupal_static('ctools_plugins', array());
+ // lookups every time.
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['plugins'] = &drupal_static('ctools_plugins', array());
+ }
+ $plugins = &$drupal_static_fast['plugins'];
+
$info = ctools_plugin_get_plugin_type_info();
- // Bail out noisily if an invalid module/type combination is requested.
if (!isset($info[$module][$type])) {
- watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR);
- return array();
+ // If we don't find the plugin we attempt a cache rebuild before bailing out.
+ $info = ctools_plugin_get_plugin_type_info(TRUE);
+ // Bail out noisily if an invalid module/type combination is requested.
+ if (!isset($info[$module][$type])) {
+ watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR);
+ return array();
+ }
}
// Make sure our plugins array is populated.
@@ -228,8 +238,8 @@ function ctools_get_plugins($module, $type, $id = NULL) {
$plugins[$module][$type] = array();
}
- // Attempt to shortcut this whole piece of code if we already have
- // the requested plugin:
+ // Attempt to shortcut this whole piece of code if we already have the
+ // requested plugin:
if ($id && array_key_exists($id, $plugins[$module][$type])) {
return $plugins[$module][$type][$id];
}
@@ -247,9 +257,9 @@ function ctools_get_plugins($module, $type, $id = NULL) {
if (!empty($cache->data)) {
// Cache load succeeded so use the cached plugin list.
- $plugins[$module][$type] = $cache->data;
+ $plugins[$module][$type] = $cache->data;
// Set $setup to true so we know things where loaded.
- $setup[$module][$type] = TRUE;
+ $setup[$module][$type] = TRUE;
}
else {
// Cache load failed so store that we need to build and write the cache.
@@ -264,8 +274,8 @@ function ctools_get_plugins($module, $type, $id = NULL) {
$plugins[$module][$type] = ctools_plugin_load_hooks($info[$module][$type]);
}
- // Then see if we should load all files. We only do this if we
- // want a list of all plugins or there was a cache miss.
+ // Then see if we should load all files. We only do this if we want a list of
+ // all plugins or there was a cache miss.
if (empty($setup[$module][$type]) && ($build_cache || !$id)) {
$setup[$module][$type] = TRUE;
$plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type]));
@@ -288,9 +298,8 @@ function ctools_get_plugins($module, $type, $id = NULL) {
}
}
-
- // If we were told earlier that this is cacheable and the cache was
- // empty, give something back.
+ // If we were told earlier that this is cacheable and the cache was empty,
+ // give something back.
if ($build_cache) {
cache_set("plugins:$module:$type", $plugins[$module][$type], $info[$module][$type]['cache table']);
}
@@ -302,7 +311,7 @@ function ctools_get_plugins($module, $type, $id = NULL) {
return array_filter($plugins[$module][$type]);
}
- // Check to see if we need to look for the file
+ // Check to see if we need to look for the file.
if (!array_key_exists($id, $plugins[$module][$type])) {
// If we can have child plugins, check to see if the plugin name is in the
// format of parent:child and break it up if it is.
@@ -343,8 +352,13 @@ function ctools_get_plugins($module, $type, $id = NULL) {
* name and each inner array keyed on plugin type name.
*/
function ctools_plugin_get_plugin_type_info($flush = FALSE) {
- $info_loaded = &drupal_static('ctools_plugin_type_info_loaded', FALSE);
- $all_type_info = &drupal_static('ctools_plugin_type_info', array());
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['info_loaded'] = &drupal_static('ctools_plugin_type_info_loaded', FALSE);
+ $drupal_static_fast['all_type_info'] = &drupal_static('ctools_plugin_type_info', array());
+ }
+ $info_loaded = &$drupal_static_fast['info_loaded'];
+ $all_type_info = &$drupal_static_fast['all_type_info'];
// Only trigger info loading once.
if ($info_loaded && !$flush) {
@@ -403,40 +417,31 @@ function ctools_get_plugins_reset() {
/**
* Load plugins from a directory.
*
- * @param $info
+ * @param array $info
* The plugin info as returned by ctools_plugin_get_info()
- * @param $file
+ * @param string $filename
* The file to load if we're looking for just one particular plugin.
*
- * @return
- * An array of information created for this plugin.
+ * @return array
+ * A (possibly empty) array of information created for this plugin.
*/
function ctools_plugin_load_includes($info, $filename = NULL) {
// Keep a static array so we don't hit file_scan_directory more than necessary.
$all_files = &drupal_static(__FUNCTION__, array());
- // store static of plugin arrays for reference because they can't be reincluded.
+ // Store static of plugin arrays for reference because they can't be
+ // reincluded, so there is no point in using drupal_static().
static $plugin_arrays = array();
- // If we're being asked for all plugins of a type, skip any caching
- // we may have done because this is an admin task and it's ok to
- // spend the extra time.
- if (!isset($filename)) {
- $all_files[$info['module']][$info['type']] = NULL;
- }
-
if (!isset($all_files[$info['module']][$info['type']])) {
- // If a filename was set, we will try to load our list of files from
- // cache. This is considered normal operation and we try to reduce
- // the time spent finding files.
- if (isset($filename)) {
- $cache = cache_get("ctools_plugin_files:$info[module]:$info[type]");
- if ($cache) {
- $all_files[$info['module']][$info['type']] = $cache->data;
- }
+ $cache = cache_get("ctools_plugin_files:$info[module]:$info[type]");
+ if ($cache) {
+ $all_files[$info['module']][$info['type']] = $cache->data;
}
-
- if (!isset($all_files[$info['module']][$info['type']])) {
+ // Do not attempt any file scan even if the cached entry was empty.
+ // A NULL entry here would mean the plugin just does not exists, and we
+ // cannot afford to run file scan on production sites normal run.
+ elseif (!isset($all_files[$info['module']][$info['type']])) {
$all_files[$info['module']][$info['type']] = array();
// Load all our plugins.
$directories = ctools_plugin_get_directories($info);
@@ -460,24 +465,23 @@ function ctools_plugin_load_includes($info, $filename = NULL) {
}
foreach ($files as $file) {
if (!empty($info['info file'])) {
- // Parse a .info file
+ // Parse a .info file.
$result = ctools_plugin_process_info($info, $module, $file);
}
else {
// Parse a hook.
- $plugin = NULL; // ensure that we don't have something leftover from earlier.
+ // Ensure that we don't have something leftover from earlier.
+ $plugin = NULL;
if (isset($plugin_arrays[$file->uri])) {
$identifier = $plugin_arrays[$file->uri];
}
else {
-
- require_once DRUPAL_ROOT . '/' . $file->uri;
+ include_once DRUPAL_ROOT . '/' . $file->uri;
// .inc files have a special format for the hook identifier.
// For example, 'foo.inc' in the module 'mogul' using the plugin
- // whose hook is named 'borg_type' should have a function named (deep breath)
- // mogul_foo_borg_type()
-
+ // whose hook is named 'borg_type' should have a function named
+ // (deep breath) mogul_foo_borg_type().
// If, however, the .inc file set the quasi-global $plugin array, we
// can use that and not even call a function. Set the $identifier
// appropriately and ctools_plugin_process() will handle it.
@@ -490,7 +494,8 @@ function ctools_plugin_load_includes($info, $filename = NULL) {
}
}
- $result = ctools_plugin_process($info, $module, $identifier, dirname($file->uri), basename($file->uri), $file->name);
+ $result = ctools_plugin_process($info, $module, $identifier,
+ dirname($file->uri), basename($file->uri), $file->name);
}
if (is_array($result)) {
$plugins = array_merge($plugins, $result);
@@ -510,7 +515,7 @@ function ctools_plugin_load_includes($info, $filename = NULL) {
* @param $info
* The $info array for the plugin as returned by ctools_plugin_get_info().
*
- * @return array $directories
+ * @return array
* An array of directories to search.
*/
function ctools_plugin_get_directories($info) {
@@ -536,10 +541,9 @@ function ctools_plugin_get_directories($info) {
}
/**
- * Helper function to build a ctools-friendly list of themes capable of
- * providing plugins.
+ * Helper to build a ctools-friendly list of themes capable of providing plugins.
*
- * @return array $themes
+ * @return array
* A list of themes that can act as plugin providers, sorted parent-first with
* the active theme placed last.
*/
@@ -550,7 +554,7 @@ function _ctools_list_themes() {
$themes = $active = array();
$all_themes = list_themes();
foreach ($all_themes as $name => $theme) {
- // Only search from active themes
+ // Only search from active themes.
if (empty($theme->status) && $theme->name != $current) {
continue;
}
@@ -561,19 +565,19 @@ function _ctools_list_themes() {
}
}
- // Construct a parent-first list of all themes
+ // Construct a parent-first list of all themes.
foreach ($active as $name => $theme) {
$base_themes = isset($theme->base_themes) ? $theme->base_themes : array();
$themes = array_merge($themes, $base_themes, array($name => $theme->info['name']));
}
- // Put the actual theme info objects into the array
+ // Put the actual theme info objects into the array.
foreach (array_keys($themes) as $name) {
if (isset($all_themes[$name])) {
$themes[$name] = $all_themes[$name];
}
}
- // Make sure the current default theme always gets the last word
+ // Make sure the current default theme always gets the last word.
if ($current_key = array_search($current, array_keys($themes))) {
$themes += array_splice($themes, $current_key, 1);
}
@@ -581,7 +585,6 @@ function _ctools_list_themes() {
return $themes;
}
-
/**
* Find all the base themes for the specified theme.
*
@@ -597,9 +600,10 @@ function _ctools_list_themes() {
* The name of the theme whose base we are looking for.
* @param $used_keys
* A recursion parameter preventing endless loops.
- * @return
+ *
+ * @return array
* Returns an array of all of the theme's ancestors; the first element's value
- * will be NULL if an error occurred.
+ * will be NULL if an error occurred. (Note: this is NOT $arr[0]).
*/
function ctools_find_base_themes($themes, $key, $used_keys = array()) {
$base_key = $themes[$key]->info['base theme'];
@@ -627,7 +631,6 @@ function ctools_find_base_themes($themes, $key, $used_keys = array()) {
return $current_base_theme;
}
-
/**
* Load plugin info for the provided hook; this is handled separately from
* plugins from files.
@@ -652,22 +655,28 @@ function ctools_plugin_load_hooks($info) {
/**
* Process a single hook implementation of a ctools plugin.
*
- * @param $info
+ * @param array $info
* The $info array about the plugin as returned by ctools_plugin_get_info()
- * @param $module
+ * @param string $module
* The module that implements the plugin being processed.
- * @param $identifier
- * The plugin identifier, which is used to create the name of the hook
- * function being called.
- * @param $path
+ * @param string|array $identifier
+ * Used to create the base setting of return value. If:
+ * - $identifier is a string, a hook name is created from this and the 'hook'
+ * key of the $info array, and the return value of that hook function is
+ * used. The hook is called like this: $identifier_$hook($info);
+ * - $identifier is an array, this array is used directly.
+ * @param string $path
* The path where files utilized by this plugin will be found.
- * @param $file
+ * @param string $file
* The file that was loaded for this plugin, if it exists.
- * @param $base
+ * @param string $base
* The base plugin name to use. If a file was loaded for the plugin, this
* is the plugin to assume must be present. This is used to automatically
* translate the array to make the syntax more friendly to plugin
* implementors.
+ *
+ * @return null|array
+ * NULL on failure, otherwise an array containing the results keyed by name.
*/
function ctools_plugin_process($info, $module, $identifier, $path, $file = NULL, $base = NULL) {
if (is_array($identifier)) {
@@ -678,7 +687,7 @@ function ctools_plugin_process($info, $module, $identifier, $path, $file = NULL,
if (!function_exists($function)) {
return NULL;
}
- $result = $function();
+ $result = $function($info);
if (!isset($result) || !is_array($result)) {
return NULL;
}
@@ -735,9 +744,19 @@ function _ctools_process_data($result, $plugin_type_info, $module, $path, $file)
return $result;
}
-
/**
* Process an info file for plugin information, rather than a hook.
+ *
+ * @param array $info
+ * The $info array about the plugin as returned by ctools_plugin_get_info()
+ * @param string $module
+ * The module that implements the plugin being processed.
+ * @param object $file
+ * An object containing 'uri' and 'name' properties. 'uri' is the name of the
+ * 'info' file to process. 'name' is the plugin key-name.
+ *
+ * @return null|array
+ * NULL on failure, otherwise an array containing the results keyed by name.
*/
function ctools_plugin_process_info($info, $module, $file) {
$result = drupal_parse_info_file($file->uri);
@@ -764,7 +783,7 @@ function ctools_plugin_get_info($module, $type) {
* @param $function_name
* The identifier of the function. For example, 'settings form'.
*
- * @return
+ * @return string
* The actual name of the function to call, or NULL if the function
* does not exist.
*/
@@ -781,7 +800,7 @@ function ctools_plugin_get_function($plugin_definition, $function_name) {
}
if (!isset($plugin_definition[$function_name])) {
- return;
+ return NULL;
}
if (is_array($plugin_definition[$function_name]) && isset($plugin_definition[$function_name]['function'])) {
@@ -816,7 +835,7 @@ function ctools_plugin_get_function($plugin_definition, $function_name) {
* @param $function_name
* The identifier of the function. For example, 'settings form'.
*
- * @return
+ * @return string
* The actual name of the function to call, or NULL if the function
* does not exist.
*/
@@ -834,7 +853,7 @@ function ctools_plugin_load_function($module, $type, $id, $function_name) {
* @param $class_name
* The identifier of the class. For example, 'handler'.
*
- * @return
+ * @return string
* The actual name of the class to call, or NULL if the class does not exist.
*/
function ctools_plugin_get_class($plugin_definition, $class_name) {
@@ -853,11 +872,11 @@ function ctools_plugin_get_class($plugin_definition, $class_name) {
if (!isset($plugin_definition[$class_name])) {
return;
}
- else if (is_string($plugin_definition[$class_name])) {
+ elseif (is_string($plugin_definition[$class_name])) {
// Plugin uses the string form shorthand.
$return = $plugin_definition[$class_name];
}
- else if (isset($plugin_definition[$class_name]['class'])) {
+ elseif (isset($plugin_definition[$class_name]['class'])) {
// Plugin uses the verbose array form.
$return = $plugin_definition[$class_name]['class'];
}
@@ -879,7 +898,7 @@ function ctools_plugin_get_class($plugin_definition, $class_name) {
* @param $class_name
* The identifier of the class. For example, 'handler'.
*
- * @return
+ * @return string
* The actual name of the class to call, or NULL if the class does not exist.
*/
function ctools_plugin_load_class($module, $type, $id, $class_name) {
diff --git a/sites/all/modules/contrib/dev/ctools/includes/registry.inc b/sites/all/modules/contrib/dev/ctools/includes/registry.inc
index 9d4328e..7e517bb 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/registry.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/registry.inc
@@ -2,7 +2,6 @@
/**
* @file
- *
* Registry magic. In a separate file to minimize unnecessary code loading.
*/
diff --git a/sites/all/modules/contrib/dev/ctools/includes/stylizer.inc b/sites/all/modules/contrib/dev/ctools/includes/stylizer.inc
index 9fdc81d..488a7f3 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/stylizer.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/stylizer.inc
@@ -202,7 +202,7 @@ function ctools_stylizer_get_settings_name($settings) {
}
/**
- * Get the path where images will be stored for a given style plugin and settings.
+ * Get the path where images will be stored for a style plugin and settings.
*
* This function will make sure the path exists.
*/
@@ -249,7 +249,7 @@ class ctools_stylizer_image_processor {
if (is_string($plugin['actions']) && function_exists($plugin['actions'])) {
$actions = $plugin['actions']($plugin, $settings);
}
- else if (is_array($plugin['actions'])) {
+ elseif (is_array($plugin['actions'])) {
$actions = $plugin['actions'];
}
@@ -318,7 +318,7 @@ class ctools_stylizer_image_processor {
function command_load($name, $file) {
$this->log("New workspace: $name (from $file)");
if (!file_exists($file)) {
- // Try it relative to the plugin
+ // Try it relative to the plugin.
$file = $this->plugin['path'] . '/' . $file;
if (!file_exists($file)) {
$this->log("Unable to open $file");
@@ -336,7 +336,7 @@ class ctools_stylizer_image_processor {
}
/**
- * Create a new workspace using the properties of an existing workspace
+ * Create a new workspace using the properties of an existing workspace.
*/
function command_new_from($name, $workspace) {
$this->log("New workspace: $name from existing $workspace");
@@ -372,7 +372,7 @@ class ctools_stylizer_image_processor {
function command_merge_from($workspace, $x = 0, $y = 0) {
$this->log("Merge from: $workspace ($x, $y)");
if (empty($this->workspaces[$workspace])) {
- $this->log("Workspace $name does not exist.", 'error');
+ $this->log("Workspace $workspace does not exist.", 'error');
return;
}
@@ -382,7 +382,7 @@ class ctools_stylizer_image_processor {
function command_merge_to($workspace, $x = 0, $y = 0) {
$this->log("Merge to: $workspace ($x, $y)");
if (empty($this->workspaces[$workspace])) {
- $this->log("Workspace $name does not exist.", 'error');
+ $this->log("Workspace $workspace does not exist.", 'error');
return;
}
@@ -500,7 +500,7 @@ class ctools_stylizer_image_processor {
$palette[$luminosity_input]['green'] = $green;
$palette[$luminosity_input]['blue'] = $blue;
- // Now we complete the palette, first we'll do it tothe black, and then to
+ // Now we complete the palette, first we'll do it to the black, and then to
// the white.
// From input to black
@@ -822,7 +822,7 @@ function ctools_stylizer_add_plugin_forms(&$form_info, $plugin, $op) {
if ($op == 'add' && isset($plugin['add form'])) {
$id = $plugin['add form'];
}
- else if (isset($plugin['edit form'])) {
+ elseif (isset($plugin['edit form'])) {
$id = $plugin['edit form'];
}
else {
diff --git a/sites/all/modules/contrib/dev/ctools/includes/stylizer.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/stylizer.theme.inc
index 85346c1..0ceedff 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/stylizer.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/stylizer.theme.inc
@@ -25,4 +25,3 @@ function ctools_stylizer_theme(&$theme) {
'file' => 'includes/stylizer.inc',
);
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/utility.inc b/sites/all/modules/contrib/dev/ctools/includes/utility.inc
index 9795dd8..3c939a4 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/utility.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/utility.inc
@@ -23,22 +23,9 @@ function ctools_passthrough($module, $type, &$items) {
require_once DRUPAL_ROOT . '/' . $file->uri;
list($tool) = explode('.', $file->name, 2);
- $function = $module . '_' . str_replace ('-', '_', $tool) . '_' . str_replace('-', '_', $type);
+ $function = $module . '_' . str_replace('-', '_', $tool) . '_' . str_replace('-', '_', $type);
if (function_exists($function)) {
$function($items);
}
}
}
-
-/**
- * Implementation of hook_theme_registry_alter()
- */
-function ctools_theme_registry_alter(&$registry) {
- // Move this one last last last so it can catch changes made by modules and themes.
- $key = array_search('ctools_preprocess_page', $registry['page']['preprocess functions']);
- if ($key) {
- unset($registry['page']['preprocess functions'][$key]);
- }
- $registry['page']['preprocess functions'][] = 'ctools_preprocess_page';
-}
-
diff --git a/sites/all/modules/contrib/dev/ctools/includes/uuid.inc b/sites/all/modules/contrib/dev/ctools/includes/uuid.inc
new file mode 100644
index 0000000..f51838b
--- /dev/null
+++ b/sites/all/modules/contrib/dev/ctools/includes/uuid.inc
@@ -0,0 +1,71 @@
+ $params) {
$form_info['order'][$step_id] = $params['title'];
@@ -83,7 +83,7 @@ function ctools_wizard_multistep_form($form_info, $step, &$form_state) {
$form_info['cache location'] = 'storage';
}
- // If absolutely nothing was set for the cache area to work on
+ // If absolutely nothing was set for the cache area to work on.
if (!isset($form_state[$form_info['cache location']])) {
ctools_include('cache');
$form_state[$form_info['cache location']] = ctools_cache_get($form_info['cache mechanism'], $form_info['cache key']);
@@ -199,7 +199,7 @@ function ctools_wizard_multistep_form($form_info, $step, &$form_state) {
}
}
}
- else if (isset($form_state['ajax next'])) {
+ elseif (isset($form_state['ajax next'])) {
// Clear a few items off the form state so we don't double post:
$next = $form_state['ajax next'];
unset($form_state['ajax next']);
@@ -274,7 +274,7 @@ function ctools_wizard_wrapper($form, &$form_state) {
if (!empty($form_info['show trail'])) {
ctools_add_css('wizard');
$form['ctools_trail'] = array(
- '#markup' => theme(array('ctools_wizard_trail__' . $form_info['id'], 'ctools_wizard_trail'), array('trail' => $trail)),
+ '#markup' => theme(array('ctools_wizard_trail__' . $form_info['id'], 'ctools_wizard_trail'), array('trail' => $trail, 'form_info' => $form_info)),
'#weight' => -1000,
);
}
@@ -299,7 +299,7 @@ function ctools_wizard_wrapper($form, &$form_state) {
'#wizard type' => 'next',
'#weight' => -2000,
'#limit_validation_errors' => array(),
- // hardcode the submit so that it doesn't try to save data.
+ // Hardcode the submit so that it doesn't try to save data.
'#submit' => array('ctools_wizard_submit'),
'#attributes' => $button_attributes,
);
@@ -325,19 +325,18 @@ function ctools_wizard_wrapper($form, &$form_state) {
// end of the form list (i.e, there is a next) then it's "update and return"
// to be clear. If this is the end of the path and there is no next, we
// call it 'Finish'.
-
// Even if there is no direct return path (some forms may not want you
// leaving in the middle) the final button is always a Finish and it does
// whatever the return action is.
if (!empty($form_info['show return']) && !empty($form_state['next'])) {
$form['buttons']['return'] = array(
'#type' => 'submit',
- '#value' => $form_info['return text'],
+ '#value' => $form_info['return text'],
'#wizard type' => 'return',
'#attributes' => $button_attributes,
);
}
- else if (empty($form_state['next']) || !empty($form_info['free trail'])) {
+ elseif (empty($form_state['next']) || !empty($form_info['free trail'])) {
$form['buttons']['return'] = array(
'#type' => 'submit',
'#value' => $form_info['finish text'],
@@ -352,7 +351,7 @@ function ctools_wizard_wrapper($form, &$form_state) {
'#type' => 'submit',
'#value' => $form_info['cancel text'],
'#wizard type' => 'cancel',
- // hardcode the submit so that it doesn't try to save data.
+ // Hardcode the submit so that it doesn't try to save data.
'#limit_validation_errors' => array(),
'#submit' => array('ctools_wizard_submit'),
'#attributes' => $button_attributes,
@@ -370,7 +369,6 @@ function ctools_wizard_wrapper($form, &$form_state) {
// Set up our submit handler after theirs. Since putting something here will
// skip Drupal's autodetect, we autodetect for it.
-
// We make sure ours is after theirs so that they get to change #next if
// the want to.
$form['#submit'] = array();
@@ -398,7 +396,7 @@ function ctools_wizard_wrapper($form, &$form_state) {
$params = array($url, $options);
}
- $form['#action'] = call_user_func_array('url', $params);
+ $form['#action'] = call_user_func_array('url', $params);
}
if (isset($info['wrapper']) && function_exists($info['wrapper'])) {
@@ -418,7 +416,7 @@ function ctools_wizard_submit(&$form, &$form_state) {
if (isset($form_state['clicked_button']['#wizard type'])) {
$type = $form_state['clicked_button']['#wizard type'];
- // if AJAX enabled, we proceed slightly differently here.
+ // If AJAX enabled, we proceed slightly differently here.
if (!empty($form_state['ajax'])) {
if ($type == 'next') {
$form_state['ajax next'] = $form_state['clicked_button']['#next'];
@@ -428,7 +426,7 @@ function ctools_wizard_submit(&$form, &$form_state) {
if ($type == 'cancel' && isset($form_state['form_info']['cancel path'])) {
$form_state['redirect'] = $form_state['form_info']['cancel path'];
}
- else if ($type == 'next') {
+ elseif ($type == 'next') {
$form_state['redirect'] = ctools_wizard_get_path($form_state['form_info'], $form_state['clicked_button']['#next']);
if (!empty($_GET['destination'])) {
// We don't want drupal_goto redirect this request
@@ -437,10 +435,10 @@ function ctools_wizard_submit(&$form, &$form_state) {
unset($_GET['destination']);
}
}
- else if (isset($form_state['form_info']['return path'])) {
+ elseif (isset($form_state['form_info']['return path'])) {
$form_state['redirect'] = $form_state['form_info']['return path'];
}
- else if ($type == 'finish' && isset($form_state['form_info']['cancel path'])) {
+ elseif ($type == 'finish' && isset($form_state['form_info']['cancel path'])) {
$form_state['redirect'] = $form_state['form_info']['cancel path'];
}
}
@@ -469,10 +467,8 @@ function ctools_wizard_get_path($form_info, $step) {
if (!isset($path[1]) || !is_array($path[1])) {
$path[1] = array();
}
- // Ensure that the query part of options is an array.
- $path[1] += array('query' => array());
// Add the destination parameter, if not set already.
- $path[1]['query'] += drupal_get_destination();
+ $path[1] += drupal_get_destination();
}
return $path;
@@ -505,15 +501,15 @@ function ctools_wizard_defaults(&$form_info) {
}
$form_info = $form_info + $defaults;
- // set form callbacks if they aren't defined
+ // Set form callbacks if they aren't defined.
foreach ($form_info['forms'] as $step => $params) {
- if (!$params['form id']) {
- $form_callback = $hook . '_' . $step . '_form';
- $form_info['forms'][$step]['form id'] = $form_callback;
+ if (empty($params['form id'])) {
+ $form_callback = $hook . '_' . $step . '_form';
+ $form_info['forms'][$step]['form id'] = $form_callback;
}
}
- // set button callbacks
+ // Set button callbacks.
$callbacks = array(
'back callback' => '_back',
'next callback' => '_next',
@@ -523,10 +519,10 @@ function ctools_wizard_defaults(&$form_info) {
);
foreach ($callbacks as $key => $callback) {
- // never overwrite if explicity defined
+ // Never overwrite if explicity defined.
if (empty($form_info[$key])) {
$wizard_callback = $hook . $callback;
- if (function_exists($wizard_callback)) {
+ if (function_exists($wizard_callback)) {
$form_info[$key] = $wizard_callback;
}
}
diff --git a/sites/all/modules/contrib/dev/ctools/includes/wizard.theme.inc b/sites/all/modules/contrib/dev/ctools/includes/wizard.theme.inc
index 304906c..c1a2646 100644
--- a/sites/all/modules/contrib/dev/ctools/includes/wizard.theme.inc
+++ b/sites/all/modules/contrib/dev/ctools/includes/wizard.theme.inc
@@ -7,19 +7,16 @@
function ctools_wizard_theme(&$theme) {
$theme['ctools_wizard_trail'] = array(
- 'variables' => array('trail' => NULL),
+ 'variables' => array('trail' => NULL, 'form_info' => NULL, 'divider' => ' » '),
'file' => 'includes/wizard.theme.inc',
);
}
/**
- * Themable display of the 'breadcrumb' trail to show the order of the
- * forms.
+ * Themable display of the 'breadcrumb' trail to show the order of the forms.
*/
function theme_ctools_wizard_trail($vars) {
- $trail = $vars['trail'];
- if (!empty($trail)) {
- return '
' . implode(' » ', $trail) . '
';
+ if (!empty($vars['trail'])) {
+ return '
' . implode($vars['divider'], $vars['trail']) . '
';
}
}
-
diff --git a/sites/all/modules/contrib/dev/ctools/js/auto-submit.js b/sites/all/modules/contrib/dev/ctools/js/auto-submit.js
index a3e9aa4..b658577 100644
--- a/sites/all/modules/contrib/dev/ctools/js/auto-submit.js
+++ b/sites/all/modules/contrib/dev/ctools/js/auto-submit.js
@@ -36,9 +36,11 @@ Drupal.behaviors.CToolsAutoSubmit = {
attach: function(context) {
// 'this' references the form element
function triggerSubmit (e) {
- var $this = $(this);
- if (!$this.hasClass('ctools-ajaxing')) {
- $this.find('.ctools-auto-submit-click').click();
+ if ($.contains(document.body, this)) {
+ var $this = $(this);
+ if (!$this.hasClass('ctools-ajaxing')) {
+ $this.find('.ctools-auto-submit-click').click();
+ }
}
}
diff --git a/sites/all/modules/contrib/dev/ctools/js/collapsible-div.js b/sites/all/modules/contrib/dev/ctools/js/collapsible-div.js
index da9bff9..134151c 100644
--- a/sites/all/modules/contrib/dev/ctools/js/collapsible-div.js
+++ b/sites/all/modules/contrib/dev/ctools/js/collapsible-div.js
@@ -212,6 +212,7 @@
content.slideToggle(100, afterToggle);
}
+ $container.toggleClass('ctools-collapsed');
toggle.toggleClass('ctools-toggle-collapsed');
// If we're supposed to remember the state of this class, do so.
diff --git a/sites/all/modules/contrib/dev/ctools/js/dependent.js b/sites/all/modules/contrib/dev/ctools/js/dependent.js
index e9e2447..a60fc12 100644
--- a/sites/all/modules/contrib/dev/ctools/js/dependent.js
+++ b/sites/all/modules/contrib/dev/ctools/js/dependent.js
@@ -40,7 +40,7 @@
Drupal.CTools.dependent.autoAttach = function() {
// Clear active bindings and triggers.
for (i in Drupal.CTools.dependent.activeTriggers) {
- $(Drupal.CTools.dependent.activeTriggers[i]).unbind('change');
+ $(Drupal.CTools.dependent.activeTriggers[i]).unbind('change.ctools-dependent');
}
Drupal.CTools.dependent.activeTriggers = [];
Drupal.CTools.dependent.activeBindings = {};
@@ -97,7 +97,13 @@
else {
switch ($(trigger).attr('type')) {
case 'checkbox':
- var val = $(trigger).attr('checked') ? true : false;
+ // **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute
+ if ($().prop) {
+ var val = $(trigger).prop('checked') ? true : false;
+ }
+ else {
+ var val = $(trigger).attr('checked') ? true : false;
+ }
if (val) {
$(trigger).siblings('label').removeClass('hidden-options').addClass('expanded-options');
@@ -148,34 +154,41 @@
len++;
}
- var object = $('#' + id + '-wrapper');
- if (!object.size()) {
- // Some elements can't use the parent() method or they can
- // damage things. They are guaranteed to have wrappers but
- // only if dependent.inc provided them. This check prevents
- // problems when multiple AJAX calls cause settings to build
- // up.
- var $original = $('#' + id);
- if ($original.is('fieldset') || $original.is('textarea')) {
- continue;
- }
-
- object = $('#' + id).parent();
+ var $original = $('#' + id);
+ if ($original.is('fieldset') || $original.is('textarea')) {
+ continue;
}
+ var object = $original.parent();
+
if (Drupal.settings.CTools.dependent[id].type == 'disable') {
if (Drupal.settings.CTools.dependent[id].num <= len) {
// Show if the element if criteria is matched
- object.attr('disabled', false);
- object.addClass('dependent-options');
- object.children().attr('disabled', false);
+ // **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute
+ if (typeof $().prop == 'function') {
+ object.prop('disabled', false);
+ object.addClass('dependent-options');
+ object.children().prop('disabled', false);
+ }
+ else {
+ object.attr('disabled', false);
+ object.addClass('dependent-options');
+ object.children().attr('disabled', false);
+ }
}
else {
// Otherwise hide. Use css rather than hide() because hide()
// does not work if the item is already hidden, for example,
// in a collapsed fieldset.
- object.attr('disabled', true);
- object.children().attr('disabled', true);
+ // **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute
+ if (typeof $().prop == 'function') {
+ object.prop('disabled', true);
+ object.children().prop('disabled', true);
+ }
+ else {
+ object.attr('disabled', true);
+ object.children().attr('disabled', true);
+ }
}
}
else {
@@ -194,7 +207,7 @@
}
}
- $(trigger_id).change(function() {
+ $(trigger_id).bind('change.ctools-dependent', function() {
// Trigger the internal change function
// the attr('id') is used because closures are more confusing
changeTrigger(trigger_id, bind_id);
@@ -215,7 +228,7 @@
// is a sort of hacked one that's faster but much less flexible.
$("select.ctools-master-dependent")
.once('ctools-dependent')
- .change(function() {
+ .bind('change.ctools-dependent', function() {
var val = $(this).val();
if (val == 'all') {
$('.ctools-dependent-all').show(0);
@@ -225,7 +238,7 @@
$('.ctools-dependent-' + val).show(0);
}
})
- .trigger('change');
+ .trigger('change.ctools-dependent');
}
}
})(jQuery);
diff --git a/sites/all/modules/contrib/dev/ctools/js/modal.js b/sites/all/modules/contrib/dev/ctools/js/modal.js
index 831649f..ec7b02a 100644
--- a/sites/all/modules/contrib/dev/ctools/js/modal.js
+++ b/sites/all/modules/contrib/dev/ctools/js/modal.js
@@ -48,7 +48,8 @@
modalOptions: {
opacity: .55,
background: '#fff'
- }
+ },
+ modalClass: 'default'
};
var settings = {};
@@ -97,8 +98,13 @@
resize();
$('span.modal-title', Drupal.CTools.Modal.modal).html(Drupal.CTools.Modal.currentSettings.loadingText);
- Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, settings.modalOptions, settings.animation, settings.animationSpeed);
- $('#modalContent .modal-content').html(Drupal.theme(settings.throbberTheme));
+ Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, settings.modalOptions, settings.animation, settings.animationSpeed, settings.modalClass);
+ $('#modalContent .modal-content').html(Drupal.theme(settings.throbberTheme)).addClass('ctools-modal-loading');
+
+ // Position autocomplete results based on the scroll position of the modal.
+ $('#modalContent .modal-content').delegate('input.form-autocomplete', 'keyup', function() {
+ $('#autocomplete').css('top', $(this).position().top + $(this).outerHeight() + $(this).offsetParent().filter('#modal-content').scrollTop());
+ });
};
/**
@@ -115,18 +121,18 @@
*/
Drupal.theme.prototype.CToolsModalDialog = function () {
var html = ''
- html += '
';
return html;
}
@@ -136,11 +142,11 @@
*/
Drupal.theme.prototype.CToolsModalThrobber = function () {
var html = '';
- html += '
';
- html += '
';
- html += Drupal.CTools.Modal.currentSettings.throbber;
- html += '
';
+ html += '
';
+ html += '
';
+ html += Drupal.CTools.Modal.currentSettings.throbber;
html += '
';
+ html += '
';
return html;
};
@@ -222,7 +228,11 @@
// AJAX submits specified in this manner automatically submit to the
// normal form action.
element_settings.url = Drupal.CTools.Modal.findURL(this);
+ if (element_settings.url == '') {
+ element_settings.url = $(this).closest('form').attr('action');
+ }
element_settings.event = 'click';
+ element_settings.setClick = true;
var base = $this.attr('id');
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
@@ -249,9 +259,16 @@
$('input[type=submit], button', this).click(function(event) {
Drupal.ajax[base].element = this;
this.form.clk = this;
+ // Stop autocomplete from submitting.
+ if (Drupal.autocompleteSubmit && !Drupal.autocompleteSubmit()) {
+ return false;
+ }
// An empty event means we were triggered via .click() and
// in jquery 1.4 this won't trigger a submit.
- if (event.bubbles == undefined) {
+ // We also have to check jQuery version to prevent
+ // IE8 + jQuery 1.4.4 to break on other events
+ // bound to the submit button.
+ if (jQuery.fn.jquery.substr(0, 3) === '1.4' && typeof event.bubbles === "undefined") {
$(this.form).trigger('submit');
return false;
}
@@ -282,7 +299,21 @@
// content. This is helpful for allowing users to see error messages at the
// top of a form, etc.
$('#modal-content').html(response.output).scrollTop(0);
- Drupal.attachBehaviors();
+
+ // Attach behaviors within a modal dialog.
+ var settings = response.settings || ajax.settings || Drupal.settings;
+ Drupal.attachBehaviors($('#modalContent'), settings);
+
+ if ($('#modal-content').hasClass('ctools-modal-loading')) {
+ $('#modal-content').removeClass('ctools-modal-loading');
+ }
+ else {
+ // If the modal was already shown, and we are simply replacing its
+ // content, then focus on the first focusable element in the modal.
+ // (When first showing the modal, focus will be placed on the close
+ // button by the show() function called above.)
+ $('#modal-content :focusable:first').focus();
+ }
}
/**
@@ -333,8 +364,9 @@
* @param css obj of css attributes
* @param animation (fadeIn, slideDown, show)
* @param speed (valid animation speeds slow, medium, fast or # in ms)
+ * @param modalClass class added to div#modalContent
*/
- Drupal.CTools.Modal.modalContent = function(content, css, animation, speed) {
+ Drupal.CTools.Modal.modalContent = function(content, css, animation, speed, modalClass) {
// If our animation isn't set, make it just show/pop
if (!animation) {
animation = 'show';
@@ -346,7 +378,7 @@
}
}
- if (!speed) {
+ if (!speed && 0 !== speed) {
speed = 'fast';
}
@@ -363,9 +395,9 @@
css.filter = 'alpha(opacity=' + (100 * css.opacity) + ')';
content.hide();
- // if we already ahve a modalContent, remove it
- if ( $('#modalBackdrop')) $('#modalBackdrop').remove();
- if ( $('#modalContent')) $('#modalContent').remove();
+ // If we already have modalContent, remove it.
+ if ($('#modalBackdrop').length) $('#modalBackdrop').remove();
+ if ($('#modalContent').length) $('#modalContent').remove();
// position code lifted from http://www.quirksmode.org/viewport/compatibility.html
if (self.pageYOffset) { // all except Explorer
@@ -386,9 +418,56 @@
if( docHeight < winHeight ) docHeight = winHeight;
// Create our divs
- $('body').append('
' + $(content).html() + '
');
+ $('body').append('
' + $(content).html() + '
');
- // Keyboard and focus event handler ensures focus stays on modal elements only
+ // Get a list of the tabbable elements in the modal content.
+ var getTabbableElements = function () {
+ var tabbableElements = $('#modalContent :tabbable'),
+ radioButtons = tabbableElements.filter('input[type="radio"]');
+
+ // The list of tabbable elements from jQuery is *almost* right. The
+ // exception is with groups of radio buttons. The list from jQuery will
+ // include all radio buttons, when in fact, only the selected radio button
+ // is tabbable, and if no radio buttons in a group are selected, then only
+ // the first is tabbable.
+ if (radioButtons.length > 0) {
+ // First, build up an index of which groups have an item selected or not.
+ var anySelected = {};
+ radioButtons.each(function () {
+ var name = this.name;
+
+ if (typeof anySelected[name] === 'undefined') {
+ anySelected[name] = radioButtons.filter('input[name="' + name + '"]:checked').length !== 0;
+ }
+ });
+
+ // Next filter out the radio buttons that aren't really tabbable.
+ var found = {};
+ tabbableElements = tabbableElements.filter(function () {
+ var keep = true;
+
+ if (this.type == 'radio') {
+ if (anySelected[this.name]) {
+ // Only keep the selected one.
+ keep = this.checked;
+ }
+ else {
+ // Only keep the first one.
+ if (found[this.name]) {
+ keep = false;
+ }
+ found[this.name] = true;
+ }
+ }
+
+ return keep;
+ });
+ }
+
+ return tabbableElements.get();
+ };
+
+ // Keyboard and focus event handler ensures only modal elements gain focus.
modalEventHandler = function( event ) {
target = null;
if ( event ) { //Mozilla
@@ -405,26 +484,85 @@
return true;
}
}
- if( $(target).filter('*:visible').parents('#modalContent').size()) {
- // allow the event only if target is a visible child node of #modalContent
+
+ if ($(target).is('#modalContent, body') || $(target).filter('*:visible').parents('#modalContent').length) {
+ // Allow the event only if target is a visible child node
+ // of #modalContent.
return true;
}
- if ( $('#modalContent')) $('#modalContent').get(0).focus();
- return false;
+ else {
+ getTabbableElements()[0].focus();
+ }
+
+ event.preventDefault();
};
$('body').bind( 'focus', modalEventHandler );
$('body').bind( 'keypress', modalEventHandler );
+ // Keypress handler Ensures you can only TAB to elements within the modal.
+ // Based on the psuedo-code from WAI-ARIA 1.0 Authoring Practices section
+ // 3.3.1 "Trapping Focus".
+ modalTabTrapHandler = function (evt) {
+ // We only care about the TAB key.
+ if (evt.which != 9) {
+ return true;
+ }
+
+ var tabbableElements = getTabbableElements(),
+ firstTabbableElement = tabbableElements[0],
+ lastTabbableElement = tabbableElements[tabbableElements.length - 1],
+ singleTabbableElement = firstTabbableElement == lastTabbableElement,
+ node = evt.target;
+
+ // If this is the first element and the user wants to go backwards, then
+ // jump to the last element.
+ if (node == firstTabbableElement && evt.shiftKey) {
+ if (!singleTabbableElement) {
+ lastTabbableElement.focus();
+ }
+ return false;
+ }
+ // If this is the last element and the user wants to go forwards, then
+ // jump to the first element.
+ else if (node == lastTabbableElement && !evt.shiftKey) {
+ if (!singleTabbableElement) {
+ firstTabbableElement.focus();
+ }
+ return false;
+ }
+ // If this element isn't in the dialog at all, then jump to the first
+ // or last element to get the user into the game.
+ else if ($.inArray(node, tabbableElements) == -1) {
+ // Make sure the node isn't in another modal (ie. WYSIWYG modal).
+ var parents = $(node).parents().get();
+ for (var i = 0; i < parents.length; ++i) {
+ var position = $(parents[i]).css('position');
+ if (position == 'absolute' || position == 'fixed') {
+ return true;
+ }
+ }
+
+ if (evt.shiftKey) {
+ lastTabbableElement.focus();
+ }
+ else {
+ firstTabbableElement.focus();
+ }
+ }
+ };
+ $('body').bind('keydown', modalTabTrapHandler);
+
// Create our content div, get the dimensions, and hide it
var modalContent = $('#modalContent').css('top','-1000px');
- var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
+ var $modalHeader = modalContent.find('.modal-header');
+ var mdcTop = wt + Math.max((winHeight / 2) - (modalContent.outerHeight() / 2), 0);
var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2);
$('#modalBackdrop').css(css).css('top', 0).css('height', docHeight + 'px').css('width', docWidth + 'px').show();
modalContent.css({top: mdcTop + 'px', left: mdcLeft + 'px'}).hide()[animation](speed);
// Bind a click for closing the modalContent
modalContentClose = function(){close(); return false;};
- $('.close').bind('click', modalContentClose);
+ $('.close', $modalHeader).bind('click', modalContentClose);
// Bind a keypress on escape for closing the modalContent
modalEventEscapeCloseHandler = function(event) {
@@ -436,31 +574,63 @@
$(document).bind('keydown', modalEventEscapeCloseHandler);
+ // Per WAI-ARIA 1.0 Authoring Practices, initial focus should be on the
+ // close button, but we should save the original focus to restore it after
+ // the dialog is closed.
+ var oldFocus = document.activeElement;
+ $('.close', $modalHeader).focus();
+
// Close the open modal content and backdrop
function close() {
// Unbind the events
$(window).unbind('resize', modalContentResize);
$('body').unbind( 'focus', modalEventHandler);
$('body').unbind( 'keypress', modalEventHandler );
- $('.close').unbind('click', modalContentClose);
- $('body').unbind('keypress', modalEventEscapeCloseHandler);
+ $('body').unbind( 'keydown', modalTabTrapHandler );
+ $('.close', $modalHeader).unbind('click', modalContentClose);
+ $(document).unbind('keydown', modalEventEscapeCloseHandler);
$(document).trigger('CToolsDetachBehaviors', $('#modalContent'));
- // Set our animation parameters and use them
- if ( animation == 'fadeIn' ) animation = 'fadeOut';
- if ( animation == 'slideDown' ) animation = 'slideUp';
- if ( animation == 'show' ) animation = 'hide';
+ // Closing animation.
+ switch (animation) {
+ case 'fadeIn':
+ modalContent.fadeOut(speed, modalContentRemove);
+ break;
- // Close the content
- modalContent.hide()[animation](speed);
+ case 'slideDown':
+ modalContent.slideUp(speed, modalContentRemove);
+ break;
- // Remove the content
+ case 'show':
+ modalContent.hide(speed, modalContentRemove);
+ break;
+ }
+ }
+
+ // Remove the content.
+ modalContentRemove = function () {
$('#modalContent').remove();
$('#modalBackdrop').remove();
+
+ // Restore focus to where it was before opening the dialog.
+ $(oldFocus).focus();
};
- // Move and resize the modalBackdrop and modalContent on resize of the window
- modalContentResize = function(){
+ // Move and resize the modalBackdrop and modalContent on window resize.
+ modalContentResize = function () {
+ // Reset the backdrop height/width to get accurate document size.
+ $('#modalBackdrop').css('height', '').css('width', '');
+
+ // Position code lifted from:
+ // http://www.quirksmode.org/viewport/compatibility.html
+ if (self.pageYOffset) { // all except Explorer
+ var wt = self.pageYOffset;
+ } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
+ var wt = document.documentElement.scrollTop;
+ } else if (document.body) { // all other Explorers
+ var wt = document.body.scrollTop;
+ }
+
// Get our heights
var docHeight = $(document).height();
var docWidth = $(document).width();
@@ -470,7 +640,7 @@
// Get where we should move content to
var modalContent = $('#modalContent');
- var mdcTop = ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
+ var mdcTop = wt + Math.max((winHeight / 2) - (modalContent.outerHeight() / 2), 0);
var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2);
// Apply the changes
@@ -478,8 +648,6 @@
modalContent.css('top', mdcTop + 'px').css('left', mdcLeft + 'px').show();
};
$(window).bind('resize', modalContentResize);
-
- $('#modalContent').focus();
};
/**
@@ -502,8 +670,12 @@
$(window).unbind('resize', modalContentResize);
$('body').unbind('focus', modalEventHandler);
$('body').unbind('keypress', modalEventHandler);
- $('.close').unbind('click', modalContentClose);
- $(document).trigger('CToolsDetachBehaviors', $('#modalContent'));
+ $('body').unbind( 'keydown', modalTabTrapHandler );
+ var $modalContent = $('#modalContent');
+ var $modalHeader = $modalContent.find('.modal-header');
+ $('.close', $modalHeader).unbind('click', modalContentClose);
+ $('body').unbind('keypress', modalEventEscapeCloseHandler);
+ $(document).trigger('CToolsDetachBehaviors', $modalContent);
// jQuery magic loop through the instances and run the animations or removal.
content.each(function(){
diff --git a/sites/all/modules/contrib/dev/ctools/js/states-show.js b/sites/all/modules/contrib/dev/ctools/js/states-show.js
new file mode 100644
index 0000000..88df584
--- /dev/null
+++ b/sites/all/modules/contrib/dev/ctools/js/states-show.js
@@ -0,0 +1,43 @@
+/**
+ * @file
+ * Custom state for handling visibility
+ */
+
+/**
+ * Add a new state to Drupal #states. We use this to toggle element-invisible
+ * to show/hidden #states elements. This allows elements to be visible to
+ * screen readers.
+ *
+ * To use:
+ * $form['my_form_field'] = array(
+ * ..
+ * // Only show this field if 'some_other_field' is checked.
+ * '#states => array(
+ * 'show' => array(
+ * 'some-other-field' => array('checked' => TRUE),
+ * ),
+ * ),
+ * ..
+ * // Required to load the 'show' state handler.
+ * '#attached' => array(
+ * 'js' => array(ctools_attach_js('states-show')),
+ * ),
+ * );
+ */
+
+(function ($) {
+ 'use strict';
+
+ Drupal.states.State.aliases.hidden = '!show';
+
+ // Show/hide form items by toggling the 'element-invisible' class. This is a
+ // more accessible option than the core 'visible' state.
+ $(document).bind('state:show', function(e) {
+ if (e.trigger) {
+ var element = $(e.target).closest('.form-item, .form-submit, .form-wrapper');
+ element.toggle(e.value);
+ e.value === true ? element.removeClass('element-invisible') : element.addClass('element-invisible');
+ }
+ });
+
+})(jQuery);
diff --git a/sites/all/modules/contrib/dev/ctools/js/stylizer.js b/sites/all/modules/contrib/dev/ctools/js/stylizer.js
index 16d6c49..12ab720 100644
--- a/sites/all/modules/contrib/dev/ctools/js/stylizer.js
+++ b/sites/all/modules/contrib/dev/ctools/js/stylizer.js
@@ -5,7 +5,7 @@
Drupal.CTools.Stylizer.addFarbtastic = function(context) {
// This behavior attaches by ID, so is only valid once on a page.
- if ($('ctools_stylizer_color_scheme_form .color-form.Stylizer-processed').size()) {
+ if ($('#ctools_stylizer_color_scheme_form .color-form.Stylizer-processed').size()) {
return;
}
diff --git a/sites/all/modules/contrib/dev/ctools/page_manager/css/page-manager.css b/sites/all/modules/contrib/dev/ctools/page_manager/css/page-manager.css
index 1a7dd5e..5abe39e 100644
--- a/sites/all/modules/contrib/dev/ctools/page_manager/css/page-manager.css
+++ b/sites/all/modules/contrib/dev/ctools/page_manager/css/page-manager.css
@@ -100,7 +100,7 @@ body form#page-manager-list-pages-form {
#page-manager-edit .page-manager-edit-operations li {
list-style: none;
- background: #F6F6F6;
+ background: #f6f6f6;
border-top: 1px solid #aaa;
border-left: 1px solid #aaa;
border-right: 1px solid #aaa;
@@ -111,7 +111,7 @@ body form#page-manager-list-pages-form {
#page-manager-edit .page-manager-edit-operations li.active,
#page-manager-edit .page-manager-edit-operations li.active-group .page-manager-group-title {
- background: #FFFFFF url(../images/arrow-active.png) no-repeat scroll right center;
+ background: #ffffff url(../images/arrow-active.png) no-repeat scroll right center;
}
#page-manager-edit .page-manager-edit-operations li.changed,
@@ -123,7 +123,7 @@ body form#page-manager-list-pages-form {
/** provide a reset for non active stray paths */
#page-manager-edit .page-manager-edit-operations li.active-group li.not-active .page-manager-group-title,
#page-manager-edit .page-manager-edit-operations li.changed-group li.not-changed .page-manager-group-title {
- background: #F6F6F6;
+ background: #f6f6f6;
}
#page-manager-edit .page-manager-edit-operations li.active {
@@ -132,7 +132,7 @@ body form#page-manager-list-pages-form {
#page-manager-edit .page-manager-edit-operations li.active a,
#page-manager-edit .page-manager-edit-operations li.active a:hover {
- background: #FFFFFF url(../images/arrow-active.png) no-repeat scroll right center;
+ background: #ffffff url(../images/arrow-active.png) no-repeat scroll right center;
color: #000000;
font-weight: bold;
}
@@ -271,8 +271,8 @@ body form#page-manager-list-pages-form {
#page-manager-edit .actions li a {
display: block;
padding: 0.2em 0.5em;
- color:#0062A0;
- background-color: #F6F6F6;
+ color: #0062a0;
+ background-color: #f6f6f6;
}
#page-manager-edit .page-manager-changed {
diff --git a/sites/all/modules/contrib/dev/ctools/page_manager/help/getting-started.html b/sites/all/modules/contrib/dev/ctools/page_manager/help/getting-started.html
index 4e4f24a..6a75a37 100644
--- a/sites/all/modules/contrib/dev/ctools/page_manager/help/getting-started.html
+++ b/sites/all/modules/contrib/dev/ctools/page_manager/help/getting-started.html
@@ -4,7 +4,7 @@ Note: this page is currently very preliminary. Please visit 32,
+ '#maxlength' => 32,
+ '#machine_name' => array(
+ 'exists' => 'page_manager_handler_check_machine_name',
+ 'source' => array('title'),
+ ),
+ '#field_prefix' => '' . $form_state['task_name'] . '__',
+ '#field_suffix' => '',
+ );
}
$form['handler'] = array(
@@ -1436,6 +1462,15 @@ function page_manager_handler_add_form($form, $form_state, $features = array())
return $form;
}
+/*
+ * Check if handler's machine-name is unique
+ */
+function page_manager_handler_check_machine_name($name, $element, $form_state) {
+ $name = $form_state['task_name'] . '__' . $name;
+
+ return count(ctools_export_load_object('page_manager_handlers', 'names', array($name)));
+}
+
/**
* Rearrange the order of variants.
*/
@@ -1446,15 +1481,16 @@ function page_manager_handler_import($form, &$form_state) {
'#description' => t('Enter the name of the new variant.'),
);
- if (user_access('use PHP for settings')) {
+ if (user_access('use ctools import')) {
$form['object'] = array(
'#type' => 'textarea',
'#title' => t('Paste variant code here'),
'#rows' => 15,
);
}
- // Users ordinarily can't get here without the PHP block visibility perm.
- // In case they somehow do, though, disable the form widget for extra safety.
+ // Users ordinarily can't get here without the 'import' permission, due to
+ // security implications. In case they somehow do, though, disable the form
+ // widget for extra safety.
else {
$form['shoveoff'] = array(
'#markup' => '
';
@@ -1359,22 +1543,25 @@ function devel_print_object($object, $prefix = NULL, $header = TRUE) {
}
/**
- * Recursive (and therefore magical) function goes through an array or object and
- * returns a nicely formatted listing of its contents.
+ * Returns formatted listing for an array or object.
*
- * @param $obj
- * array or object to recurse through
- * @param $prefix
- * prefix for the output items (example "$node->", "$user->", "$")
- * @param $parents
- * used by recursion
- * @param $object
- * used by recursion
- * @return
- * fomatted html
+ * Recursive (and therefore magical) function goes through an array or object
+ * and returns a nicely formatted listing of its contents.
+ *
+ * @param array|object $obj
+ * Array or object to recurse through.
+ * @param string $prefix
+ * Prefix for the output items (example "$node->", "$user->", "$").
+ * @param string $parents
+ * Used by recursion.
+ * @param boolean $object
+ * Used by recursion.
+ *
+ * @return string
+ * Formatted html.
*
* @todo
- * currently there are problems sending an array with a varname
+ * Currently there are problems sending an array with a varname.
*/
function _devel_print_object($obj, $prefix = NULL, $parents = NULL, $object = FALSE) {
static $root_type, $out_format;
@@ -1392,24 +1579,24 @@ function _devel_print_object($obj, $prefix = NULL, $parents = NULL, $object = FA
}
if (is_object($obj)) {
- $obj = (array)$obj;
+ $obj = (array) $obj;
}
if (is_array($obj)) {
$output = "
\n";
foreach ($obj as $field => $value) {
- if ($field == 'devel_flag_reference') {
+ if ($field === 'devel_flag_reference') {
continue;
}
if (!is_null($parents)) {
if ($object) {
- $field = $parents .'->'. $field;
+ $field = $parents . '->' . $field;
}
else {
if (is_int($field)) {
- $field = $parents .'['. $field .']';
+ $field = $parents . '[' . $field . ']';
}
else {
- $field = $parents .'[\''. $field .'\']';
+ $field = $parents . '[\'' . $field . '\']';
}
}
}
@@ -1420,9 +1607,9 @@ function _devel_print_object($obj, $prefix = NULL, $parents = NULL, $object = FA
$summary = NULL;
if ($show_summary) {
switch ($type) {
- case 'string' :
- case 'float' :
- case 'integer' :
+ case 'string':
+ case 'float':
+ case 'integer':
if (strlen($value) == 0) {
$summary = t("{empty}");
}
@@ -1433,20 +1620,20 @@ function _devel_print_object($obj, $prefix = NULL, $parents = NULL, $object = FA
$summary = format_plural(drupal_strlen($value), '1 character', '@count characters');
}
break;
- case 'array' :
- case 'object' :
- $summary = format_plural(count((array)$value), '1 element', '@count elements');
+ case 'array':
+ case 'object':
+ $summary = format_plural(count((array) $value), '1 element', '@count elements');
break;
- case 'boolean' :
+ case 'boolean':
$summary = $value ? t('TRUE') : t('FALSE');
break;
}
}
if (!is_null($summary)) {
- $typesum = '('. $type .', '. $summary .')';
+ $typesum = '(' . $type . ', ' . $summary . ')';
}
else {
- $typesum = '('. $type .')';
+ $typesum = '(' . $type . ')';
}
$output .= '';
@@ -1463,11 +1650,11 @@ function _devel_print_object($obj, $prefix = NULL, $parents = NULL, $object = FA
}
elseif (is_object($value)) {
$value->devel_flag_reference = FALSE;
- $output .= _devel_print_object((array)$value, $prefix, $field, TRUE);
+ $output .= _devel_print_object((array) $value, $prefix, $field, TRUE);
}
else {
$value = is_bool($value) ? ($value ? 'TRUE' : 'FALSE') : $value;
- $output .= htmlspecialchars(print_r($value, TRUE)) ."\n";
+ $output .= htmlspecialchars(print_r($value, TRUE)) . "\n";
}
$output .= "\n";
}
@@ -1477,14 +1664,20 @@ function _devel_print_object($obj, $prefix = NULL, $parents = NULL, $object = FA
}
/**
- * Adds a table at the bottom of the page cataloguing data on all the database queries that were made to
- * generate the page.
+ * Shows all the queries for the page.
+ *
+ * Adds a table at the bottom of the page cataloguing data on all the database
+ * queries that were made to generate the page.
+ *
+ * @return string
+ * Queries themed using devel_querylog.
*/
function devel_query_table($queries, $counts) {
$version = devel_get_core_version(VERSION);
- $header = array ('ms', '#', 'where', 'ops', 'query', 'target');
+ $header = array('ms', '#', 'where', 'ops', 'query', 'target');
$i = 0;
$api = variable_get('devel_api_url', 'api.drupal.org');
+ $conn = Database::getconnection();
foreach ($queries as $query) {
$function = !empty($query['caller']['class']) ? $query['caller']['class'] . '::' : '';
$function .= $query['caller']['function'];
@@ -1492,23 +1685,49 @@ function devel_query_table($queries, $counts) {
$diff = round($query['time'] * 1000, 2);
if ($diff > variable_get('devel_execution', 5)) {
- $cell[$i][] = array ('data' => $diff, 'class' => 'marker');
+ $cell[$i][] = array('data' => $diff, 'class' => 'marker');
}
else {
$cell[$i][] = $diff;
}
$cell[$i][] = $count;
$cell[$i][] = l($function, "http://$api/api/function/$function/$version");
- $ops[] = l('P', '', array('attributes' => array('title' => 'Show placeholders', 'class' => 'dev-placeholders', 'qid' => $i)));
- $ops[] = l('A', '', array('attributes' => array('title' => 'Show arguments', 'class' => 'dev-arguments', 'qid' => $i)));
+ $ops[] = l(t('P'), '', array(
+ 'attributes' => array(
+ 'title' => 'Show placeholders',
+ 'class' => array('dev-placeholders'),
+ 'qid' => $i,
+ )));
+ $ops[] = l(t('A'), '', array(
+ 'attributes' => array(
+ 'title' => 'Show arguments',
+ 'class' => array('dev-arguments'),
+ 'qid' => $i,
+ )));
// EXPLAIN only valid for select queries.
if (strpos($query['query'], 'UPDATE') === FALSE && strpos($query['query'], 'INSERT') === FALSE && strpos($query['query'], 'DELETE') === FALSE) {
- $ops[] = l('E', '', array('attributes' => array('title' => 'Show EXPLAIN', 'class' => 'dev-explain', 'qid' => $i)));
+ $ops[] = l(t('E'), '', array(
+ 'attributes' => array(
+ 'title' => 'Show EXPLAIN',
+ 'class' => array('dev-explain'),
+ 'qid' => $i,
+ )));
}
$cell[$i][] = implode(' ', $ops);
// 3 divs for each variation of the query. Last 2 are hidden by default.
- $placeholders = '
\n";
+ $args = '' . "\n";
+ }
$explain = '' . "\n";
$cell[$i][] = array(
'id' => "devel-query-$i",
@@ -1524,6 +1743,18 @@ function devel_query_table($queries, $counts) {
return theme('devel_querylog', array('header' => $header, 'rows' => $cell));
}
+/**
+ * Returns HTML for a Devel querylog row.
+ *
+ * @param array $variables
+ * An associative array containing:
+ * - row: An array of cells in which each cell is either a string or an
+ * associative array containing:
+ * - data: The data to render.
+ * - Any attributes to be applied to the cell.
+ *
+ * @ingroup themeable
+ */
function theme_devel_querylog_row($variables) {
$row = $variables['row'];
$i = 0;
@@ -1554,6 +1785,16 @@ function theme_devel_querylog_row($variables) {
return $output;
}
+/**
+ * Returns HTML for the Devel querylog.
+ *
+ * @param array $variables
+ * An associative array containing:
+ * - header: An array suitable for rendering with devel_querylog_row.
+ * - rows: An array of rows suitable for rendering with devel_querylog_row.
+ *
+ * @ingroup themeable
+ */
function theme_devel_querylog($variables) {
$header = $variables['header'];
$rows = $variables['rows'];
@@ -1576,6 +1817,9 @@ function theme_devel_querylog($variables) {
return $output;
}
+/**
+ * Devel's table sort.
+ */
function _devel_table_sort($a, $b) {
$a = is_array($a[0]) ? $a[0]['data'] : $a[0];
$b = is_array($b[0]) ? $b[0]['data'] : $b[0];
@@ -1590,28 +1834,36 @@ function _devel_table_sort($a, $b) {
/**
* Displays page execution time at the bottom of the page.
+ *
+ * @return string
+ * A message indicating how long it took to execute the page.
*/
function devel_timer() {
$time = timer_read('page');
return t_safe(' Page execution time was @time ms.', array('@time' => $time));
}
-// An alias for drupal_debug().
-function dd($data, $label = NULL) {
- return drupal_debug($data, $label);
+if (!function_exists('dd')) {
+ /**
+ * An alias for drupal_debug().
+ *
+ * @see drupal_debug()
+ */
+ function dd($data, $label = NULL) {
+ return drupal_debug($data, $label);
+ }
}
/**
* Logs a variable to a drupal_debug.txt in the site's temp directory.
*
- * @param $data
+ * @param mixed $data
* The variable to log to the drupal_debug.txt log file.
- * @param $label
+ * @param string $label
* (optional) If set, a label to output before $data in the log file.
*
- * @return
- * No return value if successful, FALSE if the log file could not be written
- * to.
+ * @return void|false
+ * Empty if successful, FALSE if the log file could not be written.
*
* @see dd()
* @see http://drupal.org/node/314112
@@ -1620,15 +1872,15 @@ function drupal_debug($data, $label = NULL) {
$out = ($label ? $label . ': ' : '') . print_r($data, TRUE) . "\n";
// The temp directory does vary across multiple simpletest instances.
- $file = 'temporary://drupal_debug.txt';
+ $file = file_directory_temp() . '/drupal_debug.txt';
if (file_put_contents($file, $out, FILE_APPEND) === FALSE) {
- drupal_set_message(t('The file could not be written.'), 'error');
+ drupal_set_message(t('Devel was unable to write to %file.', array('%file' => $file)), 'error');
return FALSE;
}
}
/**
- * Prints the arguments passed into the current function
+ * Prints the arguments passed into the current function.
*/
function dargs($always = TRUE) {
static $printed;
@@ -1640,27 +1892,30 @@ function dargs($always = TRUE) {
}
/**
- * Prints a SQL string from a DBTNG SelectQuery object.
+ * Prints a SQL string from a DBTNG Select object.
*
* Includes quoted arguments.
*
- * @param $query
+ * @param object $query
* An object that implements the SelectQueryInterface interface.
- * @param $return
+ * @param string $return
* Whether to return the string. Default is FALSE, meaning to print it
* and return $query instead.
- * @param $name
+ * @param string $name
* Optional name for identifying the output.
- * @return
+ *
+ * @return object|string
* The $query object, or the query string if $return was TRUE.
*/
function dpq($query, $return = FALSE, $name = NULL) {
if (user_access('access devel information')) {
- $query->preExecute();
+ if (method_exists($query, 'preExecute')) {
+ $query->preExecute();
+ }
$sql = (string) $query;
$quoted = array();
$connection = Database::getConnection();
- foreach ((array)$query->arguments() as $key => $val) {
+ foreach ((array) $query->arguments() as $key => $val) {
$quoted[$key] = $connection->quote($val);
}
$sql = strtr($sql, $quoted);
@@ -1673,18 +1928,21 @@ function dpq($query, $return = FALSE, $name = NULL) {
}
/**
- * Print a variable to the 'message' area of the page.
+ * Prints a variable to the 'message' area of the page.
*
* Uses drupal_set_message().
*
* @param $input
* An arbitrary value to output.
- * @param $name
+ * @param string $name
* Optional name for identifying the output.
- * @param $type
+ * @param string $type
* Optional message type for drupal_set_message(), defaults to 'status'.
- * @return
+ *
+ * @return input
* The unaltered input value.
+ *
+ * @see drupal_set_message()
*/
function dpm($input, $name = NULL, $type = 'status') {
if (user_access('access devel information')) {
@@ -1695,16 +1953,20 @@ function dpm($input, $name = NULL, $type = 'status') {
}
/**
- * drupal_var_export() a variable to the 'message' area of the page.
+ * Displays a drupal_var_export() variable to the 'message' area of the page.
*
* Uses drupal_set_message().
*
* @param $input
* An arbitrary value to output.
- * @param $name
+ * @param string $name
* Optional name for identifying the output.
- * @return
+ *
+ * @return input
* The unaltered input value.
+ *
+ * @see drupal_set_message()
+ * @see drupal_var_export()
*/
function dvm($input, $name = NULL) {
if (user_access('access devel information')) {
@@ -1714,37 +1976,73 @@ function dvm($input, $name = NULL) {
return $input;
}
-// legacy function that was poorly named. use dpm() instead, since the 'p' maps to 'print_r'
+/**
+ * Legacy function that was poorly named.
+ *
+ * @deprecated Use dpm() instead, since the 'p' maps to 'print_r'.
+ *
+ * @see dpm()
+ */
function dsm($input, $name = NULL) {
return dpm($input, $name);
}
/**
- * An alias for dprint_r(). Saves carpal tunnel syndrome.
+ * An alias for dprint_r().
+ *
+ * Saves carpal tunnel syndrome.
+ *
+ * @see dprint_r()
*/
function dpr($input, $return = FALSE, $name = NULL) {
return dprint_r($input, $return, $name);
}
/**
- * An alias for kprint_r(). Saves carpal tunnel syndrome.
+ * An alias for kprint_r().
+ *
+ * Saves carpal tunnel syndrome.
+ *
+ * @see kprint_r()
*/
function kpr($input, $return = FALSE, $name = NULL) {
return kprint_r($input, $return, $name);
}
/**
- * Like dpr, but uses drupal_var_export() instead
+ * Like dpr(), but uses drupal_var_export() instead.
+ *
+ * @see dprint_r()
+ * @see drupal_var_export()
*/
function dvr($input, $return = FALSE, $name = NULL) {
return dprint_r($input, $return, $name, 'drupal_var_export', FALSE);
}
+/**
+ * Returns a message using Krumo.
+ *
+ * Uses dprint_r() as a fallback.
+ *
+ * @param mixed $input
+ * The thing to print.
+ * @param boolean $return
+ * (optional) Indicates if the output should be returned. The default is
+ * FALSE.
+ * @param string $name
+ * (optional) The label to apply.
+ * @param string $function
+ * (optional) The function to use for output in the case where dprint_r() is
+ * used. The defualt is print_r().
+ *
+ * @return
+ * The output if $return is TRUE.
+ */
function kprint_r($input, $return = FALSE, $name = NULL, $function = 'print_r') {
- // We do not want to krumo() strings and integers and such
+ // We do not want to krumo() strings and integers and such.
if (merits_krumo($input)) {
if (user_access('access devel information')) {
- return $return ? (isset($name) ? $name .' => ' : '') . krumo_ob($input) : krumo($input);
+ return $return ? (isset($name) ? $name . ' => ' : '') . krumo_ob($input) : krumo($input);
}
}
else {
@@ -1754,10 +2052,27 @@ function kprint_r($input, $return = FALSE, $name = NULL, $function = 'print_r')
/**
* Pretty-print a variable to the browser (no krumo).
- * Displays only for users with proper permissions. If
- * you want a string returned instead of a print, use the 2nd param.
+ *
+ * Displays only for users with proper permissions. If you want a string
+ * returned instead of a print, use the 2nd param.
+ *
+ * @param mixed $input
+ * The input that should be printed or returned.
+ * @param boolean $return
+ * (optional) Indicates of the result should be returned instead of printed.
+ * The default is to print it.
+ * @param string $name
+ * (optional) The label to apply.
+ * @param string $function
+ * (optional) The function to use for output. The defualt is print_r().
+ * @param boolean $check
+ * (optional) Indicates if the output should be run through check_plain().
+ * The default is TRUE.
+ *
+ * @return
+ * The formatted output if $return is TRUE.
*/
-function dprint_r($input, $return = FALSE, $name = NULL, $function = 'print_r', $check= TRUE) {
+function dprint_r($input, $return = FALSE, $name = NULL, $function = 'print_r', $check = TRUE) {
if (user_access('access devel information')) {
if ($name) {
$name .= ' => ';
@@ -1775,12 +2090,12 @@ function dprint_r($input, $return = FALSE, $name = NULL, $function = 'print_r',
if ($check) {
$output = check_plain($output);
}
- if (count($input, COUNT_RECURSIVE) > DEVEL_MIN_TEXTAREA) {
- // don't use fapi here because sometimes fapi will not be loaded
- $printed_value = "';
+ if (is_array($input) && count($input, COUNT_RECURSIVE) > DEVEL_MIN_TEXTAREA) {
+ // Don't use fapi here because sometimes fapi will not be loaded.
+ $printed_value = "';
}
else {
- $printed_value = '
'. $name . $output .'
';
+ $printed_value = '
' . $name . $output . '
';
}
if ($return) {
@@ -1809,18 +2124,35 @@ function devel_render() {
}
/**
- * Print the function call stack.
+ * Prints the function call stack.
+ *
+ * @param $return
+ * Pass TRUE to return the formatted backtrace rather than displaying it in
+ * the browser via kprint_r().
+ * @param $pop
+ * How many items to pop from the top of the stack; useful when calling from
+ * an error handler.
+ * @param $options
+ * Options to pass on to PHP's debug_backtrace(), depending on your PHP
+ * version.
+ *
+ * @return string|NULL
+ * The formatted backtrace, if requested, or NULL.
+ *
+ * @see http://php.net/manual/en/function.debug-backtrace.php
*/
-function ddebug_backtrace($return = FALSE, $pop = 0) {
+function ddebug_backtrace($return = FALSE, $pop = 0, $options = TRUE) {
if (user_access('access devel information')) {
- $backtrace = debug_backtrace();
+ $backtrace = debug_backtrace($options);
while ($pop-- > 0) {
array_shift($backtrace);
}
$counter = count($backtrace);
- $path = $backtrace[$counter - 1]['file'];
- $path = substr($path, 0, strlen($path) - 10);
- $paths[$path] = strlen($path) + 1;
+ if (!empty($backtrace[$counter - 1]['file'])) {
+ $path = $backtrace[$counter - 1]['file'];
+ $path = substr($path, 0, strlen($path) - 10);
+ $paths[$path] = strlen($path) + 1;
+ }
$paths[DRUPAL_ROOT] = strlen(DRUPAL_ROOT) + 1;
$nbsp = "\xC2\xA0";
@@ -1847,6 +2179,7 @@ function ddebug_backtrace($return = FALSE, $pop = 0) {
else {
$function = $backtrace[1]['function'] . '()';
}
+ $backtrace[1] += array('args' => array());
$call['args'] = $backtrace[1]['args'];
}
else {
@@ -1864,31 +2197,32 @@ function ddebug_backtrace($return = FALSE, $pop = 0) {
}
}
-// Delete all files in a dir.
+/**
+ * Deletes all files in a dir.
+ */
function devel_empty_dir($dir) {
- foreach (new DirectoryIterator($dir) as $fileInfo) {
- if ($fileInfo->isFile()) {
- unlink($fileInfo->getPathname());
+ foreach (new DirectoryIterator($dir) as $file_info) {
+ if ($file_info->isFile()) {
+ unlink($file_info->getPathname());
}
}
}
/*
- * migration related functions
+ * Migration-related functions.
*/
/**
- * Regenerate the data in node_comment_statistics table. Technique comes from
- * http://www.artfulsoftware.com/infotree/queries.php?&bw=1280#101
+ * Regenerates the data in node_comment_statistics table.
*
- * @return void
- **/
+ * Technique - http://www.artfulsoftware.com/infotree/queries.php?&bw=1280#101
+ */
function devel_rebuild_node_comment_statistics() {
- // Empty table
+ // Empty table.
db_truncate('node_comment_statistics')->execute();
- // TODO: DBTNG. Ignore keyword is Mysql only? Is only used in the rare case when
- // two comments on the same node share same timestamp.
+ // TODO: DBTNG. Ignore keyword is Mysql only? Is only used in the rare case
+ // when two comments on the same node share same timestamp.
$sql = "
INSERT IGNORE INTO {node_comment_statistics} (nid, cid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) (
SELECT c.nid, c.cid, c.created, c.name, c.uid, c2.comment_count FROM {comment} c
@@ -1908,7 +2242,7 @@ function devel_rebuild_node_comment_statistics() {
$query->addExpression('NULL', 'last_comment_name');
$query->isNull('ncs.comment_count');
- db_insert('node_comment_statistics')
+ db_insert('node_comment_statistics', array('return' => Database::RETURN_NULL))
->from($query)
->execute();
}
@@ -1916,8 +2250,8 @@ function devel_rebuild_node_comment_statistics() {
/**
* Implements hook_form_alter().
*
- * Adds mouse-over hints on the Permissions page to display
- * language-independent machine names and module base names.
+ * Adds mouse-over hints on the Permissions page to display language-independent
+ * machine names and module base names.
*/
function devel_form_user_admin_permissions_alter(&$form, &$form_state) {
if (user_access('access devel information') && variable_get('devel_raw_names', FALSE)) {
@@ -1935,8 +2269,7 @@ function devel_form_user_admin_permissions_alter(&$form, &$form_state) {
/**
* Implements hook_form_alter().
*
- * Adds mouse-over hints on the Modules page to display
- * module base names.
+ * Adds mouse-over hints on the Modules page to display module base names.
*/
function devel_form_system_modules_alter(&$form, &$form_state) {
if (user_access('access devel information') && variable_get('devel_raw_names', FALSE) && isset($form['modules']) && is_array($form['modules'])) {
@@ -1954,3 +2287,25 @@ function devel_form_system_modules_alter(&$form, &$form_state) {
}
}
}
+
+/**
+ * Implements hook_query_TAG_alter() for the devel tag.
+ *
+ * Makes debugging EntityFieldQuery much easier.
+ *
+ * Example usage:
+ * @code
+ * $q = new EntityFieldQuery;
+ * $q->entityCondition('entity_type', 'node')
+ * ->addTag('debug')
+ * ->execute();
+ * @endcode
+ *
+ * @param QueryAlterableInterface $query
+ */
+function devel_query_debug_alter(QueryAlterableInterface $query) {
+ if (!$query->hasTag('debug-semaphore')) {
+ $query->addTag('debug-semaphore');
+ dpq($query);
+ }
+}
diff --git a/sites/all/modules/contrib/dev/devel/devel.pages.inc b/sites/all/modules/contrib/dev/devel/devel.pages.inc
index 9870f52..c93eda5 100644
--- a/sites/all/modules/contrib/dev/devel/devel.pages.inc
+++ b/sites/all/modules/contrib/dev/devel/devel.pages.inc
@@ -1,14 +1,23 @@
query, (array)$query->args)->fetchAllAssoc('table');
- $i = 1;
- foreach ($result as $row) {
- $row = (array)$row;
- if ($i == 1) {
- $header = array_keys($row);
+
+ $output = t('No explain log found.');
+
+ if (file_exists($path)) {
+ $queries = json_decode(file_get_contents($path));
+
+ if ($queries !== FALSE && isset($queries[$qid])) {
+ $header = $rows = array();
+
+ $query = $queries[$qid];
+ $result = db_query('EXPLAIN ' . $query->query, (array)$query->args)->fetchAllAssoc('table');
+ $i = 1;
+ foreach ($result as $row) {
+ $row = (array)$row;
+ if ($i == 1) {
+ $header = array_keys($row);
+ }
+ $rows[] = array_values($row);
+ $i++;
+ }
+
+ $output = theme('table', array('header' => $header, 'rows' => $rows));
}
- $rows[] = array_values($row);
- $i++;
}
+
// Print and return nothing thus avoiding page wrapper.
- $output = theme('table', array('header' => $header, 'rows' => $rows));
print $output;
$GLOBALS['devel_shutdown'] = FALSE;
}
-// A menu callback. Called by the AJAX link in query log.
+/**
+ * Page callback: Called by the AJAX link in query log.
+ */
function devel_querylog_arguments($request_id, $qid) {
if (!is_numeric($request_id)) {
return MENU_ACCESS_DENIED;
@@ -67,22 +96,30 @@ function devel_querylog_arguments($request_id, $qid) {
$path = "temporary://devel_querylog/$request_id.txt";
$path = file_stream_wrapper_uri_normalize($path);
- $queries = json_decode(file_get_contents($path));
- $query = $queries[$qid];
- $conn = Database::getConnection();
- $quoted = array();
- foreach ((array)$query->args as $key => $val) {
- $quoted[$key] = $conn->quote($val);
- }
- $output = strtr($query->query, $quoted);
- // print and return nothing thus avoiding page wrapper.
+ $output = t('No arguments log found.');
+
+ if (file_exists($path)) {
+ $queries = json_decode(file_get_contents($path));
+
+ if ($queries !== FALSE && isset($queries[$qid])) {
+ $query = $queries[$qid];
+ $conn = Database::getConnection();
+ $quoted = array();
+ foreach ((array)$query->args as $key => $val) {
+ $quoted[$key] = $conn->quote($val);
+ }
+ $output = strtr($query->query, $quoted);
+ }
+ }
+
+ // Print and return nothing thus avoiding page wrapper.
print $output;
$GLOBALS['devel_shutdown'] = FALSE;
}
/**
- * Menu callback; clear the database, resetting the menu to factory defaults.
+ * Page callback: Clears the database, resetting the menu to factory defaults.
*/
function devel_menu_rebuild() {
menu_rebuild();
@@ -91,7 +128,11 @@ function devel_menu_rebuild() {
}
/**
- * Display a dropdown of installed modules with the option to reinstall them.
+ * Form constructor for reinstalling any module from a dropdown.
+ *
+ * @see devel_reinstall_submit()
+ *
+ * @ingroup forms
*/
function devel_reinstall($form, &$form_state) {
$output = '';
@@ -103,7 +144,8 @@ function devel_reinstall($form, &$form_state) {
'#options' => $options,
'#description' => t('Uninstall and then install the selected modules. hook_uninstall() and hook_install() will be executed and the schema version number will be set to the most recent update number. You may have to manually clear out any existing tables first if the module doesn\'t implement hook_uninstall().'),
);
- $form['submit'] = array(
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
'#value' => t('Reinstall'),
'#type' => 'submit',
);
@@ -111,7 +153,7 @@ function devel_reinstall($form, &$form_state) {
}
/**
- * Process reinstall menu form submissions.
+ * Form submission callback for devel_reinstall().
*/
function devel_reinstall_submit($form, &$form_state) {
// require_once './includes/install.inc';
@@ -122,7 +164,9 @@ function devel_reinstall_submit($form, &$form_state) {
drupal_set_message(t('Uninstalled and installed: %names.', array('%names' => implode(', ', $modules))));
}
-// Menu callback.
+/**
+ * Page callback: Rebuilds the theme registry.
+ */
function devel_theme_registry() {
drupal_theme_initialize();
$hooks = theme_get_registry();
@@ -130,14 +174,26 @@ function devel_theme_registry() {
return kprint_r($hooks, TRUE);
}
-// Menu callback. $entity_type argument not currently used in the UI.
+/**
+ * Page callback: Returns information from hook_entity_info().
+ *
+ * @param string $entity_type
+ * (optional) Limit results to the specified entity type. The default is to
+ * return information about all entity types. The $entity_type argument is not
+ * currently used in the UI.
+ *
+ * @return
+ * The results from kprint_r().
+ */
function devel_entity_info_page($entity_type = NULL) {
$info = entity_get_info($entity_type);
ksort($info);
return kprint_r($info, TRUE);
}
-// Menu callback.
+/**
+ * Page callback: Returns information about fields.
+ */
function devel_field_info_page() {
$info = field_info_fields();
$output = kprint_r($info, TRUE, t('Fields'));
@@ -145,20 +201,24 @@ function devel_field_info_page() {
$output .= kprint_r($info, TRUE, t('Instances'));
$info = field_info_bundles();
$output .= kprint_r($info, TRUE, t('Bundles'));
+ $info = field_info_field_types();
+ $output .= kprint_r($info, TRUE, t('Field types'));
+ $info = field_info_formatter_types();
+ $output .= kprint_r($info, TRUE, t('Formatter types'));
+ $info = field_info_storage_types();
+ $output .= kprint_r($info, TRUE, t('Storage types'));
+ $info = field_info_widget_types();
+ $output .= kprint_r($info, TRUE, t('Widget types'));
return $output;
}
/**
- * Menu callback; display all variables.
+ * Form constructor for displaying and editing variables.
+ *
+ * @see devel_variable_form_submit()
+ *
+ * @ingroup forms.
*/
-function devel_variable_page() {
- // We return our own $page so as to avoid blocks.
- $output = drupal_get_form('devel_variable_form');
- drupal_set_page_content($output);
- $page = element_info('page');
- return $page;
-}
-
function devel_variable_form() {
$header = array(
'name' => array('data' => t('Name'), 'field' => 'name', 'sort' => 'asc'),
@@ -166,7 +226,9 @@ function devel_variable_form() {
'length' => array('data' => t('Length'), 'field' => 'length'),
'edit' => array('data' => t('Operations')),
);
- // TODO: we could get variables out of $conf but that would include hard coded ones too. ideally i would highlight overrridden/hard coded variables
+ // @todo: We could get variables out of $conf but that would include
+ // hard-coded ones too. Ideally I would highlight overridden/hard-coded
+ // variables.
$query = db_select('variable', 'v')->extend('TableSort');
$query->fields('v', array('name', 'value'));
switch (db_driver()) {
@@ -205,15 +267,20 @@ function devel_variable_form() {
'#options' => $options,
'#empty' => t('No variables.'),
);
- $form['submit'] = array(
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
+ $form['#after_build'][] = 'devel_variable_form_after_build';
// krumo($form);
return $form;
}
+/**
+ * Form submission handler for devel_variable_form().
+ */
function devel_variable_form_submit($form, &$form_state) {
$deletes = array_filter($form_state['values']['variables']);
array_walk($deletes, 'variable_del');
@@ -222,6 +289,25 @@ function devel_variable_form_submit($form, &$form_state) {
}
}
+/**
+ * After build callback for devel_variable_form().
+ *
+ * Wrap each variable name in a