Skip to content

Commit

Permalink
A variety of small tweaks. Refs #26
Browse files Browse the repository at this point in the history
  • Loading branch information
badsyntax committed Jan 14, 2012
1 parent 666d82b commit 89d01e6
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 78 deletions.
11 changes: 5 additions & 6 deletions application/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@
* Note: If you supply an invalid environment name, a PHP warning will be thrown
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
*/
if (isset($_SERVER['KOHANA_ENV']))
if (($env = getenv('KOHANA_ENV')) !== FALSE)
{
Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
Kohana::$environment = constant('Kohana::'.strtoupper($env));
unset($env);
}
else
{
Expand Down Expand Up @@ -102,8 +103,6 @@
Kohana::$config->attach(new Config_File);

/**
* Load the modules.
* Enable the modules.
*/
$modules = Kohana::$config->load('modules')->as_array();

Kohana::modules($modules);
Kohana::modules(Kohana::$config->load('modules')->as_array());
2 changes: 1 addition & 1 deletion proxima/core/classes/proxima/controller/admin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function action_signup()
}
catch(ORM_Validation_Exception $e)
{
$errors = $e->errors('signup');
$errors = $e->errors('admin/auth/signup');

Message::set(Message::ERROR, __('Please correct the errors.'));
}
Expand Down
63 changes: 36 additions & 27 deletions proxima/core/classes/proxima/model/user.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php defined('SYSPATH') or die('No direct script access.');

