function Websites_0_8_Users_mysql() { $userId = Users::communityId(); Users_Label::addLabel('Websites/admins', $userId, 'Website Admins', 'labels/Websites/admins', false); if (!file_exists(USERS_PLUGIN_FILES_DIR . DS . 'Users' . DS . 'icons' . DS . 'Websites')) { Q_Utils::symlink(WEBSITES_PLUGIN_FILES_DIR . DS . 'Websites' . DS . 'icons' . DS . 'labels' . DS . 'Websites', USERS_PLUGIN_FILES_DIR . DS . 'Users' . DS . 'icons' . DS . 'labels' . DS . 'Websites'); } }
function Websites_0_8_Users_mysql() { $userId = Q_Config::get("Websites", "user", "id", null); if (!$userId) { throw new Q_Exception('Websites: Please fill in the config field "Websites"/"user"/"id"'); } Users_Label::addLabel('Websites/admins', $userId, 'Website Admins', 'labels/Websites/admins', false); if (!file_exists('Websites')) { Q_Utils::symlink(WEBSITES_PLUGIN_FILES_DIR . DS . 'Websites' . DS . 'icons' . DS . 'labels' . DS . 'Websites', USERS_PLUGIN_FILES_DIR . DS . 'Users' . DS . 'icons' . DS . 'Websites'); } }
function Streams_0_8_1_Streams_mysql() { $app = Q_Config::expect('Q', 'app'); // template for community stream $stream = new Streams_Stream(); $stream->publisherId = ''; $stream->name = 'Streams/community/'; $stream->type = 'Streams/template'; $stream->title = "Community"; $stream->content = ''; $readLevel = Streams::$READ_LEVEL['content']; $writeLevel = Streams::$WRITE_LEVEL['join']; $adminLevel = Streams::$ADMIN_LEVEL['invite']; $stream->save(); // app community stream, for announcements Streams::create($app, $app, 'Streams/community', array('skipAccess' => true, 'name' => 'Streams/community/main', 'title' => "{$app} Community")); // symlink the labels folder if (!file_exists('Streams')) { Q_Utils::symlink(STREAMS_PLUGIN_FILES_DIR . DS . 'Streams' . DS . 'icons' . DS . 'labels' . DS . 'Streams', USERS_PLUGIN_FILES_DIR . DS . 'Users' . DS . 'icons' . DS . 'Streams'); } }
case '--noinit': $noInit = true; break; } break; } } $options['sql'] = $sql_array; echo 'Q Platform app installer' . PHP_EOL; $app = Q_Config::expect('Q', 'app'); $uploads_dir = APP_FILES_DIR . DS . $app . DS . 'uploads'; if (is_dir($uploads_dir)) { if (file_exists(APP_WEB_DIR . DS . 'uploads')) { unlink(APP_WEB_DIR . DS . 'uploads'); } Q_Utils::symlink($uploads_dir, APP_WEB_DIR . DS . 'uploads'); } if ($auto_plugins) { $plugins = Q_Config::get('Q', 'plugins', array()); if (!in_array("Q", $plugins)) { array_unshift($plugins, "Q"); } } Q_Plugin::checkPermissions(APP_FILES_DIR, array_merge($options, array('deep' => true))); foreach ($plugins as $plugin) { $cons = Q_Config::get('Q', 'pluginInfo', $plugin, 'connections', array()); foreach ($cons as $con) { if (empty($options['sql'][$con])) { $options['sql'][$con] = array('enabled' => true); } }
$pi = pathinfo($filename); if ($pi['filename'] === CONFIGURE_ORIGINAL_APP_NAME) { $pi['filename'] = $desired; } // fixed / to DIRECTORY_SEPARATOR $filename2 = $pi['dirname'] . DIRECTORY_SEPARATOR . $pi['filename'] . (empty($pi['extension']) ? '' : '.' . $pi['extension']); if ($filename != $filename2) { rename($filename, $filename2); $go_again = true; break; } } } while ($go_again); if ($desired !== CONFIGURE_ORIGINAL_APP_NAME) { $it = new RecursiveDirectoryIterator(APP_DIR); foreach (new RecursiveIteratorIterator($it) as $filename) { if (is_dir($filename) or is_link($filename)) { continue; } $file = file_get_contents($filename); file_put_contents($filename, preg_replace("/" . CONFIGURE_ORIGINAL_APP_NAME . "/", $desired, $file)); } } $uploads_dir = APP_FILES_DIR . DS . $desired . DS . 'uploads'; if (is_dir($uploads_dir)) { if (file_exists(APP_WEB_DIR . DS . 'uploads')) { unlink(APP_WEB_DIR . DS . 'uploads'); } Q_Utils::symlink('..' . DS . 'files' . DS . $desired . DS . 'uploads', APP_WEB_DIR . DS . 'uploads'); } echo "Application configured. The next steps are:\n1) edit the config in {$basename}/local/app.json\n2) run {$basename}/scripts/Q/install.php --all\n";
/** * @method installPlugin * @static * @param {string} $plugin_name * @param {array} $options * @throws {Exception} */ static function installPlugin($plugin_name, $options) { set_time_limit(Q_Config::expect('Q', 'install', 'timeLimit')); // Connect Qbix platform if it's not already connected self::prepare(); $app_dir = APP_DIR; $plugin_dir = Q_PLUGINS_DIR . DS . $plugin_name; $app_web_plugins_dir = APP_WEB_DIR . DS . 'plugins'; echo "Installing plugin '{$plugin_name}' into '{$app_dir}'" . PHP_EOL; // Do we even have such a plugin? if (!is_dir($plugin_dir)) { throw new Exception("Plugin '{$plugin_name}' not found in " . Q_PLUGINS_DIR); } // Ensure that the plugin has config.json if (!file_exists($plugin_conf_file = $plugin_dir . DS . 'config' . DS . 'plugin.json')) { throw new Exception("Could not load plugin's config. Check {$plugin_conf_file}"); } $files_dir = $plugin_dir . DS . 'files'; $app_plugins_file = APP_LOCAL_DIR . DS . 'plugins.json'; // Check access to $app_web_plugins_dir if (!file_exists($app_web_plugins_dir)) { if (!@mkdir($app_web_plugins_dir, 0755, true)) { throw new Exception("Could not create {$app_web_plugins_dir}"); } } if (!is_dir($app_web_plugins_dir)) { throw new Exception("{$app_web_plugins_dir} exists, but is not a directory"); } elseif (!is_writable($app_web_plugins_dir)) { throw new Exception("Can not write to {$app_web_plugins_dir}"); } // Check access to $app_plugins_file if (file_exists($app_plugins_file) && !is_writable($app_plugins_file)) { throw new Exception("Can not write to {$app_plugins_file}"); } elseif (!file_exists($app_plugins_file) && !is_writable(dirname($app_plugins_file))) { throw new Exception("Can not write to " . dirname($app_plugins_file)); } // Check access to $files_dir if (!file_exists($files_dir)) { if (!@mkdir($files_dir, $options['dirmode'], true)) { throw new Exception("Could not create {$files_dir}"); } } // Do we now have plugin's config? if (Q_Config::get('Q', 'pluginInfo', $plugin_name, 'version', null) == null) { throw new Exception("Could not identify plugin version. Check {$plugin_conf_file}"); } $plugin_conf = Q_Config::get('Q', 'pluginInfo', $plugin_name, null); $plugin_version = $plugin_conf['version']; if (file_exists($app_plugins_file)) { Q_Config::load($app_plugins_file, true); } // Do we already have this plugin installed for this app? // Check requirements for plugin (will throw exceptions if they aren't met) if (!isset($options['noreq']) || !$options['noreq']) { echo "Checking requirements" . PHP_EOL; Q_Bootstrap::checkRequirements(array($plugin_name)); } // Checking LOCAL plugin version in plugins.json file if (($version_installed = Q_Config::get('Q', 'pluginLocal', $plugin_name, 'version', null)) != null) { //We have this plugin installed echo "Plugin '{$plugin_name}' (version: {$version_installed}) is already installed" . PHP_EOL; if (Q::compareVersion($version_installed, $plugin_version) < 0) { echo "Upgrading '{$plugin_name}' to version: {$plugin_version}" . PHP_EOL; } } // Check and fix permissions self::checkPermissions($files_dir, $options); if (isset($plugin_conf['permissions'])) { foreach ($plugin_conf['permissions'] as $perm) { self::checkPermissions($files_dir . DS . $perm, $options); } } // Symbolic links echo 'Creating symbolic links' . PHP_EOL; Q_Utils::symlink($plugin_dir . DS . 'web', $app_web_plugins_dir . DS . $plugin_name); // Checking if schema update is requested and updating database version $connections = Q_Config::get('Q', 'pluginInfo', $plugin_name, 'connections', array()); foreach ($connections as $connection) { self::installSchema(Q_PLUGINS_DIR . DS . $plugin_name, $plugin_name, 'plugin', $connection, $options); } // Push plugin name into Q/plugins array if (!in_array($plugin_name, $current_plugins = Q_Config::get('Q', 'plugins', array()))) { $current_plugins[] = $plugin_name; Q_Config::set('Q', 'plugins', $current_plugins); //TODO: When do we save Q/plugins to disk? } // Save info about plugin echo 'Registering plugin' . PHP_EOL; Q_Config::set('Q', 'pluginLocal', $plugin_name, $plugin_conf); Q_Config::save($app_plugins_file, array('Q', 'pluginLocal')); echo Q_Utils::colored("Plugin '{$plugin_name}' successfully installed" . PHP_EOL, 'green'); }