import v1.0.0-RC4 | 2009-05-20

This commit is contained in:
2019-07-17 22:08:50 +02:00
commit b484e522e8
2459 changed files with 1038434 additions and 0 deletions

View File

@ -0,0 +1,19 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Install_CompleteController extends Monkeys_Controller_Action
{
protected $_numCols = 1;
public function indexAction()
{
}
}

View File

@ -0,0 +1,205 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Install_CredentialsController extends Monkeys_Controller_Action
{
protected $_numCols = 1;
public function indexAction()
{
if ($errors = $this->_getErrors()) {
return $this->_forward('index', 'permissions', null, array('errors' => $errors));
}
$appSession = Zend_Registry::get('appSession');
if (isset($appSession->installForm)) {
$this->view->form = $appSession->installForm;
unset($appSession->installForm);
} else {
$this->view->form = new InstallForm();
}
}
public function saveAction()
{
$form = new InstallForm();
$formData = $this->_request->getPost();
$form->populate($formData);
if (!$form->isValid($formData)) {
return $this->_forwardFormError($form);
}
if (!$this->_connectToDbEngine($form)) {
$this->_helper->FlashMessenger->addMessage('We couldn\'t connect to the database using those credentials.');
$this->_helper->FlashMessenger->addMessage('Please verify and try again.');
return $this->_forwardFormError($form);
}
if (!$this->_createDbIfMissing($form)) {
$this->_helper->FlashMessenger->addMessage(
'The connection to the database engine worked, but the database "' . $form->getValue('dbname') . '" doesn\'t exist or the provided user doesn\'t have access to it. An attempt was made to create it, but the provided user doesn\'t have permissions to do so either. Please create it yourself and try again.');
return $this->_forwardFormError($form);
}
$this->_importDb();
if (!$this->_writeConfig($form)) {
throw new Exception('Couldn\'t write to config file file ' . APP_DIR . DIRECTORY_SEPARATOR . 'config.php');
}
$this->_forward('index', 'complete');
}
private function _connectToDbEngine(InstallForm $form)
{
$this->_config->database->params->host = $form->getValue('hostname');
$this->_config->database->params->username = $form->getValue('dbusername');
$this->_config->database->params->password = $form->getValue('dbpassword');
// setting dbname to null makes Zend_Db::getConnection() try to connect to the db engine
// without attempting to connect to the dbname
$this->_config->database->params->dbname = null;
return Setup::setDatabase();
}
private function _createDbIfMissing(InstallForm $form)
{
$this->_config->database->params->host = $form->getValue('hostname');
$this->_config->database->params->username = $form->getValue('dbusername');
$this->_config->database->params->password = $form->getValue('dbpassword');
$this->_config->database->params->dbname = $form->getValue('dbname');
if (!Setup::setDatabase()) {
try {
$this->_config->database->params->dbname = null;
Setup::setDatabase();
// binding doesn't work here for some reason
Zend_Registry::get('db')->getConnection()->query("CREATE DATABASE `" . $form->getValue('dbname') . "`");
$this->_config->database->params->dbname = $form->getValue('dbname');
Setup::setDatabase();
} catch (PDOException $e) { // when using PDO, it throws this exception, not Zend's
return false;
}
}
return true;
}
private function _writeConfig(InstallForm $form)
{
$this->_config->environment->installed = true;
$this->_config->email->supportemail = $form->getValue('supportemail');
$configTemplate = file_get_contents(APP_DIR . DIRECTORY_SEPARATOR . 'config.template.php');
$replace = array(
'{environment.installed}' => $this->_config->environment->installed? 'true' : 'false',
'{environment.session_name}' => $this->_config->environment->session_name,
'{environment.production}' => $this->_config->environment->production? 'true' : 'false',
'{environment.YDN}' => $this->_config->environment->YDN? 'true' : 'false',
'{environment.ajax_slowdown}' => $this->_config->environment->ajax_slowdown,
'{environment.keep_history_days}' => $this->_config->environment->keep_history_days,
'{environment.registrations_enabled}' => $this->_config->environment->registrations_enabled? 'true' : 'false',
'{environment.locale}' => $this->_config->environment->locale,
'{environment.template}' => $this->_config->environment->template,
'{news_feed.url}' => $this->_config->news_feed->url,
'{news_feed.num_items}' => $this->_config->news_feed->num_items,
'{logging.location}' => $this->_config->logging->location,
'{logging.level}' => $this->_config->logging->level,
'{subdomain.enabled}' => $this->_config->subdomain->enabled? 'true' : 'false',
'{subdomain.hostname}' => $this->_config->subdomain->hostname,
'{subdomain.use_www}' => $this->_config->subdomain->use_www? 'true' : 'false',
'{SSL.enable_mixed_mode}' => $this->_config->SSL->enable_mixed_mode? 'true' : 'false',
'{database.adapter}' => $this->_config->database->adapter,
'{database.params.host}' => $this->_config->database->params->host,
'{database.params.dbname}' => $this->_config->database->params->dbname,
'{database.params.username}' => $this->_config->database->params->username,
'{database.params.password}' => $this->_config->database->params->password,
'{email.supportemail}' => $this->_config->email->supportemail,
'{email.adminemail}' => $this->_config->email->adminemail,
'{email.transport}' => $this->_config->email->transport,
'{email.host}' => $this->_config->email->host,
'{email.auth}' => $this->_config->email->auth,
'{email.username}' => $this->_config->email->username,
'{email.password}' => $this->_config->email->password,
);
$configTemplate = str_replace(array_keys($replace), array_values($replace), $configTemplate);
return @file_put_contents(APP_DIR . DIRECTORY_SEPARATOR . 'config.php', $configTemplate);
}
private function _importDb()
{
$this->_runSqlFILE('final.sql');
}
function _runSqlFile($fileName) {
$fp = fopen(APP_DIR . DIRECTORY_SEPARATOR . "/setup/$fileName", 'r');
$query = '';
$db = Zend_Registry::get('db');
while (!feof($fp)) {
$line = trim(fgets($fp));
// skip SQL comments
if (substr($line, 0, 2) == '--') {
continue;
}
$query .= $line;
if ((substr($line, -1, 1) == ';' || feof($fp)) && $query != '') {
// I had to resort to a direct call because regexes inside the Zend Framework are segfaulting with the long queries in sampleData.sql
//$this->db->query($query);
$db->getConnection()->query($query);
$query = '';
}
}
fclose($fp);
}
private function _forwardFormError(InstallForm $form)
{
$appSession = Zend_Registry::get('appSession');
$appSession->installForm = $form;
$this->_redirect('/install/credentials');
return;
}
private function _getErrors()
{
$errors = array();
$webServerUser = $this->_getProcessUser();
if (!is_writable(APP_DIR) && !is_writable(APP_DIR . '/config.php')) {
$errors[] = $this->view->translate('The directory where Community-ID is installed must be writable by the web server user (%s). Another option is to create an EMPTY config.php file that is writable by that user.', $webServerUser);
}
if (!is_writable(WEB_DIR . '/captchas')) {
$errors[] = $this->view->translate('The directory "captchas" under the web directory for Community-ID must be writable by the web server user (%s)', $webServerUser);
}
return $errors;
}
private function _getProcessUser()
{
if (!function_exists('posix_getpwuid')) {
// we're on windows
return getenv('USERNAME');
}
$processUser = posix_getpwuid(posix_geteuid());
return $processUser['name'];
}
}

