protected function onInstallStep() { $installStep = $this->post('step'); $this->log('Install step: %s', $installStep); $result = false; switch ($installStep) { case 'getMetaDataCore': $result = $this->requestServerData('core/install', '', 'public'); $this->log('getMetaDataCore:' . print_r($result, true)); if (!$result) { throw new Exception('Unable to get core information'); } break; case 'downloadCore': $hash = $this->getHashFromMeta('core'); $result = $this->requestServerFile('core', $hash, 'core/get', array('type' => 'install'), 'public'); if (!$result) { throw new Exception('Unable to open plugin archive file'); } break; // todo package installation // todo package installation case 'getMetaDataPackage': // todo $result = $this->requestServerData('package/install', '', 'private'); $this->log('getMetaDataPackage:' . print_r($result, true)); if (!$result) { throw new Exception('Unable to get package information'); } break; case 'downloadPackage': // todo $hash = $this->getHashFromMeta('package'); $this->requestServerFile('package', $hash, 'package/get', array('name' => 'todo: packagetype'), 'private'); $this->log('downloadPackage:' . print_r($result, true)); break; // todo /* $name = $this->post('name'); if (!$name) throw new Exception('Plugin download failed, missing name'); $params = array('name' => $name); if ($project = $this->post('project', false)) $params['project'] = $project; $hash = $this->getHashFromMeta($name, 'plugin'); $this->requestServerFile($name, $hash, 'plugin/get', $params); break; */ // todo /* $name = $this->post('name'); if (!$name) throw new Exception('Plugin download failed, missing name'); $params = array('name' => $name); if ($project = $this->post('project', false)) $params['project'] = $project; $hash = $this->getHashFromMeta($name, 'plugin'); $this->requestServerFile($name, $hash, 'plugin/get', $params); break; */ case 'backupZip': $exclude_dirs = array('common/templates_c', 'cloudbeez', 'cloudbeez/cloudloader/work', 'cloudbeez/cloudloader/temp', 'cloudbeez/backup'); $backup_result = $this->backup('../mailhive/', $this->backupDirectory, $this->backup_file, $exclude_dirs); unset($_SESSION['mailbeez_installer_backup_location']); if (!$backup_result) { throw new Exception('Unable to backup application files'); } break; case 'checkFilePermission': $workpath = $this->extract_zip($this->getFilePath('core'), $this->unzipDirectory); if (!$workpath) { throw new Exception('Unable to extract application files'); } $write_test = $this->test_deploy_files($workpath, $this->deployDirectory, $this->exclude_overwrite, $this->glob_pattern); if (!$write_test) { throw new Exception('Could not extract application files (not writeable) ' . $write_test); } $_SESSION['mailbeez_installer_workpath'] = $workpath; return true; break; case 'checkFilePermissionPackage': $this->debug_output("getFilePath('package') " . $this->getFilePath('package')); $workpath = $this->extract_zip($this->getFilePath('package'), $this->unzipDirectory); $this->debug_output("starting checkFilePermissionPackage: workpath {$workpath}\n"); if (!$workpath) { throw new Exception('Unable to extract package files'); } $this->debug_output("starting checkFilePermissionPackage: workpath {$workpath}\n"); $write_test = $this->test_deploy_files($workpath, $this->deployDirectory, $this->exclude_overwrite_package, $this->glob_pattern); if (!$write_test) { throw new Exception('Could not extract package files (not writeable) ' . $write_test); } $_SESSION['mailbeez_package_installer_workpath'] = $workpath; return true; break; case 'extractCore': $workpath = $_SESSION['mailbeez_installer_workpath']; $result = $this->deploy_files($workpath, $this->deployDirectory, $this->exclude_overwrite, $this->glob_pattern); $this->delete_folder($workpath); unset($_SESSION['mailbeez_installer_workpath']); if (!$result) { throw new Exception('Unable to deploy application files'); } // todo // update signature break; case 'extractPackage': $workpath = $_SESSION['mailbeez_package_installer_workpath']; $this->debug_output("starting extractPackage: workpath {$workpath}\n"); $result = $this->deploy_files($workpath, $this->deployDirectory, $this->exclude_overwrite_package, $this->glob_pattern); $this->delete_folder($workpath); unset($_SESSION['mailbeez_package_installer_workpath']); if (!$result) { throw new Exception('Unable to deploy package files'); } // update signature $hashFile = $this->deployDirectory . 'package.hash'; if (file_exists($hashFile)) { $package_hash = file_get_contents($hashFile); mh_insert_config_value(array('configuration_title' => 'Package hash', 'configuration_key' => 'MAILBEEZ_CLOUDBEEZ_PACKAGE_HASH', 'configuration_value' => $package_hash, 'configuration_description' => 'set automatically', 'set_function' => ''), true); } $this->debug_output("set package hash: {$package_hash}\n"); break; case 'finishInstall': break; } $this->log('Step %s +OK', $installStep); return array('result' => $result); }
protected function onInstallStep() { $installStep = $this->post('step'); $this->log('Install step: %s', $installStep); $result = false; switch ($installStep) { case 'getMetaDataCore': $result = $this->requestServerData('core/install', '', 'public'); $this->log('getMetaDataCore:' . print_r($result, true)); if (!$result) { throw new Exception('Unable to get core information'); } break; case 'downloadCore': $hash = $this->getHashFromMeta('core'); $result = $this->requestServerFile('core', $hash, 'core/get', array('type' => 'install'), 'public'); if (!$result) { throw new Exception('Unable to open download archive file'); } break; // todo package installation // todo package installation case 'getMetaDataPackage': // todo $result = $this->requestServerData('package/install', '', 'private'); $this->log('getMetaDataPackage:' . print_r($result, true)); if (!$result) { throw new Exception('Unable to get package information'); } break; case 'downloadPackage': // todo $hash = $this->getHashFromMeta('package'); $this->requestServerFile('package', $hash, 'package/get', array('name' => 'todo: packagetype'), 'private'); $this->log('downloadPackage:' . print_r($result, true)); break; // todo /* $name = $this->post('name'); if (!$name) throw new Exception('Plugin download failed, missing name'); $params = array('name' => $name); if ($project = $this->post('project', false)) $params['project'] = $project; $hash = $this->getHashFromMeta($name, 'plugin'); $this->requestServerFile($name, $hash, 'plugin/get', $params); break; */ // todo /* $name = $this->post('name'); if (!$name) throw new Exception('Plugin download failed, missing name'); $params = array('name' => $name); if ($project = $this->post('project', false)) $params['project'] = $project; $hash = $this->getHashFromMeta($name, 'plugin'); $this->requestServerFile($name, $hash, 'plugin/get', $params); break; */ case 'backupZip': $exclude_dirs = array('common/templates_c', 'cloudbeez', 'cloudbeez/cloudloader/work', 'cloudbeez/cloudloader/temp', 'cloudbeez/backup'); $backup_dir = '../' . MH_ROOT_PATH; $result = $this->backup($backup_dir, $this->backupDirectory, $this->backup_file, $exclude_dirs); $this->deleteSessionVar('mailbeez_installer_backup_location'); if (!$result) { throw new Exception('Unable to backup application files'); } break; case 'checkFilePermission': $workpath = $this->extract_zip($this->getFilePath('core'), $this->unzipDirectory); $this->debug_output("starting checkFilePermission: workpath {$workpath}\n"); if (!$workpath) { throw new Exception('Unable to extract application files'); } $this->writeSessionVar('mailbeez_installer_workpath', $workpath); $write_test = $this->test_deploy_files($workpath, $this->deployDirectory, $this->exclude_overwrite, $this->glob_pattern); if (!$write_test) { throw new Exception('Could not extract application files (not writeable) ' . $write_test); } $result = true; /* // fix strange behaviour not storing sessions on some server // workaround PHP5.2 error // Fatal error: session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: user (path: /tmp) if (version_compare(PHP_VERSION, "5.3", ">=")) { session_write_close(); session_start(); } $_SESSION['mailbeez_installer_workpath'] = $workpath; session_write_close(); */ // return true; break; case 'checkFilePermissionPackage': $this->debug_output("getFilePath('package') " . $this->getFilePath('package')); $workpath = $this->extract_zip($this->getFilePath('package'), $this->unzipDirectory); $this->debug_output("starting checkFilePermissionPackage: workpath {$workpath}\n"); $this->writeSessionVar('mailbeez_package_installer_workpath', $workpath); if (!$workpath) { throw new Exception('Unable to extract package files - workpath empty'); } $this->debug_output("starting checkFilePermissionPackage: workpath {$workpath}\n"); $write_test = $this->test_deploy_files($workpath, $this->deployDirectory, $this->exclude_overwrite_package, $this->glob_pattern); if (!$write_test) { throw new Exception('Could not extract package files (not writeable) ' . $write_test); } $result = true; /* if (version_compare(PHP_VERSION, "5.3", ">=")) { session_write_close(); session_start(); } $_SESSION['mailbeez_package_installer_workpath'] = $workpath; session_write_close(); */ //return true; break; case 'extractCore': $workpath = $this->readSessionVar('mailbeez_installer_workpath'); //$_SESSION['mailbeez_installer_workpath']; if (!$workpath) { throw new Exception('Unable to extract application files - workpath empty'); } $result = $this->deploy_files($workpath, $this->deployDirectory, $this->exclude_overwrite, $this->glob_pattern); $this->delete_folder($workpath); $this->deleteSessionVar('mailbeez_installer_workpath'); $this->deleteSessionVar('mailbeez_installer_backup_location'); $this->deleteSessionVar('mailbeez_installer_backup_location_dir'); if (!$result) { throw new Exception('Unable to deploy application files'); } // todo // update signature break; case 'extractPackage': $workpath = $this->readSessionVar('mailbeez_package_installer_workpath'); //$_SESSION['mailbeez_package_installer_workpath']; if (!$workpath) { throw new Exception('Unable to extract package files - workpath empty'); } $this->debug_output("starting extractPackage: workpath {$workpath}\n"); $result = $this->deploy_files($workpath, $this->deployDirectory, $this->exclude_overwrite_package, $this->glob_pattern); $this->delete_folder($workpath); $this->deleteSessionVar('mailbeez_package_installer_workpath'); //unset($_SESSION['mailbeez_package_installer_workpath']); if (!$result) { throw new Exception('Unable to deploy package files'); } // update signature $hashFile = $this->deployDirectory . 'package.hash'; if (file_exists($hashFile)) { $package_hash = file_get_contents($hashFile); mh_insert_config_value(array('configuration_title' => 'Package hash', 'configuration_key' => 'MAILBEEZ_CLOUDBEEZ_PACKAGE_HASH', 'configuration_value' => $package_hash, 'configuration_description' => 'set automatically', 'set_function' => ''), true); $this->debug_output("set package hash: {$package_hash}\n"); } else { $this->debug_output("ERROR package hash file not found\n"); } $this->deleteSessionVar('mailbeez_installer_workpath'); $this->deleteSessionVar('mailbeez_installer_backup_location'); $this->deleteSessionVar('mailbeez_installer_backup_location_dir'); break; case 'finishInstall': break; } $this->log('Step %s +OK', $installStep); return array('result' => $result); }
function install() { mh_insert_config_value(array('configuration_title' => 'Send trustpilot trigger email', 'configuration_key' => 'MAILBEEZ_TRUSTPILOT_STATUS', 'configuration_value' => 'False', 'configuration_description' => 'Do you want to send trustpilot trigger email to ask your customer for a review?', 'set_function' => 'mh_cfg_select_option(array(\'True\', \'False\'), ')); mh_insert_config_value(array('configuration_title' => 'Set Order Status', 'configuration_key' => 'MAILBEEZ_TRUSTPILOT_ORDER_STATUS_ID', 'configuration_value' => '3', 'configuration_description' => 'Set the status of orders to send trigger', 'set_function' => 'mh_cfg_pull_down_order_statuses(', 'use_function' => 'mh_get_order_status_name')); mh_insert_config_value(array('configuration_title' => 'your trustpilot email address', 'configuration_key' => 'MAILBEEZ_TRUSTPILOT_TRIGGER_EMAIL', 'configuration_value' => '*****@*****.**', 'configuration_description' => 'your unique trustpilot email address', 'set_function' => '')); mh_insert_config_value(array('configuration_title' => 'Set days passed', 'configuration_key' => 'MAILBEEZ_TRUSTPILOT_PASSED_DAYS', 'configuration_value' => '5', 'configuration_description' => 'number of days to wait before sending the emails', 'set_function' => '')); mh_insert_config_value(array('configuration_title' => 'Set days to skip after', 'configuration_key' => 'MAILBEEZ_TRUSTPILOT_PASSED_DAYS_SKIP', 'configuration_value' => '10', 'configuration_description' => 'number of days after which do skip the reminder', 'set_function' => '')); mh_insert_config_value(array('configuration_title' => 'sender email', 'configuration_key' => 'MAILBEEZ_TRUSTPILOT_SENDER', 'configuration_value' => STORE_OWNER_EMAIL_ADDRESS, 'configuration_description' => 'sender email', 'set_function' => '')); mh_insert_config_value(array('configuration_title' => 'sender name', 'configuration_key' => 'MAILBEEZ_TRUSTPILOT_SENDER_NAME', 'configuration_value' => STORE_NAME, 'configuration_description' => 'sender email', 'set_function' => '')); mh_insert_config_value(array('configuration_title' => 'Default Customer Language', 'configuration_key' => 'MAILBEEZ_TRUSTPILOT_LANGUAGE', 'configuration_value' => 'automatic', 'configuration_description' => 'Please choose the language Trustpilot will ask your Customers.', 'set_function' => 'mh_cfg_select_option(array(\'da-DK\', \'de-DE\', \'en-GB\', \'es-ES\', \'fr-FR\', \'it-IT\', \'nb-NO\', \'nl-NL\', \'ro-RO\', \'ru-RU\', \'sv-SE\', \'automatic\'), ')); mh_insert_config_value(array('configuration_title' => 'Sort order of display.', 'configuration_key' => 'MAILBEEZ_TRUSTPILOT_SORT_ORDER', 'configuration_value' => '10', 'configuration_description' => 'Sort order of display. Lowest is displayed first.', 'set_function' => '')); }