Issue #1479164 by populist, nedjo: Method for checking writability of server.
authorFrank Febbraro
Wed, 15 Aug 2012 15:29:55 +0000 (11:29 -0400)
committerFrank Febbraro
Wed, 15 Aug 2012 15:29:55 +0000 (11:29 -0400)
apps.installer.inc
apps.module
apps.profile.inc

index 4ba4405..85a25ec 100755 (executable)
@@ -187,7 +187,7 @@ function apps_install_downloads() {
     // credentials. Instead, we instantiate a FileTransferLocal and invoke
     // update_authorize_run_update() directly.
     //if (fileowner($project_real_location) == fileowner(conf_path())) {
-    if (is_writeable(conf_path())) {
+    if (apps_installer_has_write_access()) {
       module_load_include('inc', 'update', 'update.authorize');
       $filetransfer = new FileTransferLocal(DRUPAL_ROOT);
       apps_run_install($filetransfer, $updates); //this is our change
index 056a82a..b7714b3 100755 (executable)
@@ -79,6 +79,17 @@ function apps_hook_info() {
 }
 
 /**
+ * Check whether Apps has write access to libraries and modules directories.
+ *
+ * @return boolean
+ */
+function apps_installer_has_write_access() {
+  $libraries_dir = (is_dir('sites/all/libraries')) ? 'sites/all/libraries' : 'sites/all';
+  return is_writable(drupal_realpath($libraries_dir)) && is_writable(drupal_realpath('sites/all/modules'));
+}
+
+
+/**
  * Implements hook_block_info().
  */
 function apps_block_info() {
index e9ece1c..ea973ff 100755 (executable)
  *
  */
 function apps_profile_install_tasks($install_state, $apps_server) {
+  // Need to include the apps.module file because on installs the profile
+  // collects all install tasks before any modules are enabled
+  module_load_include('module', 'apps');
+
   // Only use apps forms during interactive installs.
   $tasks = array();
   if ($install_state['interactive']) {
@@ -34,7 +38,7 @@ function apps_profile_install_tasks($install_state, $apps_server) {
       'apps_profile_authorize_transfer_' . $apps_server_name => array(
         'display' => FALSE,
         'type' => 'form',
-        'run' => (!is_writeable(conf_path()) && isset($_SESSION['apps']))?INSTALL_TASK_RUN_IF_NOT_COMPLETED:INSTALL_TASK_SKIP,
+        'run' => (!apps_installer_has_write_access() && isset($_SESSION['apps']))?INSTALL_TASK_RUN_IF_NOT_COMPLETED:INSTALL_TASK_SKIP,
         'function' => 'apps_profile_authorize_transfer',
       ),
       'apps_profile_install_app_modules_' . $apps_server_name => array(