Updates from lnApp
This commit is contained in:
@@ -79,5 +79,12 @@ abstract class Controller_lnApp_Default extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function after() {
|
||||
parent::after();
|
||||
|
||||
// Generate and check the ETag for this file
|
||||
$this->response->check_cache(NULL,$this->request);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -12,6 +12,8 @@
|
||||
* @also [logout]
|
||||
*/
|
||||
class Controller_lnApp_Login extends Controller_TemplateDefault {
|
||||
protected $auth_required = FALSE;
|
||||
|
||||
public function action_index() {
|
||||
// If user already signed-in
|
||||
if (Auth::instance()->logged_in()!= 0) {
|
||||
@@ -21,6 +23,10 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
||||
|
||||
// If there is a post and $_POST is not empty
|
||||
if ($_POST) {
|
||||
// Store our details in a session key
|
||||
Session::instance()->set(Kohana::config('auth.session_key'),$_POST['username']);
|
||||
Session::instance()->set('password',$_POST['password']);
|
||||
|
||||
// If the post data validates using the rules setup in the user model
|
||||
if (Auth::instance()->login($_POST['username'],$_POST['password'])) {
|
||||
// Redirect to the user account
|
||||
@@ -46,8 +52,6 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
||||
'style'=>array('css/login.css'=>'screen'),
|
||||
));
|
||||
|
||||
$this->template->control = HTML::anchor($this->request->uri(),'Login',array('id'=>'ajxbody'));
|
||||
|
||||
Script::add(array('type'=>'stdin','data'=>'
|
||||
$(document).ready(function() {
|
||||
$("#ajxbody").click(function() {$("#ajBODY").load("'.$this->request->uri().'/"); return false;});
|
||||
@@ -71,7 +75,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
||||
$status = $account->values($_POST)->check();
|
||||
|
||||
if (! $status) {
|
||||
foreach ($account->validate()->errors() as $f=>$r) {
|
||||
foreach ($account->validation()->errors('form/register') as $f => $r) {
|
||||
// $r[0] has our reason for validation failure
|
||||
switch ($r[0]) {
|
||||
// Generic validation reason
|
||||
@@ -79,7 +83,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Validation failed'),
|
||||
'type'=>'error',
|
||||
'body'=>sprintf(_('The defaults on your submission were not valid for field %s (%s).'),$f,$r[0])
|
||||
'body'=>sprintf(_('The defaults on your submission were not valid for field %s (%s).'),$f,$r)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -108,7 +112,6 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
||||
->set('errors',$account->validation()->errors('form/register')),
|
||||
));
|
||||
|
||||
$this->template->control = HTML::anchor($this->request->uri(),'Register',array('id'=>'ajxbody'));
|
||||
$this->template->left = HTML::anchor('login','Login').'...';
|
||||
}
|
||||
|
||||
|
@@ -144,6 +144,9 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
||||
}
|
||||
|
||||
public function after() {
|
||||
if (! is_string($this->template) AND empty($this->template->content))
|
||||
$this->template->content = Block::factory();
|
||||
|
||||
if ($this->auto_render) {
|
||||
// Application Title
|
||||
$this->meta->title = 'Application Title';
|
||||
@@ -189,10 +192,10 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
||||
$this->response->bodyadd(sprintf('<table class="content"><tr><td>%s</td></tr></table>',$this->template->content));
|
||||
}
|
||||
|
||||
if (isset($this->template->content) AND ! $this->template->content)
|
||||
$this->template->content = Block::factory();
|
||||
|
||||
parent::after();
|
||||
|
||||
// Generate and check the ETag for this file
|
||||
$this->response->check_cache(NULL,$this->request);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,9 +243,6 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
||||
* @return void
|
||||
*/
|
||||
final public function action_media() {
|
||||
// Generate and check the ETag for this file
|
||||
$this->response->check_cache(NULL,$this->request);
|
||||
|
||||
// Get the file path from the request
|
||||
$file = $this->request->param('file');
|
||||
|
||||
@@ -251,9 +251,14 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
||||
|
||||
// Remove the extension from the filename
|
||||
$file = substr($file, 0, -(strlen($ext) + 1));
|
||||
$f = '';
|
||||
|
||||
// If our file is pathed with session, our file is in our session.
|
||||
if ($fd = Session::instance()->get_once($this->request->param('file'))) {
|
||||
$this->response->body($fd);
|
||||
|
||||
// First try and find media files for the site_id
|
||||
if ($f = Kohana::find_file(sprintf('media/%s',Config::siteid()), $file, $ext)) {
|
||||
} elseif ($f = Kohana::find_file(sprintf('media/%s',Config::siteid()), $file, $ext)) {
|
||||
// Send the file content as the response
|
||||
$this->response->body(file_get_contents($f));
|
||||
|
||||
@@ -267,10 +272,13 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
||||
$this->response->status(404);
|
||||
}
|
||||
|
||||
// Generate and check the ETag for this file
|
||||
$this->response->check_cache(NULL,$this->request);
|
||||
|
||||
// Set the proper headers to allow caching
|
||||
$this->response->headers('Content-Type',File::mime_by_ext($ext));
|
||||
$this->response->headers('Content-Length',(string)filesize($f));
|
||||
$this->response->headers('Last-Modified',date('r', filemtime($f)));
|
||||
$this->response->headers('Content-Length',(string)$this->response->content_length());
|
||||
$this->response->headers('Last-Modified',date('r', $f ? filemtime($f) : time()));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -83,20 +83,18 @@ $(function () {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public function action_json($id=null) {
|
||||
#if (! Auth::instance()->logged_in()) {
|
||||
if ($this->_auth_required()) {
|
||||
$this->treedata = array('attr'=>array('id'=>'a_login'),
|
||||
public function action_json($id=null,array $data=array()) {
|
||||
if ($this->_auth_required() AND ! Auth::instance()->logged_in()) {
|
||||
$this->output = array('attr'=>array('id'=>'a_login'),
|
||||
'data'=>array('title'=>_('Please Login').'...','attr'=>array('id'=>'N_login','href'=>URL::site('/login'))));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->treedata = array();
|
||||
$data = array();
|
||||
$this->output = array();
|
||||
|
||||
foreach ($data as $branch) {
|
||||
array_push($this->treedata,array(
|
||||
array_push($this->output,array(
|
||||
'attr'=>array('id'=>sprintf('B_%s',$branch['id'])),
|
||||
'state'=>$branch['state'],
|
||||
'data'=>array('title'=>$branch['name']),
|
||||
|
Reference in New Issue
Block a user