View File

@ -0,0 +1,19 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Install_IndexController extends Monkeys_Controller_Action
{
protected $_numCols = 1;
public function indexAction()
{
}
}

View File

@ -0,0 +1,20 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Install_PermissionsController extends Monkeys_Controller_Action
{
protected $_numCols = 1;
public function indexAction()
{
$this->view->errors = $this->_getParam('errors');
}
}

View File

@ -0,0 +1,44 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkeys Ltd.
* @since Textroller 0.9
* @package TextRoller
* @packager Keyboard Monkeys
*/
class InstallForm extends Zend_Form
{
public function init()
{
$hostname = new Zend_Form_Element_Text('hostname');
$hostname->setLabel('Hostname:')
->setDescription('usually localhost')
->setRequired(true)
->setValue('localhost');
$dbname = new Zend_Form_Element_Text('dbname');
$dbname->setLabel('Database name:')
->setRequired(true)
->setValue(Zend_Registry::get('config')->database->params->dbname);
$dbusername = new Zend_Form_Element_Text('dbusername');
$dbusername->setLabel('Database username:')
->setRequired(true);
$dbpassword = new Zend_Form_Element_Password('dbpassword');
$dbpassword->setLabel('Database password:');
$supportemail = new Zend_Form_Element_Text('supportemail');
$supportemail->setLabel('Support E-mail:')
->setDescription('Will be used as the sender for any message sent by the system, and as the recipient for user feedback')
->addFilter('StringToLower')
->addValidator('EmailAddress')
->setRequired(true);
$this->addElements(array($hostname, $dbname, $dbusername, $dbpassword, $supportemail));
}
}

View File

@ -0,0 +1,20 @@
<h3>
<?= $this->translate('The installation was performed successfully') ?>
</h3>
<div style="margin-top:20px">
<div>
You can login as the administrator with the username "admin" and the password "admin"<br />
Please note that this user is only meant for administrative tasks, and cannot have an OpenID credential.
</div>
<div style="margin-top:20px">
<input type="button" id="start" value="<?= $this->translate('Finish') ?>" />
<div>
<script type="text/javascript">
var oButton = new YAHOO.widget.Button(
"start",
{
onclick: {fn: function() {location.href="<?= $this->base ?>"}}
}
);
</script>
</div>

View File

@ -0,0 +1,16 @@
<h3>
<?= $this->translate('Database and E-mail information') ?>
</h3>
<form name="installform" method="post" action="<?= $this->base ?>/install/credentials/save" class="longLabelsForm">
<dl>
<?= $this->form->hostname ?>
<?= $this->form->dbname ?>
<?= $this->form->dbusername ?>
<?= $this->form->dbpassword ?>
<?= $this->form->supportemail ?>
</dl>
<input type="submit" id="send" value="<?= $this->translate('Send') ?>" />
<script type="text/javascript">
var oButton = new YAHOO.widget.Button("send");
</script>
</form>

View File

@ -0,0 +1,14 @@
<h3>
<?= $this->translate('This Community-ID instance hasn\'t been installed yet') ?>
</h3>
<div style="margin-top:20px">
<input type="button" id="start" value="<?= $this->translate('Proceed with installation')?>" />
<script type="text/javascript">
var oButton = new YAHOO.widget.Button(
"start",
{
onclick: {fn: function() {location.href="<?= $this->base ?>/install/credentials"}}
}
);
</script>
</div>

View File

@ -0,0 +1,19 @@
<h3>
<?= $this->translate('Please correct the following problems before proceeding:') ?>
</h3>
<ul>
<? foreach ($this->errors as $error): ?>
<li style="list-style-type:circle"><?= $error ?></li>
<? endforeach ?>
</ul>
<div style="margin-top:20px">
<input type="button" id="check" value="<?= $this->translate('Check again')?>" />
<script type="text/javascript">
var oButton = new YAHOO.widget.Button(
"check",
{
onclick: {fn: function() {location.href="<?= $this->base ?>/install/credentials"}}
}
);
</script>
</div>