import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
@ -11,6 +11,8 @@
|
||||
|
||||
class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
{
|
||||
const PHP_MINIMAL_VERSION_REQUIRED = '5.2.4';
|
||||
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
@ -39,14 +41,14 @@ class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
}
|
||||
|
||||
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.');
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('We couldn\'t connect to the database using those credentials.'));
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('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.');
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate(
|
||||
'The connection to the database engine worked, but the database %s 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.', $form->getValue('dbname')));
|
||||
return $this->_forwardFormError($form);
|
||||
}
|
||||
|
||||
@ -57,7 +59,7 @@ class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
throw new Exception('Couldn\'t write to config file ' . APP_DIR . DIRECTORY_SEPARATOR . 'config.php');
|
||||
}
|
||||
|
||||
$this->_forward('index', 'complete');
|
||||
$this->_redirect('/install/complete');
|
||||
}
|
||||
|
||||
private function _connectToDbEngine(Install_Form_Install $form)
|
||||
@ -111,9 +113,12 @@ class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
'{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.unconfirmed_accounts_days_expire}' => $this->_config->environment->unconfirmed_accounts_days_expire,
|
||||
'{environment.registrations_enabled}' => $this->_config->environment->registrations_enabled? 'true' : 'false',
|
||||
'{environment.locale}' => $this->_config->environment->locale,
|
||||
'{environment.template}' => $this->_config->environment->template,
|
||||
'{metadata.description}' => $this->_config->metadata->description,
|
||||
'{metadata.keywords}' => $this->_config->metadata->keywords,
|
||||
'{logging.location}' => $this->_config->logging->location,
|
||||
'{logging.level}' => $this->_config->logging->level,
|
||||
'{subdomain.enabled}' => $this->_config->subdomain->enabled? 'true' : 'false',
|
||||
@ -125,6 +130,31 @@ class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
'{database.params.dbname}' => $this->_config->database->params->dbname,
|
||||
'{database.params.username}' => $this->_config->database->params->username,
|
||||
'{database.params.password}' => $this->_config->database->params->password,
|
||||
'{security.passwords.dictionary}' => $this->_config->security->passwords->dictionary,
|
||||
'{security.passwords.username_different}' => $this->_config->security->passwords->username_different? 'true' : 'false',
|
||||
'{security.passwords.minimum_length}' => $this->_config->security->passwords->minimum_length,
|
||||
'{security.passwords.include_numbers}'=> $this->_config->security->passwords->include_numbers? 'true' : 'false',
|
||||
'{security.passwords.include_symbols}'=> $this->_config->security->passwords->include_symbols? 'true' : 'false',
|
||||
'{security.passwords.lowercase_and_uppercase}' => $this->_config->security->passwords->lowercase_and_uppercase? 'true' : 'false',
|
||||
'{security.usernames.exclude}' => $this->_config->security->usernames->exclude->current(),
|
||||
'{ldap.enabled}' => $this->_config->ldap->enabled? 'true' : 'false',
|
||||
'{ldap.host}' => $this->_config->ldap->host,
|
||||
'{ldap.baseDn}' => $this->_config->ldap->baseDn,
|
||||
'{ldap.bindRequiresDn}' => $this->_config->ldap->bindRequiresDn? 'true' : 'false',
|
||||
'{ldap.username}' => $this->_config->ldap->username,
|
||||
'{ldap.password}' => $this->_config->ldap->password,
|
||||
'{ldap.admin}' => $this->_config->ldap->admin,
|
||||
'{ldap.keepRecordsSynced}' => $this->_config->ldap->keepRecordsSynced? 'true' : 'false',
|
||||
'{ldap.canChangePassword}' => $this->_config->ldap->canChangePassword? 'true' : 'false',
|
||||
'{ldap.passwordHashing}' => $this->_config->ldap->passwordHashing,
|
||||
'{ldap.fields.nickname}' => $this->_config->ldap->fields->nickname,
|
||||
'{ldap.fields.email}' => $this->_config->ldap->fields->email,
|
||||
'{ldap.fields.fullname}' => $this->_config->ldap->fields->fullname,
|
||||
'{ldap.fields.postcode}' => $this->_config->ldap->fields->postcode,
|
||||
'{yubikey.enabled}' => $this->_config->yubikey->enabled? 'true' : 'false',
|
||||
'{yubikey.force}' => $this->_config->yubikey->force? 'true' : 'false',
|
||||
'{yubikey.api_id}' => $this->_config->yubikey->api_id,
|
||||
'{yubikey.api_key}' => $this->_config->yubikey->api_key,
|
||||
'{email.supportemail}' => $this->_config->email->supportemail,
|
||||
'{email.adminemail}' => $this->_config->email->adminemail,
|
||||
'{email.transport}' => $this->_config->email->transport,
|
||||
@ -147,7 +177,7 @@ class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
{
|
||||
$users = new Users_Model_Users();
|
||||
$user = $users->createRow();
|
||||
$user->username = $form->getValue('adminUsername');
|
||||
$user->username = $form->getValue('username');
|
||||
$user->accepted_eula = 1;
|
||||
$user->registration_date = date('Y-m-d');
|
||||
$user->openid = '';
|
||||
@ -196,6 +226,10 @@ class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
$errors = array();
|
||||
$webServerUser = $this->_getProcessUser();
|
||||
|
||||
if (version_compare(PHP_VERSION, self::PHP_MINIMAL_VERSION_REQUIRED, '<')) {
|
||||
$errors[] = $this->view->translate('PHP version %s or greater is required',
|
||||
self::PHP_MINIMAL_VERSION_REQUIRED);
|
||||
}
|
||||
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);
|
||||
}
|
||||
@ -205,6 +239,18 @@ class Install_CredentialsController extends CommunityID_Controller_Action
|
||||
if (!extension_loaded('mysqli')) {
|
||||
$errors[] = $this->view->translate('You need to have the %s extension installed', '<a href="http://www.php.net/manual/en/mysqli.installation.php">MySQLi</a>');
|
||||
}
|
||||
if (!extension_loaded('gd')) {
|
||||
$errors[] = $this->view->translate('You need to have the %s extension installed', '<a href="http://www.php.net/manual/en/image.installation.php">GD</a>');
|
||||
}
|
||||
if (!function_exists('imagepng')) {
|
||||
$errors[] = $this->view->translate('You need to have <a href="http://www.php.net/manual/en/image.installation.php">PNG support in your GD configuration</a>');
|
||||
}
|
||||
if (!function_exists('imageftbbox')) {
|
||||
$errors[] = $this->view->translate('You need to have <a href="http://www.php.net/manual/en/image.installation.php">Freetype support in your GD configuration</a>');
|
||||
}
|
||||
if (!function_exists('curl_init')) {
|
||||
$errors[] = $this->view->translate('You need to have the %s extension installed', '<a href="http://co.php.net/manual/en/curl.setup.php">cURL</a>');
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
@ -50,8 +50,15 @@ class Install_UpgradeController extends CommunityID_Controller_Action
|
||||
}
|
||||
|
||||
$users = new Users_Model_Users();
|
||||
$result = $users->authenticate($this->_request->getPost('username'),
|
||||
$this->_request->getPost('password'));
|
||||
list($super, $mayor, $minor) = explode('.', $this->_getDbVersion());
|
||||
$greaterThan2 = $super >= 2;
|
||||
$result = $users->authenticate(
|
||||
$this->_request->getPost('username'),
|
||||
$this->_request->getPost('password'),
|
||||
false,
|
||||
$this->view,
|
||||
!$greaterThan2 // bypass mark successfull login 'cause last_login field only exists after v.2
|
||||
);
|
||||
|
||||
if (!$result) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials'));
|
||||
@ -72,6 +79,11 @@ class Install_UpgradeController extends CommunityID_Controller_Action
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Upgrade was successful. You are now on version %s', $upgradedVersion));
|
||||
|
||||
$missingConfigs = $this->_checkMissingConfigDirectives();
|
||||
if ($missingConfigs) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('WARNING: there are some new configuration settings. To override their default values (as set in config.default.php) add them to your config.php file. The new settings correspond to the following directives: %s.', implode(', ', $missingConfigs)));
|
||||
}
|
||||
|
||||
// we need to logout user in case the user table changed
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
Zend_Session::forgetMe();
|
||||
@ -85,6 +97,7 @@ class Install_UpgradeController extends CommunityID_Controller_Action
|
||||
|
||||
$includeFiles = false;
|
||||
$db = Zend_Registry::get('db');
|
||||
$errors = array();
|
||||
foreach ($versions as $version) {
|
||||
if ($version == $this->_getDbVersion()) {
|
||||
$includeFiles = true;
|
||||
@ -95,19 +108,29 @@ class Install_UpgradeController extends CommunityID_Controller_Action
|
||||
continue;
|
||||
}
|
||||
|
||||
$fileName = APP_DIR . '/setup/upgrade_'.$version.'.sql';
|
||||
$sqlFileName = APP_DIR . '/setup/upgrade_'.$version.'.sql';
|
||||
$phpFileName = APP_DIR . '/setup/upgrade_'.$version.'.php';
|
||||
$className = 'Upgrade_' . strtr($version, '.', '_');
|
||||
|
||||
if ($onlyCheckFiles) {
|
||||
if (!file_exists($fileName)) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Correct before upgrading: File %s is required to proceed', $fileName));
|
||||
if (!file_exists($sqlFileName)) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Correct before upgrading: File %s is required to proceed', $sqlFileName));
|
||||
$this->_redirect('index');
|
||||
return;
|
||||
}
|
||||
|
||||
if (file_exists($phpFileName)) {
|
||||
require_once $phpFileName;
|
||||
$upgradeStage = new $className($this->user, $db, $this->view);
|
||||
$errors = array_merge($errors, $upgradeStage->requirements());
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$query = '';
|
||||
$lines = file($fileName);
|
||||
$lines = file($sqlFileName);
|
||||
Zend_Registry::get('logger')->log("Running upgrade file $sqlFileName", Zend_Log::DEBUG);
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if ($line != '') {
|
||||
@ -123,8 +146,47 @@ class Install_UpgradeController extends CommunityID_Controller_Action
|
||||
$query = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($phpFileName)) {
|
||||
Zend_Registry::get('logger')->log("Running upgrade file $phpFileName", Zend_Log::DEBUG);
|
||||
$upgradeStage = new $className($this->user, $db, $this->view);
|
||||
$upgradeStage->proceed();
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
$errorMessages = join('<br />', $errors);
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Please address the following requirements before proceeding with the upgrade:') . '<br />' . $errorMessages);
|
||||
$this->_redirect('index');
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
private function _checkMissingConfigDirectives()
|
||||
{
|
||||
require 'config.default.php';
|
||||
$defaultConfig = $config;
|
||||
unset($config);
|
||||
require 'config.php';
|
||||
$missingConfigs = $this->_getMissingConfigs($defaultConfig, $config);
|
||||
return $missingConfigs;
|
||||
}
|
||||
|
||||
private function _getMissingConfigs($defaultConfig, $config, $baseKey = false)
|
||||
{
|
||||
$missingConfigs = array();
|
||||
|
||||
foreach ($defaultConfig as $key => $value) {
|
||||
if (!isset($config[$key])) {
|
||||
$missingConfigs[] = $key;
|
||||
} else if (is_array($value)) {
|
||||
if ($this->_getMissingConfigs($defaultConfig[$key], $config[$key], $baseKey)) {
|
||||
$missingConfigs[] = $baseKey? $baseKey : $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $missingConfigs;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
@ -15,6 +15,8 @@ class Install_Form_Install extends Zend_Form
|
||||
public function init()
|
||||
{
|
||||
$hostname = new Monkeys_Form_Element_Text('hostname');
|
||||
translate('Hostname');
|
||||
translate('usually localhost');
|
||||
$hostname->setLabel('Hostname')
|
||||
->setDescription('usually localhost')
|
||||
->setRequired(true)
|
||||
@ -22,20 +24,25 @@ class Install_Form_Install extends Zend_Form
|
||||
->setValue('localhost');
|
||||
|
||||
$dbname = new Monkeys_Form_Element_Text('dbname');
|
||||
translate('Database name');
|
||||
$dbname->setLabel('Database name')
|
||||
->setRequired(true)
|
||||
->setDecoratorOptions(array('dontMarkRequired' => true))
|
||||
->setValue(Zend_Registry::get('config')->database->params->dbname);
|
||||
|
||||
$dbusername = new Monkeys_Form_Element_Text('dbusername');
|
||||
translate('Database username');
|
||||
$dbusername->setLabel('Database username')
|
||||
->setRequired(true)
|
||||
->setDecoratorOptions(array('dontMarkRequired' => true));
|
||||
|
||||
$dbpassword = new Monkeys_Form_Element_Password('dbpassword');
|
||||
translate('Database password');
|
||||
$dbpassword->setLabel('Database password');
|
||||
|
||||
$supportemail = new Monkeys_Form_Element_Text('supportemail');
|
||||
translate('Support E-mail');
|
||||
translate('Will be used as the sender for any message sent by the system, and as the recipient for user feedback');
|
||||
$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')
|
||||
@ -43,24 +50,32 @@ class Install_Form_Install extends Zend_Form
|
||||
->setRequired(true)
|
||||
->setDecoratorOptions(array('dontMarkRequired' => true));
|
||||
|
||||
$adminUsername = new Monkeys_Form_Element_Text('adminUsername');
|
||||
$adminUsername->setLabel('Username')
|
||||
->setRequired(true)
|
||||
->setDecoratorOptions(array('dontMarkRequired' => true));
|
||||
$username = new Monkeys_Form_Element_Text('username');
|
||||
$username->setLabel('Username')
|
||||
->setRequired(true)
|
||||
->setDecoratorOptions(array('dontMarkRequired' => true));
|
||||
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter password');
|
||||
$passwordValidator = new Monkeys_Validate_Password();
|
||||
$password1->setLabel('Enter password')
|
||||
->setRequired(true)
|
||||
->setDecoratorOptions(array('dontMarkRequired' => true))
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation())
|
||||
->addValidator($passwordValidator);
|
||||
|
||||
if ($restrictions = $passwordValidator->getPasswordRestrictionsDescription()) {
|
||||
$password1->setDescription($restrictions);
|
||||
}
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
$password2->setLabel('Enter password again')
|
||||
->setRequired(true)
|
||||
->setDecoratorOptions(array('dontMarkRequired' => true));
|
||||
|
||||
|
||||
$this->addElements(array($hostname, $dbname, $dbusername, $dbpassword, $supportemail,
|
||||
$adminUsername, $password1, $password2));
|
||||
$username, $password1, $password2));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
@ -21,6 +21,7 @@ class Install_Form_UpgradeLogin extends Zend_Form
|
||||
->setRequired(true);
|
||||
|
||||
$password = new Monkeys_Form_Element_Password('password');
|
||||
translate('Password');
|
||||
$password->setLabel('Password')
|
||||
->setRequired(true);
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
<?php echo $this->translate('Administrator User Information') ?>
|
||||
</h3>
|
||||
<div class="yui-gf" style="margin-top:20px">
|
||||
<?php echo $this->form->adminUsername ?>
|
||||
<?php echo $this->form->username ?>
|
||||
<?php echo $this->form->password1 ?>
|
||||
<?php echo $this->form->password2 ?>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user