class Proxima_Model_User extends Model_Auth_User {

protected $_has_many = array(
'user_tokens' => array('model' => 'user_token'),
'assets' => array('model' => 'asset'),
Expand All @@ -15,7 +15,7 @@ public function admin_add($data = array())
$this->check_passwords($data);
$this->values($data);
$this->save();

$roles = Arr::get($data, 'roles');
$groups = Arr::get($data, 'groups');

Expand Down Expand Up @@ -52,9 +52,9 @@ private function check_passwords($data)
{
// Check the passwords match.
$validation = Validation::factory($data)
->rules('password_confirm',
->rules('password_confirm',
array(
array('matches',
array('matches',
array(':validation', ':field', 'password')
)
)
Expand All @@ -81,7 +81,7 @@ public function login($data)
->rules('password', array(
array('not_empty'),
));

if ( ! $validation->check())
{
throw new Validation_Exception($validation);
Expand All @@ -95,19 +95,28 @@ public function login($data)

public function signup($data)
{
// Add a password confirmation check
$validation = Validation::factory($data)
->rules('password', array(
array('not_empty')
))
->rules('password_confirm', array(
array('matches', array(':validation', ':field', 'password')),
));

$this->values($data);
$this->save();
$this->save($validation);
$this->add('roles', new Model_Role(array('name' =>'login')));

$message_body = View::factory('admin/page/auth/email/signup')
->set('user', $this);

$swift_loader = Kohana::find_file('vendor', 'swiftmailer/lib/swift_required');

if ($swift_loader === FALSE)
{
{
throw new Exception('Swiftmailer library not found.');
}
}

require_once $swift_loader;

Expand All @@ -118,17 +127,17 @@ public function signup($data)
->addPart($message_body, 'text/plain');

$transport = Swift_MailTransport::newInstance();

Swift_Mailer::newInstance($transport)->send($message);
}

public function update_roles($roles)
{
foreach(ORM::factory('role')->find_all() as $role)
{
if (in_array($role->id, $roles))
if (in_array($role->id, $roles))
{
try
try
{
// Add roles relationship
$this->add('roles', new Model_Role(array('id' => $role->id)));
Expand All @@ -142,7 +151,7 @@ public function update_roles($roles)
}
}
}

public function update_groups($groups)
{
foreach(ORM::factory('group')->find_all() as $group)
Expand All @@ -153,10 +162,10 @@ public function update_groups($groups)
{
// Add groups relationship
$this->add('groups', new Model_Group(array('id' => $group->id)));
}
}
catch(Exception $e){}
}
else
}
else
{
// Remove groups relationship
$this->remove('groups', new Model_Group(array('id' => $group->id)));
Expand Down Expand Up @@ -187,7 +196,7 @@ public function reset_password($data)

// generate the token
$token = Auth::instance()->hash_password($this->email.'+'.$this->password);

// generate the reset password link
$url = URL::site('admin/auth/confirm_reset_password?id=' . $this->id . '&auth_token=' . $token, TRUE);

Expand All @@ -201,9 +210,9 @@ public function reset_password($data)
$swift_loader = Kohana::find_file('vendor', 'swiftmailer/lib/swift_required');

if ($swift_loader === FALSE)
{
{
throw new Kohana_Exception('Swiftmailer library not found.');
}
}

require_once $swift_loader;

Expand All @@ -224,21 +233,21 @@ public function confirm_reset_password(& $data, $token)
{
$cookie_token = Cookie::get('token', FALSE);

if ( $token !== $cookie_token )
if ( $token !== $cookie_token )
{
throw new Exception(__('Invalid auth token.'));
}

$rules = array_merge(
$this->rules(),
array('password_confirm' =>
array('password_confirm' =>
array(
array('matches',
array('matches',
array(':validation', ':field', 'password')
)
)
)
)
)
);
);

$data = Validation::factory($data)
->rules('password', $rules['password'])
Expand Down Expand Up @@ -270,9 +279,9 @@ public function friendly_date()
public function __get($key)
{
if ($key === 'friendly_date')
{
{
return $this->friendly_date();
}
}

return parent::__get($key);
}
Expand Down
8 changes: 4 additions & 4 deletions proxima/core/classes/proxima/view/model/admin/master.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ public function __construct($file = NULL, array $data = NULL)

$this
->styles(array(
(array) Kohana::$config->load('admin/media.styles'),
(array) Kohana::$config->load('admin/media.styles'),
(array) Kohana::$config->load('admin/'.$request->controller().'.styles')
))
))
->scripts(array(
(array) Kohana::$config->load('admin/media.scripts'),
(array) Kohana::$config->load('admin/'.$request->controller().'.scripts'),
))
))
->paths(array(
(array) Kohana::$config->load('admin/media.paths'),
(array) Kohana::$config->load('admin/'.$request->controller().'.paths'),
));
));
}
}
6 changes: 3 additions & 3 deletions proxima/core/config/admin/auth.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php defined('SYSPATH') or die('No direct script access.');

return array(
'scripts' => array(
'modules/users/media/js/admin/auth.js'
),
'scripts' => Core::path(array(
'media/js/admin/auth.js'
)),
'styles' => array(
),
);
2 changes: 1 addition & 1 deletion proxima/core/config/admin/nav.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php defined('SYSPATH') or die('No direct script access.');

/*
* Auto generated on: Friday 13th of January 2012 08:41:45 PM
* Auto generated on: Saturday 14th of January 2012 09:10:32 AM
*/

