/**
     * Tests the drupal_rewrite_settings() function.
     */
    function testDrupalRewriteSettings()
    {
        include_once DRUPAL_ROOT . '/core/includes/install.inc';
        $tests = array(array('original' => '$no_index_value_scalar = TRUE;', 'settings' => array('no_index_value_scalar' => (object) array('value' => FALSE, 'comment' => 'comment')), 'expected' => '$no_index_value_scalar = false; // comment'), array('original' => '$no_index_value_scalar = TRUE;', 'settings' => array('no_index_value_foo' => array('foo' => array('value' => (object) array('value' => NULL, 'required' => TRUE, 'comment' => 'comment')))), 'expected' => <<<'EXPECTED'
$no_index_value_scalar = TRUE;
$no_index_value_foo['foo']['value'] = NULL; // comment
EXPECTED
), array('original' => '$no_index_value_array = array("old" => "value");', 'settings' => array('no_index_value_array' => (object) array('value' => FALSE, 'required' => TRUE, 'comment' => 'comment')), 'expected' => '$no_index_value_array = array("old" => "value");
$no_index_value_array = false; // comment'), array('original' => '$has_index_value_scalar["foo"]["bar"] = NULL;', 'settings' => array('has_index_value_scalar' => array('foo' => array('bar' => (object) array('value' => FALSE, 'required' => TRUE, 'comment' => 'comment')))), 'expected' => '$has_index_value_scalar["foo"]["bar"] = false; // comment'), array('original' => '$has_index_value_scalar["foo"]["bar"] = "foo";', 'settings' => array('has_index_value_scalar' => array('foo' => array('value' => (object) array('value' => array('value' => 2), 'required' => TRUE, 'comment' => 'comment')))), 'expected' => <<<'EXPECTED'
$has_index_value_scalar["foo"]["bar"] = "foo";
$has_index_value_scalar['foo']['value'] = array (
  'value' => 2,
); // comment
EXPECTED
));
        foreach ($tests as $test) {
            $filename = Settings::get('file_public_path', conf_path() . '/files') . '/mock_settings.php';
            file_put_contents(DRUPAL_ROOT . '/' . $filename, "<?php\n" . $test['original'] . "\n");
            drupal_rewrite_settings($test['settings'], $filename);
            $this->assertEqual(file_get_contents(DRUPAL_ROOT . '/' . $filename), "<?php\n" . $test['expected'] . "\n");
        }
        // Test that <?php gets added to the start of an empty settings file.
        // Set the array of settings that will be written to the file.
        $test = array('settings' => array('no_index' => (object) array('value' => TRUE, 'required' => TRUE)), 'expected' => '$no_index = true;');
        // Make an empty file.
        $filename = Settings::get('file_public_path', conf_path() . '/files') . '/mock_settings.php';
        file_put_contents(DRUPAL_ROOT . '/' . $filename, "");
        // Write the setting to the file.
        drupal_rewrite_settings($test['settings'], $filename);
        // Check that the result is just the php opening tag and the settings.
        $this->assertEqual(file_get_contents(DRUPAL_ROOT . '/' . $filename), "<?php\n" . $test['expected'] . "\n");
    }
 /**
  * Returns the kernel parameters.
  *
  * @return array An array of kernel parameters
  */
 protected function getKernelParameters()
 {
     $parameters = parent::getKernelParameters();
     $parameters['kernel.drupal_root'] = DRUPAL_ROOT;
     $parameters['kernel.conf_path'] = conf_path();
     return $parameters;
 }
 /**
  * Test local directory handling functions.
  */
 function testFileCheckLocalDirectoryHandling()
 {
     $directory = conf_path() . '/files';
     // Check a new recursively created local directory for correct file system
     // permissions.
     $parent = $this->randomMachineName();
     $child = $this->randomMachineName();
     // Files directory already exists.
     $this->assertTrue(is_dir($directory), t('Files directory already exists.'), 'File');
     // Make files directory writable only.
     $old_mode = fileperms($directory);
     // Create the directories.
     $parent_path = $directory . DIRECTORY_SEPARATOR . $parent;
     $child_path = $parent_path . DIRECTORY_SEPARATOR . $child;
     $this->assertTrue(drupal_mkdir($child_path, 0775, TRUE), t('No error reported when creating new local directories.'), 'File');
     // Ensure new directories also exist.
     $this->assertTrue(is_dir($parent_path), t('New parent directory actually exists.'), 'File');
     $this->assertTrue(is_dir($child_path), t('New child directory actually exists.'), 'File');
     // Check that new directory permissions were set properly.
     $this->assertDirectoryPermissions($parent_path, 0775);
     $this->assertDirectoryPermissions($child_path, 0775);
     // Check that existing directory permissions were not modified.
     $this->assertDirectoryPermissions($directory, $old_mode);
     // Check creating a directory using an absolute path.
     $absolute_path = drupal_realpath($directory) . DIRECTORY_SEPARATOR . $this->randomMachineName() . DIRECTORY_SEPARATOR . $this->randomMachineName();
     $this->assertTrue(drupal_mkdir($absolute_path, 0775, TRUE), 'No error reported when creating new absolute directories.', 'File');
     $this->assertDirectoryPermissions($absolute_path, 0775);
 }
 protected function urlToFileEntity($url)
 {
     $url = urldecode(DRUPAL_ROOT . EntityPathHelper::normalizeUrl($url));
     if (file_exists($url)) {
         // Get the filename.
         $filename = pathinfo($url, PATHINFO_FILENAME) . '.' . pathinfo($url, PATHINFO_EXTENSION);
         $filesize = filesize($url);
         $files = db_select('file_managed', 'f')->fields('f', array('fid', 'uri', 'filesize'))->condition('filename', $filename)->condition('filesize', $filesize)->execute();
         $found_fid = -1;
         while ($row = $files->fetch()) {
             $result_uri = drupal_realpath($row->uri);
             if ($result_uri == drupal_realpath($url)) {
                 $found_fid = $row->fid;
                 break;
             }
         }
         if ($found_fid !== -1) {
             return Entity::load($found_fid, 'file');
         } else {
             // Create the file entity.
             if ($contents = file_get_contents($url)) {
                 $public_files_directory = DRUPAL_ROOT . '/' . variable_get('file_public_path', conf_path() . '/files') . '/';
                 $schema_url = 'public://' . str_replace($public_files_directory, '', $url);
                 // This will basically re-create the same file with the same filename, so we don't
                 // need to check to see if the file already exists because we don't care to replace
                 // the file with itself.
                 $file = file_save_data($contents, $schema_url, FILE_EXISTS_REPLACE);
                 return Entity::load($file->fid, 'file');
             }
         }
     }
     return false;
 }
 /**
  * An extension control for dynamic forms that adds a box to output hints on any
  * species selected for addition to the species checklist grid. To use this control
  * provide a file called speciesHints.json in the Drupal file path, within the indicia
  * subfolder. This should contain a JSON object with the property names matching the
  * external keys of the taxa_taxon_list table, and the property values being the hint
  * string to show.
  */
 public static function add_species_hints($auth, $args, $tabalias, $options, $path)
 {
     // enable nice tooltips
     //drupal_add_library('system', 'ui.tooltip', true);
     $filePath = variable_get('file_public_path', conf_path() . '/files');
     data_entry_helper::$javascript .= "initSpeciesHints('{$filePath}/indicia/speciesHints.json');\n";
     return '<h3>' . lang::get('Hints relating to species names entered') . '</h3> ' . '<div id="species-hints"></div>';
 }
Example #6
0
 /**
  * do not change
  */
 private function __construct()
 {
     $this->defaults = array('width' => '300px', 'height' => '200px', 'zoom' => 3, 'maxzoom' => 14, 'controltype' => 'Small', 'pancontrol' => 1, 'streetviewcontrol' => 0, 'align' => 'None', 'latlong' => '40,0', 'maptype' => 'Map', 'mtc' => 'standard', 'baselayers' => array('Map', 'Satellite', 'Hybrid'), 'styles' => array('line_default' => array('0000ff', 5, 45, '', 0, 0), 'poly_default' => array('000000', 3, 25, 'ff0000', 45), 'highlight_color' => 'ff0000'), 'line_colors' => array('#00cc00', '#ff0000', '#0000ff'));
     $this->defaults['behavior'] = array();
     // @todo refactor this for removal
     $m = array();
     // @todo convert to class GmapBehaviours or method addBehavior
     $behaviors = gmap_module_invoke('behaviors', $m);
     foreach ($behaviors as $k => $v) {
         $this->defaults['behavior'][$k] = $v['default'];
     }
     $this->defaults = array_merge($this->defaults, variable_get('gmap_default', array()));
     // former _gmap_base_js()
     $this->basejs = array();
     $path = drupal_get_path('module', 'gmap');
     // Convert some language codes.
     // For Google Maps API v3, the drupal language code is not always the same as the google language code.
     // @see https://developers.google.com/maps/documentation/javascript/basics#Localization
     global $language;
     switch ($language->language) {
         case 'zh-hans':
             // 'Chinese, Simplified'
             $langcode = 'zh-CN';
             break;
         case 'zh-hant':
             // 'Chinese, Traditional'
             $langcode = 'zh-TW';
             break;
         case 'he':
             // Hebrew
             $langcode = 'iw';
             break;
         case 'nb':
             // 'Norwegian Bokm�l', 'Bokm�l'
         // 'Norwegian Bokm�l', 'Bokm�l'
         case 'nn':
             // 'Norwegian Nynorsk', 'Nynorsk'
             $langcode = 'no';
             // 'Norwegian'
             break;
         default:
             $langcode = $language->language;
             break;
     }
     $m = array();
     $query = array('v' => variable_get('gmap_api_version', GMAP_API_VERSION), 'language' => $langcode, 'sensor' => 'false', 'libraries' => implode(array_merge(variable_get('gmap_api_libraries', array()), gmap_module_invoke('libraries', $m)), ','));
     if ($key = gmap_get_key()) {
         $query['key'] = $key;
     }
     $this->basejs[$path . '/js/gmap.js'] = array('weight' => 1);
     $this->basejs[$path . '/js/icon.js'] = array('weight' => 2);
     $this->basejs[$path . '/js/marker.js'] = array('weight' => 2);
     $this->basejs[$path . '/js/highlight.js'] = array('weight' => 2);
     $this->basejs[$path . '/js/poly.js'] = array('weight' => 2);
     $this->basejs[url(gmap_views_protocol() . '://maps.googleapis.com/maps/' . 'api/js', array('query' => $query))] = array('type' => 'external', 'weight' => 1);
     $this->basejs[base_path() . variable_get('file_public_path', conf_path() . '/files') . '/js/gmap_markers.js'] = array('type' => 'external', 'weight' => 4);
 }
 /**
  * Test read-only specific behavior.
  */
 function testReadOnlyBehavior()
 {
     // Generate a test file
     $filename = $this->randomMachineName();
     $filepath = conf_path() . '/files/' . $filename;
     file_put_contents($filepath, $filename);
     // Generate a read-only stream wrapper instance
     $uri = $this->scheme . '://' . $filename;
     file_stream_wrapper_get_instance_by_scheme($this->scheme);
     // Attempt to open a file in read/write mode
     $handle = @fopen($uri, 'r+');
     $this->assertFalse($handle, 'Unable to open a file for reading and writing with the read-only stream wrapper.');
     // Attempt to open a file in binary read mode
     $handle = fopen($uri, 'rb');
     $this->assertTrue($handle, 'Able to open a file for reading in binary mode with the read-only stream wrapper.');
     $this->assertTrue(fclose($handle), 'Able to close file opened in binary mode using the read_only stream wrapper.');
     // Attempt to open a file in text read mode
     $handle = fopen($uri, 'rt');
     $this->assertTrue($handle, 'Able to open a file for reading in text mode with the read-only stream wrapper.');
     $this->assertTrue(fclose($handle), 'Able to close file opened in text mode using the read_only stream wrapper.');
     // Attempt to open a file in read mode
     $handle = fopen($uri, 'r');
     $this->assertTrue($handle, 'Able to open a file for reading with the read-only stream wrapper.');
     // Attempt to change file permissions
     $this->assertFalse(@chmod($uri, 0777), 'Unable to change file permissions when using read-only stream wrapper.');
     // Attempt to acquire an exclusive lock for writing
     $this->assertFalse(@flock($handle, LOCK_EX | LOCK_NB), 'Unable to acquire an exclusive lock using the read-only stream wrapper.');
     // Attempt to obtain a shared lock
     $this->assertTrue(flock($handle, LOCK_SH | LOCK_NB), 'Able to acquire a shared lock using the read-only stream wrapper.');
     // Attempt to release a shared lock
     $this->assertTrue(flock($handle, LOCK_UN | LOCK_NB), 'Able to release a shared lock using the read-only stream wrapper.');
     // Attempt to truncate the file
     $this->assertFalse(@ftruncate($handle, 0), 'Unable to truncate using the read-only stream wrapper.');
     // Attempt to write to the file
     $this->assertFalse(@fwrite($handle, $this->randomMachineName()), 'Unable to write to file using the read-only stream wrapper.');
     // Attempt to flush output to the file
     $this->assertFalse(@fflush($handle), 'Unable to flush output to file using the read-only stream wrapper.');
     // Attempt to close the stream.  (Suppress errors, as fclose triggers fflush.)
     $this->assertTrue(fclose($handle), 'Able to close file using the read_only stream wrapper.');
     // Test the rename() function
     $this->assertFalse(@rename($uri, $this->scheme . '://newname.txt'), 'Unable to rename files using the read-only stream wrapper.');
     // Test the unlink() function
     $this->assertTrue(@drupal_unlink($uri), 'Able to unlink file using read-only stream wrapper.');
     $this->assertTrue(file_exists($filepath), 'Unlink File was not actually deleted.');
     // Test the mkdir() function by attempting to create a directory.
     $dirname = $this->randomMachineName();
     $dir = conf_path() . '/files/' . $dirname;
     $readonlydir = $this->scheme . '://' . $dirname;
     $this->assertFalse(@drupal_mkdir($readonlydir, 0775, 0), 'Unable to create directory with read-only stream wrapper.');
     // Create a temporary directory for testing purposes
     $this->assertTrue(drupal_mkdir($dir), 'Test directory created.');
     // Test the rmdir() function by attempting to remove the directory.
     $this->assertFalse(@drupal_rmdir($readonlydir), 'Unable to delete directory with read-only stream wrapper.');
     // Remove the temporary directory.
     drupal_rmdir($dir);
 }
 /**
  * Returns the current stream used to import and export configurations.
  * Default value is config://
  *
  * @return string
  */
 public static function getStream()
 {
     $temp_stream = static::$stream;
     // During the install process strema wrappers are to available so this is
     // a work around.
     if (!file_stream_wrapper_get_instance_by_uri($temp_stream)) {
         $temp_stream = variable_get('configuration_config_path', conf_path() . '/files/config');
     }
     return $temp_stream;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $conf_path = './' . conf_path(FALSE);
     $settings_file = $conf_path . '/settings.php';
     $form['#title'] = $this->t('Database configuration');
     $drivers = drupal_get_database_types();
     $drivers_keys = array_keys($drivers);
     // Unless there is input for this form (for a non-interactive installation,
     // input originates from the $settings array passed into install_drupal()),
     // check whether database connection settings have been prepared in
     // settings.php already.
     // Note: The installer even executes this form if there is a valid database
     // connection already, since the submit handler of this form is responsible
     // for writing all $settings to settings.php (not limited to $databases).
     $input =& $form_state->getUserInput();
     if (!isset($input['driver']) && ($database = Database::getConnectionInfo())) {
         $input['driver'] = $database['default']['driver'];
         $input[$database['default']['driver']] = $database['default'];
     }
     if (isset($input['driver'])) {
         $default_driver = $input['driver'];
         // In case of database connection info from settings.php, as well as for a
         // programmed form submission (non-interactive installer), the table prefix
         // information is usually normalized into an array already, but the form
         // element only allows to configure one default prefix for all tables.
         $prefix =& $input[$default_driver]['prefix'];
         if (isset($prefix) && is_array($prefix)) {
             $prefix = $prefix['default'];
         }
         $default_options = $input[$default_driver];
     } else {
         $default_driver = current($drivers_keys);
         $default_options = array();
     }
     $form['driver'] = array('#type' => 'radios', '#title' => $this->t('Database type'), '#required' => TRUE, '#default_value' => $default_driver);
     if (count($drivers) == 1) {
         $form['driver']['#disabled'] = TRUE;
     }
     // Add driver specific configuration options.
     foreach ($drivers as $key => $driver) {
         $form['driver']['#options'][$key] = $driver->name();
         $form['settings'][$key] = $driver->getFormOptions($default_options);
         $form['settings'][$key]['#prefix'] = '<h2 class="js-hide">' . $this->t('@driver_name settings', array('@driver_name' => $driver->name())) . '</h2>';
         $form['settings'][$key]['#type'] = 'container';
         $form['settings'][$key]['#tree'] = TRUE;
         $form['settings'][$key]['advanced_options']['#parents'] = array($key);
         $form['settings'][$key]['#states'] = array('visible' => array(':input[name=driver]' => array('value' => $key)));
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['save'] = array('#type' => 'submit', '#value' => $this->t('Save and continue'), '#button_type' => 'primary', '#limit_validation_errors' => array(array('driver'), array($default_driver)), '#submit' => array('::submitForm'));
     $form['errors'] = array();
     $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file);
     return $form;
 }
Example #10
0
 /**
  * Implements \SiteAudit\Check\Abstract\calculateScore().
  */
 public function calculateScore()
 {
     $drupal_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
     exec('du -s -k -x ' . $drupal_root . '/' . variable_get('file_public_path', conf_path() . '/files') . '/', $result);
     $size_files_kb_exploded = explode("\t", trim($result[0]));
     $this->registry['size_files_kb'] = $size_files_kb_exploded[0];
     if (!$this->registry['size_files_kb']) {
         $this->abort = TRUE;
         return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
     }
     return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function getFormOptions(array $database)
 {
     $form = parent::getFormOptions($database);
     // Remove the options that only apply to client/server style databases.
     unset($form['username'], $form['password'], $form['advanced_options']['host'], $form['advanced_options']['port']);
     // Make the text more accurate for SQLite.
     $form['database']['#title'] = t('Database file');
     $form['database']['#description'] = t('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
     $default_database = conf_path(FALSE) . '/files/.ht.sqlite';
     $form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database'];
     return $form;
 }
Example #12
0
/**
 * Checking permissions on files and folders.
 */
function check_permission()
{
    $conf_dir = drupal_verify_install_file(conf_path(), FILE_NOT_WRITABLE, 'dir');
    if (!$conf_dir) {
        $data = '<li>' . t('The directory %file is not protected from modifications and poses a security risk. You must change the directory\'s permissions to be non-writable. ', array('%file' => conf_path())) . '</li>';
        fwrite($GLOBALS['createdFile'], $data);
    }
    $conf_file = drupal_verify_install_file(conf_path() . '/settings.php', FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE);
    if (!$conf_file) {
        $data = '<li>' . t('The file %file is not protected from modifications and poses a security risk. You must change the file\'s permissions to be non-writable.', array('%file' => conf_path() . '/settings.php')) . '</li>';
        fwrite($GLOBALS['createdFile'], $data);
    }
}
Example #13
0
 public static function backupDatabase()
 {
     self::$database_dump = self::directory_cache('db_dumps') . '/' . basename(conf_path()) . '-' . REQUEST_TIME . '.sql';
     if (!file_exists(self::$database_dump)) {
         $cmd = sprintf('%s sql-dump --uri=%s --root=%s --result-file=%s', UNISH_DRUSH, UPAL_WEB_URL, UPAL_ROOT, self::$database_dump);
         exec($cmd, $output, $return);
         if ($return) {
             echo "Failed to create database backup.\n";
             echo $output;
             exit(1);
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form['#title'] = $this->t('Configure site');
     // Warn about settings.php permissions risk
     $settings_dir = conf_path();
     $settings_file = $settings_dir . '/settings.php';
     // Check that $_POST is empty so we only show this message when the form is
     // first displayed, not on the next page after it is submitted. (We do not
     // want to repeat it multiple times because it is a general warning that is
     // not related to the rest of the installation process; it would also be
     // especially out of place on the last page of the installer, where it would
     // distract from the message that the Drupal installation has completed
     // successfully.)
     $post_params = $this->getRequest()->request->all();
     if (empty($post_params) && (!drupal_verify_install_file(DRUPAL_ROOT . '/' . $settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file(DRUPAL_ROOT . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
         drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href="@handbook_url">online handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'warning');
     }
     $form['#attached']['library'][] = 'system/drupal.system';
     // Add JavaScript time zone detection.
     $form['#attached']['library'][] = 'core/drupal.timezone';
     // We add these strings as settings because JavaScript translation does not
     // work during installation.
     $js = array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail')));
     $form['#attached']['js'][] = array('data' => $js, 'type' => 'setting');
     // Cache a fully-built schema. This is necessary for any invocation of
     // index.php because: (1) setting cache table entries requires schema
     // information, (2) that occurs during bootstrap before any module are
     // loaded, so (3) if there is no cached schema, drupal_get_schema() will
     // try to generate one but with no loaded modules will return nothing.
     //
     // @todo Move this to the 'install_finished' task?
     drupal_get_schema(NULL, TRUE);
     $form['site_information'] = array('#type' => 'fieldgroup', '#title' => $this->t('Site information'));
     $form['site_information']['site_name'] = array('#type' => 'textfield', '#title' => $this->t('Site name'), '#required' => TRUE, '#weight' => -20);
     $form['site_information']['site_mail'] = array('#type' => 'email', '#title' => $this->t('Site email address'), '#default_value' => ini_get('sendmail_from'), '#description' => $this->t("Automated emails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these emails from being flagged as spam."), '#required' => TRUE, '#weight' => -15);
     $form['admin_account'] = array('#type' => 'fieldgroup', '#title' => $this->t('Site maintenance account'));
     $form['admin_account']['account']['name'] = array('#type' => 'textfield', '#title' => $this->t('Username'), '#maxlength' => USERNAME_MAX_LENGTH, '#description' => $this->t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'), '#required' => TRUE, '#attributes' => array('class' => array('username')));
     $form['admin_account']['account']['pass'] = array('#type' => 'password_confirm', '#required' => TRUE, '#size' => 25);
     $form['admin_account']['account']['#tree'] = TRUE;
     $form['admin_account']['account']['mail'] = array('#type' => 'email', '#title' => $this->t('Email address'), '#required' => TRUE);
     $form['regional_settings'] = array('#type' => 'fieldgroup', '#title' => $this->t('Regional settings'));
     $countries = $this->countryManager->getList();
     $form['regional_settings']['site_default_country'] = array('#type' => 'select', '#title' => $this->t('Default country'), '#empty_value' => '', '#default_value' => $this->config('system.date')->get('country.default'), '#options' => $countries, '#description' => $this->t('Select the default country for the site.'), '#weight' => 0);
     $form['regional_settings']['date_default_timezone'] = array('#type' => 'select', '#title' => $this->t('Default time zone'), '#default_value' => date_default_timezone_get(), '#options' => system_time_zones(), '#description' => $this->t('By default, dates in this site will be displayed in the chosen time zone.'), '#weight' => 5, '#attributes' => array('class' => array('timezone-detect')));
     $form['update_notifications'] = array('#type' => 'fieldgroup', '#title' => $this->t('Update notifications'));
     $form['update_notifications']['update_status_module'] = array('#type' => 'checkboxes', '#title' => $this->t('Update notifications'), '#options' => array(1 => $this->t('Check for updates automatically'), 2 => $this->t('Receive email notifications')), '#default_value' => array(1, 2), '#description' => $this->t('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href="@drupal">Drupal.org</a>.', array('@drupal' => 'http://drupal.org')), '#weight' => 15);
     $form['update_notifications']['update_status_module'][2] = array('#states' => array('visible' => array('input[name="update_status_module[1]"]' => array('checked' => TRUE))));
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save and continue'), '#weight' => 15, '#button_type' => 'primary');
     return $form;
 }
Example #15
0
 /**
  * @param string $connection
  *   Database connection name (key in $databases array from settings.php).
  */
 public function __construct($connection)
 {
     if (!defined('DRUPAL_ROOT') || !function_exists('conf_path')) {
         throw new \RuntimeException('Drupal is not bootstrapped.');
     }
     $databases = [];
     require sprintf('%s/%s/settings.php', DRUPAL_ROOT, conf_path());
     if (empty($databases[$connection])) {
         throw new \InvalidArgumentException(sprintf('The "%s" database connection does not exist.', $connection));
     }
     $db = $databases[$connection]['default'];
     $this->db = new Operator($db['username'], $db['password'], $db['host'], $db['port']);
     $this->source = $db['database'];
     $this->temporary = "tqextension_{$this->source}";
 }
Example #16
0
/**
 * @param $vars
 */
function cni_preprocess_html(&$vars)
{
    $base_path = base_path();
    $conf_path = conf_path();
    $site_css = $base_path . $conf_path . '/cni-site.css';
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . $site_css)) {
        drupal_add_css($site_css, array('type' => 'file', 'media' => 'all', 'preprocess' => false, 'every_page' => true, 'weight' => 999, 'group' => CSS_THEME));
    }
    /* Add Page Body Class */
    $path = drupal_get_path_alias($_GET['q']);
    $aliases = explode('/', $path);
    foreach ($aliases as $alias) {
        $vars['classes_array'][] = drupal_clean_css_identifier($alias);
    }
}
Example #17
0
 function test_foundation_css_injection()
 {
     // check if foundation css file is included in css drupal list :
     // we look for a {themename}/css/app.css ( included by foundation plugin)
     // or a files/okcdesign/{themename}/user_app.css included by foundation_ui plugin.
     $styles = drupal_add_css();
     $foundation_css = drupal_get_path('theme', variable_get('theme_default')) . '/css/app.css';
     // if foundation_ui is enabled && its generated file is readable, we load user_app.css instead.
     if (theme_plugin_is_enabled('foundation_ui')) {
         $user_foundation_css = variable_get('file_public_path', conf_path() . '/files') . '/okcdesign/' . variable_get('theme_default', 'okcdesign') . '/user_app.css';
         if (is_readable($user_foundation_css)) {
             $foundation_css = $user_foundation_css;
         }
     }
     $this->assertArrayHasKey($foundation_css, $styles, "foundation app.css not injected in Drupal ! ");
 }
 /**
  * {@inheritdoc}
  *
  * Configures a preexisting settings.php file without an install_profile
  * setting before invoking the interactive installer.
  */
 protected function setUp()
 {
     // Pre-configure hash salt.
     // Any string is valid, so simply use the class name of this test.
     $this->settings['settings']['hash_salt'] = (object) array('value' => __CLASS__, 'required' => TRUE);
     // Pre-configure database credentials.
     $connection_info = Database::getConnectionInfo();
     unset($connection_info['default']['pdo']);
     unset($connection_info['default']['init_commands']);
     $this->settings['databases']['default'] = (object) array('value' => $connection_info, 'required' => TRUE);
     // Pre-configure config directories.
     $this->settings['config_directories'] = array(CONFIG_ACTIVE_DIRECTORY => (object) array('value' => conf_path() . '/files/config_active', 'required' => TRUE), CONFIG_STAGING_DIRECTORY => (object) array('value' => conf_path() . '/files/config_staging', 'required' => TRUE));
     mkdir($this->settings['config_directories'][CONFIG_ACTIVE_DIRECTORY]->value, 0777, TRUE);
     mkdir($this->settings['config_directories'][CONFIG_STAGING_DIRECTORY]->value, 0777, TRUE);
     parent::setUp();
 }
/**
 * Lazy loads the google calendar service
 *
 * @return Google_Service_Calendar
 */
function cob_calendar_service()
{
    static $client = null;
    static $service = null;
    if (!$service) {
        if (!$client) {
            libraries_load('google-api-php-client');
            $json = json_decode(file_get_contents(DRUPAL_ROOT . '/' . conf_path() . '/credentials.json'));
            $credentials = new \Google_Auth_AssertionCredentials($json->client_email, ['https://www.googleapis.com/auth/calendar.readonly'], $json->private_key);
            $credentials->sub = variable_get('cob_google_email');
            $client = new \Google_Client();
            $client->setClassConfig('Google_Cache_File', 'directory', DRUPAL_ROOT . '/' . conf_path() . '/files/Google_Client');
            $client->setAssertionCredentials($credentials);
            if ($client->getAuth()->isAccessTokenExpired()) {
                $client->getAuth()->refreshTokenWithAssertion();
            }
        }
        $service = new \Google_Service_Calendar($client);
    }
    return $service;
}
 /**
  * {@inheritdoc}
  *
  * Fully configures a preexisting settings.php file before invoking the
  * interactive installer.
  */
 protected function setUp()
 {
     // Pre-configure hash salt.
     // Any string is valid, so simply use the class name of this test.
     $this->settings['settings']['hash_salt'] = (object) array('value' => __CLASS__, 'required' => TRUE);
     // Actually the install profile should be skipped to because it is written
     // to settings.php.
     // @todo https://www.drupal.org/node/2451369 Fix install_profile so that it
     //   is written to an existing settings.php if possible or if set used.
     $this->settings['settings']['install_profile'] = (object) array('value' => 'testing', 'required' => TRUE);
     // Pre-configure database credentials.
     $connection_info = Database::getConnectionInfo();
     unset($connection_info['default']['pdo']);
     unset($connection_info['default']['init_commands']);
     $this->settings['databases']['default'] = (object) array('value' => $connection_info, 'required' => TRUE);
     // Pre-configure config directories.
     $this->settings['config_directories'] = array(CONFIG_ACTIVE_DIRECTORY => (object) array('value' => conf_path() . '/files/config_active', 'required' => TRUE), CONFIG_STAGING_DIRECTORY => (object) array('value' => conf_path() . '/files/config_staging', 'required' => TRUE));
     mkdir($this->settings['config_directories'][CONFIG_ACTIVE_DIRECTORY]->value, 0777, TRUE);
     mkdir($this->settings['config_directories'][CONFIG_STAGING_DIRECTORY]->value, 0777, TRUE);
     parent::setUp();
 }
 /**
  * Collects data for the given Request and Response.
  *
  * @param Request    $request   A Request instance
  * @param Response   $response  A Response instance
  * @param \Exception $exception An Exception instance
  *
  * @api
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     if ($this->matcher->matches($request)) {
         $this->data = array('bootstrap' => function_exists('drupal_get_bootstrap_phase') ? drupal_get_bootstrap_phase() : -1, 'base_url' => $GLOBALS['base_url'], 'base_path' => $GLOBALS['base_path'], 'base_root' => $GLOBALS['base_root'], 'conf_path' => conf_path(), 'queries' => array());
         // Load .install files
         include_once DRUPAL_ROOT . '/includes/install.inc';
         drupal_load_updates();
         // Check run-time requirements and status information.
         $requirements = module_invoke_all('requirements', 'runtime');
         usort($requirements, '_system_sort_requirements');
         $this->data['requirements'] = $requirements;
         $this->data['severity'] = drupal_requirements_severity($requirements);
         $this->data['status_report'] = theme('status_report', array('requirements' => $requirements));
         if (isset($GLOBALS['databases']) && is_array($GLOBALS['databases'])) {
             foreach (array_keys($GLOBALS['databases']) as $key) {
                 $this->data['queries'][$key] = \Database::getLog('devel', $key);
             }
         }
     } else {
         $this->data = false;
     }
 }
Example #22
0
function unl_reset_site_submit($form, &$form_state)
{
    $nids = db_select('node', 'n')->fields('n', array('nid'))->execute()->fetchCol();
    node_delete_multiple($nids);
    variable_set('site_frontpage', 'node');
    $mlids = db_select('menu_links', 'm')->fields('m', array('mlid'))->condition('m.menu_name', 'main-menu')->execute()->fetchCol();
    foreach ($mlids as $mlid) {
        menu_link_delete($mlid);
    }
    $home_link = array('link_path' => '<front>', 'link_title' => 'Home', 'menu_name' => 'main-menu', 'module' => 'menu');
    menu_link_save($home_link);
    $fids = db_select('file_managed', 'f')->fields('f', array('fid'))->execute()->fetchCol();
    $files = file_load_multiple($fids);
    foreach ($files as $file) {
        file_delete($file);
    }
    $files_dir = DRUPAL_ROOT . '/' . conf_path() . '/files/';
    $cmd = 'rm -rf ' . $files_dir . '*';
    echo shell_exec($cmd);
    drupal_mkdir('public://styles/');
    variable_set('site_name', 'Site Name');
}
Example #23
0
 /**
  * Adjust drupal html headers and add css & js required by foundation
  */
 function hook_html_head_alter(&$head_elements)
 {
     // by default, we will load this file
     $foundation_css = $this->default_theme_path . '/css/app.css';
     // if foundation_ui is enabled && its generated file is readable, we load user_app.css instead.
     if (theme_plugin_is_enabled('foundation_ui')) {
         $user_app_css = variable_get('file_public_path', conf_path() . '/files') . '/okcdesign/' . variable_get('theme_default', 'okcdesign') . '/user_app.css';
         if (is_readable($user_app_css)) {
             $foundation_css = $user_app_css;
         }
     }
     drupal_add_css($foundation_css);
     // for other files, use okcdesign files to not duplicate theme, for easier maintenance of all subthemes.
     drupal_add_js($this->base_theme_path . '/js/app.js');
     drupal_add_js($this->base_theme_path . '/' . $this->vendors_directory . '/modernizr/modernizr.js');
     drupal_add_js($this->base_theme_path . '/' . $this->vendors_directory . '/foundation/js/foundation.min.js');
     // HTML5 charset declaration.
     $head_elements['system_meta_content_type']['#attributes'] = array('charset' => 'utf-8');
     // Optimize mobile viewport.
     $head_elements['mobile_viewport'] = array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0'));
     // Remove image toolbar in IE.
     $head_elements['ie_image_toolbar'] = array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('http-equiv' => 'ImageToolbar', 'content' => 'false'));
 }
 /**
  * Listener disables the Drupal registry and replaces it with
  * a set of class maps.
  */
 public function onBootstrapDatabase()
 {
     spl_autoload_unregister('drupal_autoload_class');
     spl_autoload_unregister('drupal_autoload_interface');
     global $install_state;
     if (isset($install_state['parameters']['profile'])) {
         $profile = $install_state['parameters']['profile'];
     } else {
         $profile = variable_get('install_profile', 'standard');
     }
     $searchdirs = array();
     $searchdirs[] = DRUPAL_ROOT;
     $searchdirs[] = DRUPAL_ROOT . '/profiles/' . $profile;
     $searchdirs[] = DRUPAL_ROOT . '/sites/all';
     $searchdirs[] = DRUPAL_ROOT . '/' . conf_path();
     foreach ($searchdirs as $dir) {
         $filename = $dir . '/classmap.php';
         if (file_exists($filename)) {
             $loader = new MapClassLoader(require $filename);
             $loader->register(true);
         }
     }
 }
Example #25
0
/**
 * Check installation requirements and report any errors.
 */
function install_check_requirements($profile, $verify)
{
    // If Drupal is not set up already, we need to create a settings file.
    if (!$verify) {
        $writable = FALSE;
        $conf_path = './' . conf_path(FALSE, TRUE);
        $settings_file = $conf_path . '/settings.php';
        $file = $conf_path;
        $exists = FALSE;
        // Verify that the directory exists.
        if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
            // Check to make sure a settings.php already exists.
            $file = $settings_file;
            if (drupal_verify_install_file($settings_file, FILE_EXIST)) {
                $exists = TRUE;
                // If it does, make sure it is writable.
                $writable = drupal_verify_install_file($settings_file, FILE_READABLE | FILE_WRITABLE);
            }
        }
        if (!$exists) {
            drupal_set_message(st('The @drupal installer requires that you create a settings file as part of the installation process.
<ol>
<li>Copy the %default_file file to %file.</li>
<li>Change file permissions so that it is writable by the web server. If you are unsure how to grant file permissions, please consult the <a href="@handbook_url">on-line handbook</a>.</li>
</ol>
More details about installing Drupal are available in INSTALL.txt.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '%default_file' => $conf_path . '/default.settings.php', '@handbook_url' => 'http://drupal.org/server-permissions')), 'error');
        } elseif (!$writable) {
            drupal_set_message(st('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, please consult the <a href="@handbook_url">on-line handbook</a>.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'error');
        }
    }
    // Check the other requirements.
    $requirements = drupal_check_profile($profile);
    $severity = drupal_requirements_severity($requirements);
    // If there are issues, report them.
    if ($severity == REQUIREMENT_ERROR) {
        foreach ($requirements as $requirement) {
            if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
                $message = $requirement['description'];
                if (isset($requirement['value']) && $requirement['value']) {
                    $message .= ' (' . st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')';
                }
                drupal_set_message($message, 'error');
            }
        }
    }
    if ($severity == REQUIREMENT_WARNING) {
        foreach ($requirements as $requirement) {
            if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_WARNING) {
                $message = $requirement['description'];
                if (isset($requirement['value']) && $requirement['value']) {
                    $message .= ' (' . st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')';
                }
                drupal_set_message($message, 'warning');
            }
        }
    }
}
 /**
  * Discovers available extensions of a given type.
  *
  * Finds all extensions (modules, themes, etc) that exist on the site. It
  * searches in several locations. For instance, to discover all available
  * modules:
  * @code
  * $listing = new ExtensionDiscovery();
  * $modules = $listing->scan('module');
  * @endcode
  *
  * The following directories will be searched (in the order stated):
  * - the core directory; i.e., /core
  * - the installation profile directory; e.g., /core/profiles/standard
  * - the legacy site-wide directory; i.e., /sites/all
  * - the site-wide directory; i.e., /
  * - the site-specific directory; e.g., /sites/example.com
  *
  * The information is returned in an associative array, keyed by the extension
  * name (without .info.yml extension). Extensions found later in the search
  * will take precedence over extensions found earlier - unless they are not
  * compatible with the current version of Drupal core.
  *
  * @param string $type
  *   The extension type to search for. One of 'profile', 'module', 'theme', or
  *   'theme_engine'.
  * @param bool $include_tests
  *   (optional) Whether to explicitly include or exclude test extensions. By
  *   default, test extensions are only discovered when in a test environment.
  *
  * @return \Drupal\Core\Extension\Extension[]
  *   An associative array of Extension objects, keyed by extension name.
  */
 public function scan($type, $include_tests = NULL)
 {
     // Determine the installation profile directories to scan for extensions,
     // unless explicit profile directories have been set.
     if (!isset($this->profileDirectories)) {
         $this->setProfileDirectoriesFromSettings();
     }
     // Search the core directory.
     $searchdirs[static::ORIGIN_CORE] = 'core';
     // Search the legacy sites/all directory.
     $searchdirs[static::ORIGIN_SITES_ALL] = 'sites/all';
     // Search for contributed and custom extensions in top-level directories.
     // The scan uses a whitelist to limit recursion to the expected extension
     // type specific directory names only.
     $searchdirs[static::ORIGIN_ROOT] = '';
     // Simpletest uses the regular built-in multi-site functionality of Drupal
     // for running web tests. As a consequence, extensions of the parent site
     // located in a different site-specific directory are not discovered in a
     // test site environment, because the site directories are not the same.
     // Therefore, add the site directory of the parent site to the search paths,
     // so that contained extensions are still discovered.
     // @see \Drupal\simpletest\WebTestBase::setUp()
     if ($parent_site = Settings::get('test_parent_site')) {
         $searchdirs[static::ORIGIN_PARENT_SITE] = $parent_site;
     }
     // Search the site-specific directory.
     $searchdirs[static::ORIGIN_SITE] = conf_path();
     // Unless an explicit value has been passed, manually check whether we are
     // in a test environment, in which case test extensions must be included.
     // Test extensions can also be included for debugging purposes by setting a
     // variable in settings.php.
     if (!isset($include_tests)) {
         $include_tests = drupal_valid_test_ua() || Settings::get('extension_discovery_scan_tests');
     }
     $files = array();
     foreach ($searchdirs as $dir) {
         // Discover all extensions in the directory, unless we did already.
         if (!isset(static::$files[$dir][$include_tests])) {
             static::$files[$dir][$include_tests] = $this->scanDirectory($dir, $include_tests);
         }
         // Only return extensions of the requested type.
         if (isset(static::$files[$dir][$include_tests][$type])) {
             $files += static::$files[$dir][$include_tests][$type];
         }
     }
     // Sort the discovered extensions by their originating directories and,
     // if applicable, filter out extensions that do not belong to the current
     // installation profiles.
     $origin_weights = array_flip($searchdirs);
     $origins = array();
     $profiles = array();
     foreach ($files as $key => $file) {
         // If the extension does not belong to a profile, just apply the weight
         // of the originating directory.
         if (strpos($file->subpath, 'profiles') !== 0) {
             $origins[$key] = $origin_weights[$file->origin];
             $profiles[$key] = NULL;
         } elseif (empty($this->profileDirectories)) {
             $origins[$key] = static::ORIGIN_PROFILE;
             $profiles[$key] = NULL;
         } else {
             // Apply the weight of the originating profile directory.
             foreach ($this->profileDirectories as $weight => $profile_path) {
                 if (strpos($file->getPath(), $profile_path) === 0) {
                     $origins[$key] = static::ORIGIN_PROFILE;
                     $profiles[$key] = $weight;
                     continue 2;
                 }
             }
             // If we end up here, then the extension does not belong to any of the
             // current installation profile directories, so remove it.
             unset($files[$key]);
         }
     }
     // Now sort the extensions by origin and installation profile(s).
     // The result of this multisort can be depicted like the following matrix,
     // whereas the first integer is the weight of the originating directory and
     // the second is the weight of the originating installation profile:
     // 0   core/modules/node/node.module
     // 1 0 profiles/parent_profile/modules/parent_module/parent_module.module
     // 1 1 core/profiles/testing/modules/compatible_test/compatible_test.module
     // 2   sites/all/modules/common/common.module
     // 3   modules/devel/devel.module
     // 4   sites/default/modules/custom/custom.module
     array_multisort($origins, SORT_ASC, $profiles, SORT_ASC, $files);
     // Process and return the sorted and filtered list of extensions keyed by
     // extension name.
     return $this->process($files);
 }
Example #27
0
 /**
  * Impelements CoreInterface::validateDrupalSite().
  */
 public function validateDrupalSite()
 {
     if ('default' !== $this->uri) {
         // Fake the necessary HTTP headers that Drupal needs:
         $drupal_base_url = parse_url($this->uri);
         // If there's no url scheme set, add http:// and re-parse the url
         // so the host and path values are set accurately.
         if (!array_key_exists('scheme', $drupal_base_url)) {
             $drush_uri = 'http://' . $this->uri;
             $drupal_base_url = parse_url($this->uri);
         }
         // Fill in defaults.
         $drupal_base_url += array('path' => NULL, 'host' => NULL, 'port' => NULL);
         $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
         if ($drupal_base_url['port']) {
             $_SERVER['HTTP_HOST'] .= ':' . $drupal_base_url['port'];
         }
         $_SERVER['SERVER_PORT'] = $drupal_base_url['port'];
         if (array_key_exists('path', $drupal_base_url)) {
             $_SERVER['PHP_SELF'] = $drupal_base_url['path'] . '/index.php';
         } else {
             $_SERVER['PHP_SELF'] = '/index.php';
         }
     } else {
         $_SERVER['HTTP_HOST'] = 'default';
         $_SERVER['PHP_SELF'] = '/index.php';
     }
     $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $_SERVER['REQUEST_METHOD'] = NULL;
     $_SERVER['SERVER_SOFTWARE'] = NULL;
     $_SERVER['HTTP_USER_AGENT'] = NULL;
     $conf_path = conf_path(TRUE, TRUE);
     $conf_file = $this->drupalRoot . "/{$conf_path}/settings.php";
     if (!file_exists($conf_file)) {
         throw new BootstrapException(sprintf('Could not find a Drupal settings.php file at "%s"', $conf_file));
     }
 }
Example #28
0
 /**
  * Test to be run and the results confirmed.
  *
  * Here we force test results which must match the expected results from
  * confirmStubResults().
  */
 function stubTest()
 {
     // Ensure the .htkey file exists since this is only created just before a
     // request. This allows the stub test to make requests. The event does not
     // fire here and drupal_generate_test_ua() can not generate a key for a
     // test in a test since the prefix has changed.
     // @see \Drupal\Core\Test\EventSubscriber\HttpRequestSubscriber::onBeforeSendRequest()
     // @see drupal_generate_test_ua();
     $key_file = DRUPAL_ROOT . '/sites/simpletest/' . substr($this->databasePrefix, 10) . '/.htkey';
     $private_key = Crypt::randomBytesBase64(55);
     file_put_contents($key_file, $private_key);
     // This causes the first of the fifteen passes asserted in
     // confirmStubResults().
     $this->pass($this->passMessage);
     // The first three fails are caused by enabling a non-existent module in
     // setUp().
     // This causes the fourth of the five fails asserted in
     // confirmStubResults().
     $this->fail($this->failMessage);
     // This causes the second to fourth of the fifteen passes asserted in
     // confirmStubResults().
     $user = $this->drupalCreateUser(array($this->validPermission), 'SimpleTestTest');
     // This causes the fifth of the five fails asserted in confirmStubResults().
     $this->drupalCreateUser(array($this->invalidPermission));
     // Test logging in as a user.
     // This causes the fifth to ninth of the fifteen passes asserted in
     // confirmStubResults().
     $this->drupalLogin($user);
     // This causes the tenth of the fifteen passes asserted in
     // confirmStubResults().
     $this->pass(t('Test ID is @id.', array('@id' => $this->testId)));
     // These cause the eleventh to fourteenth of the fifteen passes asserted in
     // confirmStubResults().
     $this->assertTrue(file_exists(conf_path() . '/settings.testing.php'));
     // Check the settings.testing.php file got included.
     $this->assertTrue(function_exists('simpletest_test_stub_settings_function'));
     // Check that the test-specific service file got loaded.
     $this->assertTrue($this->container->has('site.service.yml'));
     $this->assertIdentical(get_class($this->container->get('cache.backend.database')), 'Drupal\\Core\\Cache\\MemoryBackendFactory');
     // These cause the two exceptions asserted in confirmStubResults().
     // Call trigger_error() without the required argument to trigger an E_WARNING.
     trigger_error();
     // Generates a warning inside a PHP function.
     array_key_exists(NULL, NULL);
     // This causes the fifteenth of the fifteen passes asserted in
     // confirmStubResults().
     $this->assertNothing();
     // This causes the debug message asserted in confirmStubResults().
     debug('Foo', 'Debug', FALSE);
 }
Example #29
0
 /**
  * @return array of strings - paths to directories where contrib
  * themes can be found
  */
 function contrib_themes_paths()
 {
     return array(conf_path() . '/themes', 'sites/all/themes', 'themes');
 }
Example #30
0
/**
 * Bootstrap Drupal.
 */
function _drush_bootstrap_drupal()
{
    require_once DRUSH_DRUPAL_BOOTSTRAP;
    if (($conf_path = conf_path()) && !file_exists("./{$conf_path}/settings.php")) {
        // Provide a helpful exit message, letting the user know where we looked
        // (if we looked at all) and a hint on how to specify the URI manually.
        $message = "E: Unable to load Drupal configuration from {$conf_path}. Aborting.\n";
        $message .= "Hint: You can specify your Drupal URI to use with the --uri\n";
        $message .= "parameter on the command line or \$options['uri'] in your drushrc.php file.\n";
        die($message);
    }
    // The bootstrap can fail silently, so we catch that in a shutdown function.
    register_shutdown_function('drush_shutdown');
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    if (module_exists('drush')) {
        require_once drupal_get_path('module', 'drush') . '/drush.inc';
    } else {
        $message = "E: You must enable the Drush module for the site you want to use.\n";
        $message .= "Hint: Drush was looking in the site '{$conf_path}'. You can select another site\n";
        $message .= "with Drush enabled by specifying the Drupal URI to use with the --uri\n";
        $message .= "parameter on the command line or \$options['uri'] in your drushrc.php file.\n";
        die($message);
    }
}