/** * Returns TRUE if the current user has write permissions for a configuration * file in the config:// directory. */ public static function checkFilePermissions($filename) { $dir_path = ConfigurationManagement::getStream(); $full_path = $dir_path . '/' . $filename; if (static::checkDirectory($dir_path)) { if (file_exists($full_path)) { if (is_writable($full_path) || drupal_chmod($full_path)) { return TRUE; } else { drupal_set_message(t('The current user does not have permissions to edit the file %file.', array('%file' => $full_path)), 'error'); } } else { return TRUE; } } return FALSE; }
/** * Loads the configuration object from the DataStore. * * @param $file_content * Optional. The content to load directly. * @param $source * Optional. An optional path to load the configuration. */ public function load($file_content = NULL, $source = NULL) { if (empty($this->loaded)) { $this->loaded = TRUE; if (empty($file_content)) { $dir = $source ? $source : ConfigurationManagement::getStream(); if (!file_exists($dir . '/' . $this->filename)) { $this->data = NULL; } else { $file_content = drupal_substr(file_get_contents($dir . '/' . $this->filename), 6); } } if (!empty($file_content)) { $this->import($file_content); } } return $this; }