return array(
Expand Down
21 changes: 5 additions & 16 deletions proxima/core/media/css/admin/admin.global.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@ input,textarea{
-o-transition: border linear 0.2s, box-shadow linear 0.2s;
transition: border linear 0.2s, box-shadow linear 0.2s;:
}
input:focus, textarea:focus {
outline: 0;
input:focus, textarea:focus { outline: 0;
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 4px rgba(82, 168, 236, 0.6);
-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 4px rgba(82, 168, 236, 0.6);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 4px rgba(0, 0, 0, 0.6);
}
input.error-field:focus, textarea.error-field:focus {

border-color: #BB0000;
}
input.error-field:focus, textarea.error-field:focus { border-color: #BB0000; }
code{font-family:monaco,monospace;}
table{border-collapse:collapse;width:100%;}
table th, table td{padding:0.4em;text-align:left;vertical-align:top;}
Expand All @@ -53,20 +49,13 @@ table td.pass{color:#191;}
table td.fail{color:#911;}
#install,#content{text-align:left;margin:3em auto;width:356px;border:4px solid transparent;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 0 18px rgba(0,0,0,0.4);-moz-box-shadow:0 0 18px rgba(0,0,0,0.4);box-shadow:0 0 18px rgba(0,0,0,0.4);}
#messages{display:none;width:360px;margin:2em auto -1em auto;text-align:left;}
#messages{-webkit-box-shadow:0 0 10px rgba(0,0,0,0.4);-moz-box-shadow:0 0 18px rgba(0,0,0,0.4);box-shadow:0 0 10px rgba(0,0,0,0.4); -moz-border-radius: 4px;
#messages{-moz-border-radius: 4px;
-webkit-border-radius: 4px;}
#messages .inner{
padding: 10px 10px 5px 10px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;border: 1px solid #CD0A0A;
background: #FEF1EC;
color: #CD0A0A;}
#messages .inner{ padding: 10px 10px 5px 10px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; background: #FFF; color: #CD0A0A;}
#messages ul{margin:0;padding:0;}
#messages ul li{list-style:none;margin-bottom:5px;}
#messages p{margin:0;}
#messages span{float: left;
margin-right: .3em;background:url(../../img/admin/red-icons.png) no-repeat 0 -144px;width: 16px;
height: 16px;}
#messages span{float: left; margin-right: .3em;background:url(../../img/admin/red-icons.png) no-repeat 0 -144px;width: 16px; height: 16px;}
#install.tests{width:626px;}
#inner{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#fbfbfb');background:-webkit-gradient(linear,left top,left bottom,from(white),to(#FBFBFB));background:-moz-linear-gradient(top,white,#FBFBFB);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;padding:.8em 1.2em;}
#loading{display:none;}
Expand Down
17 changes: 16 additions & 1 deletion proxima/core/media/js/admin/auth.js
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
// auth.js
// auth.js

$(function(){

$('input').each(function(key, elem){
if ( $.trim(this.value) === '' || $(this).hasClass('error-field') ){
this.focus();
return false;
}
});

if ($('#messages').find('li').length){
$('#messages').fadeIn();
}

});
12 changes: 1 addition & 11 deletions proxima/core/media/js/install/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,10 @@
var hasFocus = false;
$fields.each(function(key, elem){
var $field = $(elem);
if ($field.hasClass('error-field')) {
$field.blur(function(){
if ($.trim(this.value) !== '') {
$field
.removeClass('error-field')
.prev()
.find('.label-error')
.remove();
}
});
}
if ( !hasFocus && ( $.trim(this.value) === '' || $field.hasClass('error-field') )){
this.focus();
hasFocus = true;
return false;
}
});
return arguments.callee;
Expand Down
7 changes: 7 additions & 0 deletions proxima/core/messages/admin/auth/signup/_external.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php defined('SYSPATH') or die('No direct script access.');

return array(
'password_confirm' => array(
'matches' => 'password confirm must match'
)
);
14 changes: 14 additions & 0 deletions proxima/core/messages/admin/auth/signup/user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php defined('SYSPATH') or die('No direct script access.');

return array(
'email' => array(
'unique' => 'email address is already registered',
),
'username' => array(
'unique' => 'username is already registered',
),
'_external' => array(
'password_confirm' => array(
'matches' => 'password confirm must match password'
)
);
8 changes: 0 additions & 8 deletions proxima/core/views/admin/page/auth/master/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,5 @@

<?php echo View::factory('admin/page/fragments/footer', array('paths' => $paths)) ?>
</div>
<script>
if ($('#messages').find('li').length){
$('#messages').fadeIn();
setTimeout(function(){
//$('#messages').fadeOut();
}, 5000);
}
</script>
</body>
</html>

0 comments on commit 89d01e6

Please sign in to comment.