Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WCMS
uw_base_profile
Commits
8697df09
Commit
8697df09
authored
Feb 28, 2018
by
Liam Morland
Browse files
Coding standards
parent
a534c42d
Changes
5
Hide whitespace changes
Inline
Side-by-side
content-security-policy.php
View file @
8697df09
...
...
@@ -11,7 +11,8 @@
$items
=
array
(
"'self'"
,
// These are all bad for security, but they are needed for various things such as MathJax.
// These are all bad for security, but they are needed for various things such
// as MathJax.
"'unsafe-inline'"
,
"'unsafe-eval'"
,
'data:'
,
...
...
@@ -31,7 +32,7 @@ $sites = array(
'*.googletagmanager.com'
,
'*.googleusercontent.com'
,
// Additional Google. RT#584058.
'*.googleadservices.com'
,
'*.googleadservices.com'
,
// Google Analytics.
'*.g.doubleclick.net'
,
// Google's DoubleClick, for MSI's use.
...
...
@@ -86,7 +87,7 @@ $sites = array(
'*.ads.linkedin.com'
,
// Hootsuite Campaigns. RT#582824.
'*.hscampaigns.com'
,
// Used by MSI, confirmed by Joe Kwan
// Used by MSI, confirmed by Joe Kwan
.
'secure.adnxs.com'
,
);
while
(
$site
=
array_shift
(
$sites
))
{
...
...
install_from_db/install_from_db.install.inc
View file @
8697df09
...
...
@@ -31,23 +31,20 @@ function install_from_db_install_tasks_alter(&$tasks, $install_state) {
'run'
=>
INSTALL_TASK_RUN_IF_NOT_COMPLETED
,
);
// Add t
w
o taks before modules are install:
// Add to ta
s
ks before modules are install
ed
:
// 1. Install from database.
// 2. Finish install module function
// 3. Run update database.
// 4. Feature revert all.
$tasks
=
_install_from_db_insert_before_key
(
$tasks
,
'install_profile_modules'
,
'install_from_db_form'
,
$quickstart
);
$tasks
=
_install_from_db_insert_after_key
(
$tasks
,
'install_profile_modules'
,
'install_from_db_features_revert_all_batch'
,
$features_revert_all_batch
);
$tasks
=
_install_from_db_insert_after_key
(
$tasks
,
'install_profile_modules'
,
'install_from_db_update_batch'
,
$update_batch
);
// $tasks = _install_from_db_insert_after_key($tasks, 'install_profile_update_batch',
// 'install_from_db_features_revert_all_batch', $features_revert_all_batch);.
$tasks
=
_install_from_db_insert_before_key
(
$tasks
,
'install_profile_modules'
,
'install_from_db_form'
,
$quickstart
);
$tasks
=
_install_from_db_insert_after_key
(
$tasks
,
'install_profile_modules'
,
'install_from_db_features_revert_all_batch'
,
$features_revert_all_batch
);
$tasks
=
_install_from_db_insert_after_key
(
$tasks
,
'install_profile_modules'
,
'install_from_db_update_batch'
,
$update_batch
);
// $tasks = _install_from_db_insert_after_key($tasks, 'install_profile_update_batch', 'install_from_db_features_revert_all_batch', $features_revert_all_batch);.
}
/**
* Helper function to insert a key/value pair before an existing key
* Helper function to insert a key/value pair before an existing key.
*
* Used to re-order the install tasks array.
*/
function
_install_from_db_insert_before_key
(
$originalArray
,
$originalKey
,
$insertKey
,
$insertValue
)
{
...
...
@@ -64,7 +61,8 @@ function _install_from_db_insert_before_key($originalArray, $originalKey, $inser
}
/**
* Helper function to insert a key/value pair after an existing key
* Helper function to insert a key/value pair after an existing key.
*
* Used to re-order the install tasks array.
*/
function
_install_from_db_insert_after_key
(
$originalArray
,
$originalKey
,
$insertKey
,
$insertValue
)
{
...
...
@@ -129,7 +127,10 @@ function install_from_db_update_batch() {
// Add this update function to the batch.
$function
=
$update
[
'module'
]
.
'_update_'
.
$update
[
'number'
];
$functions
[]
=
$function
;
$operations
[]
=
array
(
'update_do_one'
,
array
(
$update
[
'module'
],
$update
[
'number'
],
$dependency_map
[
$function
]));
$operations
[]
=
array
(
'update_do_one'
,
array
(
$update
[
'module'
],
$update
[
'number'
],
$dependency_map
[
$function
]),
);
}
$batch
=
array
(
'operations'
=>
$operations
,
...
...
@@ -140,7 +141,7 @@ function install_from_db_update_batch() {
'file'
=>
'includes/update.inc'
,
);
if
(
!
$install_state
[
'interactive'
])
{
watchdog
(
'install'
,
count
(
$operations
)
.
'
updates to run.'
,
array
(),
WATCHDOG_INFO
);
watchdog
(
'install'
,
'@
count updates to run.'
,
array
(
'@count'
=>
count
(
$operations
)
),
WATCHDOG_INFO
);
print
count
(
$operations
)
.
" updates to run.
\n
"
;
if
(
count
(
$operations
))
{
...
...
@@ -180,7 +181,11 @@ function install_from_db_features_revert_all_batch() {
include_once
drupal_get_path
(
'module'
,
'features'
)
.
'/features.module'
;
$operations
=
array
();
// $restore_states = array(FEATURES_OVERRIDDEN, FEATURES_NEEDS_REVIEW);.
$restore_states
=
array
(
FEATURES_OVERRIDDEN
,
FEATURES_REBUILDABLE
,
FEATURES_NEEDS_REVIEW
);
$restore_states
=
array
(
FEATURES_OVERRIDDEN
,
FEATURES_REBUILDABLE
,
FEATURES_NEEDS_REVIEW
,
);
// Clear cache because an database update might have change something.
drupal_flush_all_caches
();
...
...
@@ -204,7 +209,7 @@ function install_from_db_features_revert_all_batch() {
}
}
if
(
!
$install_state
[
'interactive'
])
{
watchdog
(
'install'
,
count
(
$operations
)
.
'
features to revert.'
,
array
(),
WATCHDOG_INFO
);
watchdog
(
'install'
,
'@
count features to revert.'
,
array
(
'@count'
=>
count
(
$operations
)
),
WATCHDOG_INFO
);
print
count
(
$operations
)
.
" features have components to revert.
\n
"
;
}
$batch
=
array
(
...
...
@@ -234,9 +239,10 @@ function install_from_db_features_revert_all_batch_finished() {
}
/**
* Prompt user to select normal or quick installation method
* TODO: Check db to be sure it is mysql, or provide mechanism for
* using dumps of other database types.
* Prompt user to select normal or quick installation method.
*
* @todo: Check db to be sure it is mysql, or provide mechanism for using dumps
* of other database types.
*
* @see install_from_db_form_validate()
* @see install_from_db_form_submit()
...
...
@@ -313,9 +319,9 @@ function install_from_db_form_submit($form, &$form_state) {
}
/**
* Overrides install_profile_modules()
*
For quick install, load database from sql dump
* otherwise install normally.
* Overrides install_profile_modules()
.
*
*
For quick install, load database from sql dump
otherwise install normally.
*/
function
install_from_db_install_profile_modules
(
&
$install_state
)
{
if
(
!
empty
(
$install_state
[
'parameters'
][
'quickstart'
])
&&
(
$install_state
[
'parameters'
][
'quickstart'
]
===
'quick'
)
&&
!
empty
(
$install_state
[
'parameters'
][
'db_import_filename'
]))
{
...
...
@@ -382,6 +388,7 @@ function _install_from_db_install_db_import_finished($success, $results, $operat
/**
* Aggressively clear the cache so new database will take affect.
*
* Do this right after importing the new system module.
*/
function
_install_from_db_cc_all
()
{
...
...
@@ -421,7 +428,12 @@ function _install_from_db_install_db_import($line, $table, &$context) {
if
(
$table
===
'variable'
)
{
// save/restore some variables needed by installer or unique to new site.
$saved_vars
=
array
(
'install_task'
,
'install_current_batch'
,
'cron_key'
,
'drupal_private_key'
);
$saved_vars
=
array
(
'install_task'
,
'install_current_batch'
,
'cron_key'
,
'drupal_private_key'
,
);
foreach
(
$saved_vars
as
$var
)
{
$saved_values
[
$var
]
=
variable_get
(
$var
,
''
);
}
...
...
@@ -448,14 +460,15 @@ function _install_from_db_install_db_import($line, $table, &$context) {
}
/**
* Read a batch of sql commands (ending in commit)
* Read a batch of sql commands (ending in commit)
.
*
* @param $file
*
-
name of file to read from
* @param $table
*
-
name of table referenced in sql statements is returned
* @param
string
$file
*
The
name of file to read from
.
* @param
string
$table
*
The
name of table referenced in sql statements is returned
.
*
* @return - string containing sql commands for a single table.
* @return string
* A string containing sql commands for a single table.
*/
function
_install_from_db_read_sql_batch
(
$file
,
&
$table
)
{
$conn
=
Database
::
getConnection
(
'default'
);
...
...
@@ -590,17 +603,18 @@ function _install_from_db_replace_prefix($line, $conn) {
/**
* Finishes importing files at end of installation.
*
* COPIED from install.core.inc but no longer calls drupal_run_cron
* since we just installed the correct module versions for the distro
* that we desire.
*
* @param $install_state
* @param
array
$install_state
* An array of information about the current installation state.
*
* @return
* @return
string
* A message informing the user that the installation is complete.
*/
function
install_from_db_install_finished
(
&
$install_state
)
{
function
install_from_db_install_finished
(
array
&
$install_state
)
{
drupal_set_title
(
st
(
'@drupal installation complete'
,
array
(
'@drupal'
=>
drupal_install_profile_distribution_name
())),
PASS_THROUGH
);
$messages
=
drupal_set_message
();
$output
=
'<p>'
.
st
(
'Congratulations, you installed @drupal!'
,
array
(
'@drupal'
=>
drupal_install_profile_distribution_name
()))
.
'</p>'
;
...
...
install_from_db/install_from_db.module
View file @
8697df09
...
...
@@ -2,18 +2,20 @@
/**
* @file
* Install the profile from a database dump.
*
* Provides ability for installation profiles to install core modules from a
* database dump.
*
* Subprofiles module can extend the features to install afterwards.
*
* For interactive installs, the install from database can be selected before
the
* profile dependencies are install. If the install from database is not
selected
* then the normal batch will take place.
* For interactive installs, the install from database can be selected before
*
the
profile dependencies are install. If the install from database is not
*
selected
then the normal batch will take place.
*/
// Include only when in install mode. MAINTENANCE_MODE is defined in
//
install.php
and in drush_core_site_install().
// Include only when in install mode. MAINTENANCE_MODE is defined in
install.php
// and in drush_core_site_install().
if
(
defined
(
'MAINTENANCE_MODE'
)
&&
MAINTENANCE_MODE
==
'install'
)
{
include_once
'install_from_db.install.inc'
;
}
uw_base_profile.install
View file @
8697df09
...
...
@@ -2,6 +2,7 @@
/**
* @file
* Profile install file.
*/
/**
...
...
@@ -66,15 +67,25 @@ function uw_base_profile_install() {
'cache'
=>
-
1
,
),
);
$query
=
db_insert
(
'block'
)
->
fields
(
array
(
'module'
,
'delta'
,
'theme'
,
'status'
,
'weight'
,
'region'
,
'pages'
,
'cache'
));
$query
=
db_insert
(
'block'
)
->
fields
(
array
(
'module'
,
'delta'
,
'theme'
,
'status'
,
'weight'
,
'region'
,
'pages'
,
'cache'
,
));
foreach
(
$values
as
$record
)
{
$query
->
values
(
$record
);
}
$query
->
execute
();
// Create an image field named "Image", enabled for the 'article' content type.
// Many of the following values will be defaulted, they're included here as an illustrative examples.
// See http://api.drupal.org/api/function/field_create_field/7
// Create an image field named "Image", enabled for the 'article' content
// type. Many of the following values will be defaulted, they're included here
// as an illustrative examples. See:
// http://api.drupal.org/api/function/field_create_field/7
$field
=
array
(
'field_name'
=>
'field_image'
,
'type'
=>
'image'
,
...
...
@@ -103,6 +114,11 @@ function uw_base_profile_install() {
menu_link_save
(
$item
);
// Enable themes and set default on new installs.
theme_enable
(
array
(
'uw_fdsu_theme'
,
'uw_adminimal_theme'
,
'adminimal'
,
'uw_fdsu_theme_resp'
));
theme_enable
(
array
(
'uw_fdsu_theme'
,
'uw_adminimal_theme'
,
'adminimal'
,
'uw_fdsu_theme_resp'
,
));
variable_set
(
'theme_default'
,
'uw_fdsu_theme_resp'
);
}
uw_base_profile.profile
View file @
8697df09
...
...
@@ -2,14 +2,16 @@
/**
* @file
*
Add global for $install_from_db so it gets referenced correctly in a later function
.
*
Profile file
.
*/
global
$install_from_db
;
// Add global for $_uw_base_profile_install_from_db so it gets referenced correctly in a later
// function.
global
$_uw_base_profile_install_from_db
;
// Set to FALSE to create a new database export.
$install_from_db
=
FALSE
;
$
_uw_base_profile_
install_from_db
=
FALSE
;
if
(
$install_from_db
)
{
if
(
$
_uw_base_profile_
install_from_db
)
{
include_once
'install_from_db/install_from_db.install.inc'
;
}
...
...
@@ -92,11 +94,11 @@ function uw_base_profile_install_tasks(&$install_state) {
}
/**
* Implements hook_install_tasks_alter()
* Implements hook_install_tasks_alter()
.
*/
function
uw_base_profile_install_tasks_alter
(
&
$tasks
,
$install_state
)
{
global
$install_from_db
;
if
(
$install_from_db
)
{
global
$
_uw_base_profile_
install_from_db
;
if
(
$
_uw_base_profile_
install_from_db
)
{
install_from_db_install_tasks_alter
(
$tasks
,
$install_state
);
}
}
...
...
@@ -118,9 +120,11 @@ function uw_base_profile_features_revert_all() {
global
$install_state
;
drupal_set_time_limit
(
0
);
// Revert specific feature sections before reverting them all.
// @code
// features_revert(array(
// 'feature_name' => array('feature_section1', 'feature_section2'),
// ));.
// 'feature_name' => array('feature_section1', 'feature_section2'),
// ));
// @endcode
features_revert
();
}
...
...
@@ -133,9 +137,14 @@ function uw_base_profile_node_access_rebuild() {
}
/**
* Task callback: returns the form allowing the user to turn on features at install time.
* Made the content types and dev. modules checked by default (#default_value => TRUE)
* to speed up site creation time for local development (Dec, 15 2012).
* Task callback.
*
* Returns the form allowing the user to turn on features at install time. Made
* the content types and dev. modules checked by default (#default_value =>
* TRUE) to speed up site creation time for local development (Dec, 15 2012).
*
* @return array
* The form array.
*/
function
uw_select_site_features_form
()
{
drupal_set_title
(
st
(
'Enable features'
));
...
...
@@ -489,10 +498,13 @@ function uw_create_default_content_form_submit(&$form, &$form_state) {
}
/**
* Given an array where key => module_name and value => TRUE/FALSE,
* enables those modules.
* Enable a bunch of modules.
*
* @param array $modules
* Given an array where key => module_name and value => TRUE/FALSE, enables
* those modules.
*/
function
_uw_base_profile_enable_modules
(
$modules
=
array
())
{
function
_uw_base_profile_enable_modules
(
array
$modules
=
array
())
{
$module_list
=
array
();
foreach
(
$modules
as
$key
=>
$value
)
{
if
(
$value
)
{
...
...
@@ -505,10 +517,12 @@ function _uw_base_profile_enable_modules($modules = array()) {
}
/**
* Set language for content.
*
* @param string $langcode
* The language code.
*/
function
_uw_base_profile_set_content_language
(
$langcode
)
{
$install_languages
=
language_list
();
// Add English language if it does not exist (Probably do not need to check).
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment