import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -9,7 +9,7 @@
* @packager Keyboard Monkeys
*/
class Install_CompleteController extends Monkeys_Controller_Action
class Install_CompleteController extends CommunityID_Controller_Action
{
protected $_numCols = 1;

View File

@ -9,7 +9,7 @@
* @packager Keyboard Monkeys
*/
class Install_CredentialsController extends Monkeys_Controller_Action
class Install_CredentialsController extends CommunityID_Controller_Action
{
protected $_numCols = 1;
@ -24,13 +24,13 @@ class Install_CredentialsController extends Monkeys_Controller_Action
$this->view->form = $appSession->installForm;
unset($appSession->installForm);
} else {
$this->view->form = new InstallForm();
$this->view->form = new Install_Form_Install();
}
}
public function saveAction()
{
$form = new InstallForm();
$form = new Install_Form_Install();
$formData = $this->_request->getPost();
$form->populate($formData);
@ -53,13 +53,13 @@ class Install_CredentialsController extends Monkeys_Controller_Action
$this->_importDb();
if (!$this->_writeConfig($form)) {
throw new Exception('Couldn\'t write to config file file ' . APP_DIR . DIRECTORY_SEPARATOR . 'config.php');
throw new Exception('Couldn\'t write to config file ' . APP_DIR . DIRECTORY_SEPARATOR . 'config.php');
}
$this->_forward('index', 'complete');
}
private function _connectToDbEngine(InstallForm $form)
private function _connectToDbEngine(Install_Form_Install $form)
{
$this->_config->database->params->host = $form->getValue('hostname');
$this->_config->database->params->username = $form->getValue('dbusername');
@ -69,10 +69,10 @@ class Install_CredentialsController extends Monkeys_Controller_Action
// without attempting to connect to the dbname
$this->_config->database->params->dbname = null;
return Setup::setDatabase();
return Application::setDatabase();
}
private function _createDbIfMissing(InstallForm $form)
private function _createDbIfMissing(Install_Form_Install $form)
{
$this->_config->database->params->host = $form->getValue('hostname');
$this->_config->database->params->username = $form->getValue('dbusername');
@ -80,15 +80,15 @@ class Install_CredentialsController extends Monkeys_Controller_Action
$this->_config->database->params->dbname = $form->getValue('dbname');
if (!Setup::setDatabase()) {
if (!Application::setDatabase()) {
try {
$this->_config->database->params->dbname = null;
Setup::setDatabase();
Application::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();
Application::setDatabase();
} catch (PDOException $e) { // when using PDO, it throws this exception, not Zend's
return false;
}
@ -97,7 +97,7 @@ class Install_CredentialsController extends Monkeys_Controller_Action
return true;
}
private function _writeConfig(InstallForm $form)
private function _writeConfig(Install_Form_Install $form)
{
$this->_config->environment->installed = true;
$this->_config->email->supportemail = $form->getValue('supportemail');
@ -113,8 +113,6 @@ class Install_CredentialsController extends Monkeys_Controller_Action
'{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',
@ -168,7 +166,7 @@ class Install_CredentialsController extends Monkeys_Controller_Action
fclose($fp);
}
private function _forwardFormError(InstallForm $form)
private function _forwardFormError(Install_Form_Install $form)
{
$appSession = Zend_Registry::get('appSession');
$appSession->installForm = $form;
@ -181,7 +179,7 @@ class Install_CredentialsController extends Monkeys_Controller_Action
$errors = array();
$webServerUser = $this->_getProcessUser();
if (!is_writable(APP_DIR) && !is_writable(APP_DIR . '/config.php')) {
if (!is_writable(APP_DIR) && !is_writable(APP_DIR . DIRECTORY_SEPARATOR . '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')) {

View File

@ -9,7 +9,7 @@
* @packager Keyboard Monkeys
*/
class Install_IndexController extends Monkeys_Controller_Action
class Install_IndexController extends CommunityID_Controller_Action
{
protected $_numCols = 1;

View File

@ -9,7 +9,7 @@
* @packager Keyboard Monkeys
*/
class Install_PermissionsController extends Monkeys_Controller_Action
class Install_PermissionsController extends CommunityID_Controller_Action
{
protected $_numCols = 1;

View File

@ -0,0 +1,125 @@
<?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_UpgradeController extends CommunityID_Controller_Action
{
protected $_numCols = 1;
public function indexAction()
{
// double check upgrade is necessary in case someone access this action directly
if (!$this->_needsUpgrade()) {
$this->_redirect('');
return;
}
$appSession = Zend_Registry::get('appSession');
if (isset($appSession->loginForm)) {
$this->view->loginForm = $appSession->loginForm;
unset($appSession->loginForm);
} else {
$this->view->loginForm = new Install_Form_UpgradeLogin();
}
}
public function proceedAction()
{
// double check upgrade is necessary in case someone access this action directly
if (!$this->_needsUpgrade()) {
$this->_redirect('');
return;
}
$form = new Install_Form_UpgradeLogin();
$formData = $this->_request->getPost();
$form->populate($formData);
if (!$form->isValid($formData)) {
$appSession = Zend_Registry::get('appSession');
$appSession->loginForm = $form;
$this->_forward('index');
return;
}
$users = new Users_Model_Users();
$result = $users->authenticate($this->_request->getPost('username'),
$this->_request->getPost('password'));
if (!$result) {
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials'));
$this->_redirect('index');
return;
}
$user = $users->getUser();
if ($user->role != Users_Model_User::ROLE_ADMIN) {
Zend_Auth::getInstance()->clearIdentity();
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials'));
$this->_redirect('index');
return;
}
$this->_runUpgrades(true);
$upgradedVersion = $this->_runUpgrades(false);
$this->_helper->FlashMessenger->addMessage($this->view->translate('Upgrade was successful. You are now on version %s', $upgradedVersion));
$this->_redirect('/');
}
private function _runUpgrades($onlyCheckFiles = true)
{
require 'setup/versions.php';
$includeFiles = false;
$db = Zend_Registry::get('db');
foreach ($versions as $version) {
if ($version == $this->_getDbVersion()) {
$includeFiles = true;
continue;
}
if (!$includeFiles) {
continue;
}
$fileName = APP_DIR . '/setup/upgrade_'.$version.'.sql';
if ($onlyCheckFiles) {
if (!file_exists($fileName)) {
$this->_helper->FlashMessenger->addMessage($this->view->translate('Correct before upgrading: File %s is required to proceed', $fileName));
$this->_redirect('index');
return;
}
continue;
}
$query = '';
$lines = file($fileName);
foreach ($lines as $line) {
$line = trim($line);
if ($line != '') {
$query .= $line;
}
if (substr($line, -1) == ';') {
try {
$db->query($query);
} catch (Zend_Db_Statement_Mysqli_Exception $e) {
Zend_Registry::get('logger')->log("Error in this query: $query", Zend_Log::ERR);
throw $e;
}
$query = '';
}
}
}
return $version;
}
}

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 CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Install_Form_Install 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,29 @@
<?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 CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Install_Form_UpgradeLogin extends Zend_Form
{
public function init()
{
$username = new Monkeys_Form_Element_Text('username');
translate('Username');
$username->setLabel('Username')
->addValidator(new Monkeys_Validate_Username())
->setRequired(true);
$password = new Monkeys_Form_Element_Password('password');
$password->setLabel('Password')
->setRequired(true);
$this->addElements(array($username, $password));
}
}

View File

@ -1,5 +1,5 @@
<h3>
<?= $this->translate('The installation was performed successfully') ?>
<?php echo $this->translate('The installation was performed successfully') ?>
</h3>
<div style="margin-top:20px">
<div>
@ -7,13 +7,13 @@
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') ?>" />
<input type="button" id="start" value="<?php echo $this->translate('Finish') ?>" />
<div>
<script type="text/javascript">
var oButton = new YAHOO.widget.Button(
"start",
{
onclick: {fn: function() {location.href="<?= $this->base ?>"}}
onclick: {fn: function() {location.href="<?php echo $this->base ?>"}}
}
);
</script>

View File

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

View File

@ -1,13 +1,13 @@
<h3>
<?= $this->translate('This Community-ID instance hasn\'t been installed yet') ?>
<?php echo $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')?>" />
<input type="button" id="start" value="<?php echo $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"}}
onclick: {fn: function() {location.href="<?php echo $this->base ?>/install/credentials"}}
}
);
</script>

View File

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

View File

@ -0,0 +1,15 @@
<h2><?php echo $this->translate('New version detected') ?></h2>
<div>
<?php echo $this->translate('Enter the administrator credentials to proceed with the upgrade:') ?>
</div>
<div>
<em><?php echo $this->translate('Make sure you make a copy of the database before, just in case') ?></em>
</div>
<form action="<?php echo $this->base ?>/install/upgrade/proceed" method="post" class="formGrid" style="margin-top:30px">
<?php echo $this->loginForm->username ?>
<?php echo $this->loginForm->password ?>
<input type="submit" id="send" value="<?php echo $this->translate('Send') ?>" />
<script type="text/javascript">
var oButton = new YAHOO.widget.Button("send");
</script>
</form>