Some internal reorg
This commit is contained in:
parent
9ae0980221
commit
037633f084
4
classes/Auth/ORM.php
Normal file
4
classes/Auth/ORM.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
class Auth_ORM extends lnApp_Auth_ORM {}
|
||||||
|
?>
|
4
classes/Controller/User/Welcome.php
Normal file
4
classes/Controller/User/Welcome.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
class Controller_User_Welcome extends lnApp_Controller_User_Welcome {}
|
||||||
|
?>
|
@ -1,9 +1,4 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct script access.');
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
class Controller_Welcome extends Controller_TemplateDefault {
|
class Controller_Welcome extends lnApp_Controller_Welcome {}
|
||||||
protected $auth_required = FALSE;
|
?>
|
||||||
|
|
||||||
public function action_index() {
|
|
||||||
throw HTTP_Exception::factory(500,'Site not setup!');
|
|
||||||
}
|
|
||||||
} // End Welcome
|
|
||||||
|
4
classes/Model/Account.php
Normal file
4
classes/Model/Account.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
class Model_Account extends lnApp_Model_Account {}
|
||||||
|
?>
|
4
classes/Model/Auth/UserDefault.php
Normal file
4
classes/Model/Auth/UserDefault.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
abstract class Model_Auth_UserDefault extends lnApp_Model_Auth_UserDefault {}
|
||||||
|
?>
|
4
classes/Model/Country.php
Normal file
4
classes/Model/Country.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
class Model_Country extends lnApp_Model_Country {}
|
||||||
|
?>
|
4
classes/Model/Language.php
Normal file
4
classes/Model/Language.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
class Model_Language extends lnApp_Model_Language {}
|
||||||
|
?>
|
4
classes/StaticList/Title.php
Normal file
4
classes/StaticList/Title.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
class StaticList_Title extends lnApp_StaticList_Title {}
|
||||||
|
?>
|
140
classes/lnApp/Auth/ORM.php
Normal file
140
classes/lnApp/Auth/ORM.php
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auth driver.
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Classes
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_Auth_ORM extends Kohana_Auth_ORM {
|
||||||
|
/**
|
||||||
|
* We need to override Kohana's __construct(), for tasks, which attempt to open a session
|
||||||
|
* and probably dont have access to PHP sessions path.
|
||||||
|
* Tasks dont need sessions anyway?
|
||||||
|
*/
|
||||||
|
public function __construct($config = array()) {
|
||||||
|
// Save the config in the object
|
||||||
|
$this->_config = $config;
|
||||||
|
|
||||||
|
if (PHP_SAPI !== 'cli')
|
||||||
|
parent::__construct($config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a user in.
|
||||||
|
*
|
||||||
|
* @param string username
|
||||||
|
* @param string password
|
||||||
|
* @param boolean enable autologin
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
protected function _login($user,$password,$remember) {
|
||||||
|
if (! is_object($user)) {
|
||||||
|
$username = $user;
|
||||||
|
|
||||||
|
// Load the user
|
||||||
|
$user = ORM::factory($this->_model);
|
||||||
|
$user->where('email','=',$username)->find();
|
||||||
|
|
||||||
|
// If no user loaded, return
|
||||||
|
if (! $user->loaded())
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a hashed password
|
||||||
|
if (is_string($password))
|
||||||
|
$password = $this->hash($password);
|
||||||
|
|
||||||
|
// If we have the right password, we'll check the status of the account
|
||||||
|
if ($user->password === $password AND $user->active) {
|
||||||
|
// Record our session ID, we may need to update our DB when we get a new ID
|
||||||
|
$oldsess = session_id();
|
||||||
|
|
||||||
|
// Finish the login
|
||||||
|
$this->complete_login($user);
|
||||||
|
|
||||||
|
// Do we need to update databases with our new sesion ID
|
||||||
|
$sct = Kohana::$config->load('config')->session_change_trigger;
|
||||||
|
if (session_id() != $oldsess AND count($sct))
|
||||||
|
foreach ($sct as $t => $c)
|
||||||
|
if (Config::module_exist($t))
|
||||||
|
foreach (ORM::factory(ucwords($t))->where($c,'=',$oldsess)->find_all() as $o)
|
||||||
|
$o->set('session_id',session_id())
|
||||||
|
->update();
|
||||||
|
|
||||||
|
//@TODO
|
||||||
|
if (! $user->has_any('group',ORM::factory('Group',array('name'=>'Registered Users'))->list_childgrps(TRUE)))
|
||||||
|
HTTP::redirect(URL::link('user','account/activate'));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Login failed
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a user is authorised to view an account
|
||||||
|
*
|
||||||
|
* @param Model_Account Account Ojbect to validate if the current user has access
|
||||||
|
* @return boolean TRUE if authorised, FALSE if not.
|
||||||
|
*/
|
||||||
|
public function authorised(Model_Account $ao) {
|
||||||
|
return (($uo = $this->get_user()) AND $uo->loaded() AND ($uo == $ao OR in_array($ao->id,$uo->RTM->customers($uo->RTM))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_groups() {
|
||||||
|
return is_null($x=$this->get_user()) ? ORM::factory('Group')->where('id','=',0)->find_all() : $x->groups();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override Kohana Auth requirement to have a hash_key
|
||||||
|
public function hash($str) {
|
||||||
|
switch ($this->_config['hash_method']) {
|
||||||
|
case '' : return $str;
|
||||||
|
case 'md5': return md5($str);
|
||||||
|
default: return hash_hmac($this->_config['hash_method'], $str, $this->_config['hash_key']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OSB authentication is controlled via database queries.
|
||||||
|
*
|
||||||
|
* This method can be used to test two situations:
|
||||||
|
* 1) Is the user logged in? ($role == FALSE)
|
||||||
|
* 2) Can the user run the current controller->action ($role == TRUE)
|
||||||
|
*
|
||||||
|
* @param boolean If authentication should be done for this module:method (ie: controller:action).
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function logged_in($role=NULL,$debug=NULL) {
|
||||||
|
$status = FALSE;
|
||||||
|
|
||||||
|
// If we are a CLI, we are not logged in
|
||||||
|
if (PHP_SAPI === 'cli')
|
||||||
|
return $status;
|
||||||
|
|
||||||
|
// Get the user from the session
|
||||||
|
$uo = $this->get_user();
|
||||||
|
|
||||||
|
// If we are not a valid user object, then we are not logged in
|
||||||
|
if (is_object($uo) AND ($uo instanceof Model_Account) AND $uo->loaded())
|
||||||
|
if (! empty($role)) {
|
||||||
|
if (($x = Request::current()->mmo()) instanceof Model)
|
||||||
|
// If the role has the authorisation to run the method
|
||||||
|
foreach ($x->group->find_all() as $go)
|
||||||
|
if ($go->id == 0 OR $uo->has_any('group',$go->list_childgrps(TRUE))) {
|
||||||
|
$status = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// There is no role, so the method should be allowed to run as anonymous
|
||||||
|
} else
|
||||||
|
$status = TRUE;
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -56,7 +56,9 @@ abstract class lnApp_Controller_TemplateDefault extends Kohana_Controller_Templa
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function _auth_required() {
|
protected function _auth_required() {
|
||||||
return FALSE;
|
return (($this->auth_required !== FALSE && Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__) === FALSE) ||
|
||||||
|
(is_array($this->secure_actions) && array_key_exists($this->request->action(),$this->secure_actions) &&
|
||||||
|
! Auth::instance()->logged_in($this->secure_actions[$this->request->action()],get_class($this).'|'.__METHOD__)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
19
classes/lnApp/Controller/User/Welcome.php
Normal file
19
classes/lnApp/Controller/User/Welcome.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct script access.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main home page
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Controllers/User
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2009-2013 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_Controller_User_Welcome extends Controller_Welcome {
|
||||||
|
protected $auth_required = TRUE;
|
||||||
|
|
||||||
|
public function action_index() {
|
||||||
|
throw HTTP_Exception::factory(500,'Site not setup!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
19
classes/lnApp/Controller/Welcome.php
Normal file
19
classes/lnApp/Controller/Welcome.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct script access.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main home page for un-authenticated users
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Controllers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2009-2013 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_Controller_Welcome extends Controller_TemplateDefault {
|
||||||
|
protected $auth_required = FALSE;
|
||||||
|
|
||||||
|
public function action_index() {
|
||||||
|
throw HTTP_Exception::factory(500,'Site not setup!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
152
classes/lnApp/Model/Account.php
Normal file
152
classes/lnApp/Model/Account.php
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Model manages both the accounts that users use to login to the system, as well as the account where services are owned.
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Models
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_Model_Account extends Model_Auth_UserDefault {
|
||||||
|
// Relationships
|
||||||
|
protected $_has_many = array(
|
||||||
|
'email_log'=>array('far_key'=>'id'),
|
||||||
|
'group'=>array('through'=>'account_group'),
|
||||||
|
);
|
||||||
|
|
||||||
|
protected $_has_one = array(
|
||||||
|
'country'=>array('foreign_key'=>'id'),
|
||||||
|
'currency'=>array('foreign_key'=>'id'),
|
||||||
|
'language'=>array('foreign_key'=>'id'),
|
||||||
|
);
|
||||||
|
|
||||||
|
protected $_display_filters = array(
|
||||||
|
'date_orig'=>array(
|
||||||
|
array('Site::Date',array(':value')),
|
||||||
|
),
|
||||||
|
'date_last'=>array(
|
||||||
|
array('Site::Date',array(':value')),
|
||||||
|
),
|
||||||
|
'active'=>array(
|
||||||
|
array('StaticList_YesNo::get',array(':value',TRUE)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
protected $_form = array('id'=>'id','value'=>'name(TRUE)');
|
||||||
|
|
||||||
|
protected $_save_message = TRUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our account number format
|
||||||
|
*/
|
||||||
|
public function accnum() {
|
||||||
|
return sprintf('%s-%04s',Company::instance()->site(TRUE),$this->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activate_code() {
|
||||||
|
return md5(sprintf('%s-%s-%s-%s',$this->accnum(),$this->date_orig,$this->date_last,$this->email));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activated() {
|
||||||
|
return $this->has_any('group',ORM::factory('Group',array('name'=>'Registered Users'))->list_childgrps(TRUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the groups that an account belongs to
|
||||||
|
*/
|
||||||
|
public function groups() {
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
foreach ($this->group->where_active()->find_all() as $go)
|
||||||
|
foreach ($go->list_parentgrps(TRUE) as $cgo)
|
||||||
|
if (empty($result[$cgo->id]))
|
||||||
|
$result[$cgo->id] = $cgo;
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function log($message) {
|
||||||
|
// Log a message for this account
|
||||||
|
$alo = ORM::factory('Account_Log');
|
||||||
|
$alo->account_id = $this->id;
|
||||||
|
$alo->ip = Request::$client_ip;
|
||||||
|
$alo->details = $message;
|
||||||
|
$alo->save();
|
||||||
|
|
||||||
|
return $alo->saved();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAdmin() {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will extract the available methods for this account
|
||||||
|
* This is used both for menu options and method security
|
||||||
|
*/
|
||||||
|
public function methods() {
|
||||||
|
static $result = array();
|
||||||
|
|
||||||
|
// @todo We may want to optimise this with some session caching.
|
||||||
|
if ($result)
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
foreach ($this->groups() as $go)
|
||||||
|
foreach ($go->module_method->find_all() as $mmo)
|
||||||
|
if (empty($result[$mmo->id]))
|
||||||
|
$result[$mmo->id] = $mmo;
|
||||||
|
|
||||||
|
Sort::MAsort($result,'module->name,menu_display');
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an account name
|
||||||
|
*/
|
||||||
|
public function name() {
|
||||||
|
return trim(sprintf('%s %s',$this->first_name,$this->last_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for accounts matching a term
|
||||||
|
*/
|
||||||
|
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||||
|
$ao = Auth::instance()->get_user();
|
||||||
|
|
||||||
|
$this->clear();
|
||||||
|
$this->where_active();
|
||||||
|
|
||||||
|
// Build our where clause
|
||||||
|
// First Name, Last name
|
||||||
|
if (preg_match('/\ /',$term)) {
|
||||||
|
list($fn,$ln) = explode(' ',$term,2);
|
||||||
|
|
||||||
|
$this->where_open()
|
||||||
|
->where('first_name','like','%'.$fn.'%')
|
||||||
|
->and_where('last_name','like','%'.$ln.'%')
|
||||||
|
->where_close();
|
||||||
|
|
||||||
|
} elseif (is_numeric($term)) {
|
||||||
|
$this->where('id','like','%'.$term.'%');
|
||||||
|
|
||||||
|
} elseif (preg_match('/\@/',$term)) {
|
||||||
|
$this->where('email','like','%'.$term.'%');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$this->where_open()
|
||||||
|
->or_where('first_name','like','%'.$term.'%')
|
||||||
|
->or_where('last_name','like','%'.$term.'%')
|
||||||
|
->or_where('email','like','%'.$term.'%')
|
||||||
|
->where_close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restrict results to authorised accounts
|
||||||
|
// @todo
|
||||||
|
|
||||||
|
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
40
classes/lnApp/Model/Auth/UserDefault.php
Normal file
40
classes/lnApp/Model/Auth/UserDefault.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default ORM profile for Authentication Accounts
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Models
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_Model_Auth_UserDefault extends Model_Auth_User {
|
||||||
|
// Validation rules
|
||||||
|
public function rules() {
|
||||||
|
return array(
|
||||||
|
'email' => array(
|
||||||
|
array('not_empty'),
|
||||||
|
array('min_length', array(':value', 4)),
|
||||||
|
array('max_length', array(':value', 127)),
|
||||||
|
array('email'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complete our login
|
||||||
|
*
|
||||||
|
* For some database logins, we may not want to record the user last login
|
||||||
|
* details in the repository, so we just override that parent function
|
||||||
|
* here.
|
||||||
|
*
|
||||||
|
* We can also do some other post-login actions here.
|
||||||
|
*/
|
||||||
|
public function complete_login() {
|
||||||
|
return $this->log('Logged In');
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public function isAdmin();
|
||||||
|
}
|
||||||
|
?>
|
23
classes/lnApp/Model/Country.php
Normal file
23
classes/lnApp/Model/Country.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Country Model
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Models
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_Model_Country extends ORM {
|
||||||
|
protected $_sorting = array(
|
||||||
|
'name'=>'ASC',
|
||||||
|
);
|
||||||
|
|
||||||
|
protected $_form = array('id'=>'id','value'=>'name');
|
||||||
|
|
||||||
|
public static function icon() {
|
||||||
|
return HTML::image(sprintf('media/img/country/%s.png',strtolower($this->two_code)),array('alt'=>$this->currency->symbol));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
19
classes/lnApp/Model/Language.php
Normal file
19
classes/lnApp/Model/Language.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language Model
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Models
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_Model_Language extends ORM {
|
||||||
|
protected $_sorting = array(
|
||||||
|
'name'=>'ASC',
|
||||||
|
);
|
||||||
|
|
||||||
|
protected $_form = array('id'=>'id','value'=>'name');
|
||||||
|
}
|
||||||
|
?>
|
@ -33,7 +33,7 @@ abstract class lnApp_Site {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the site configured language
|
* Return the site configured id
|
||||||
*/
|
*/
|
||||||
public static function ID($format=FALSE) {
|
public static function ID($format=FALSE) {
|
||||||
return $format ? sprintf('%02s',Kohana::$config->load('config')->id) : Kohana::$config->load('config')->id;
|
return $format ? sprintf('%02s',Kohana::$config->load('config')->id) : Kohana::$config->load('config')->id;
|
||||||
@ -43,6 +43,19 @@ abstract class lnApp_Site {
|
|||||||
* Return the site configured language
|
* Return the site configured language
|
||||||
*/
|
*/
|
||||||
public static function Language() {
|
public static function Language() {
|
||||||
|
foreach (Request::factory()->accept_lang() as $k=>$v) {
|
||||||
|
if (strlen($k) == 2)
|
||||||
|
$k = sprintf('%s_%s',strtolower($k),strtoupper($k));
|
||||||
|
else {
|
||||||
|
list($k,$v) = preg_split('/[-_]/',$k,2);
|
||||||
|
$k = sprintf('%s_%s',strtolower($k),strtoupper($v));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($x=ORM::factory('Language',array('iso'=>$k)))
|
||||||
|
return $x;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @todo Return Default Language
|
||||||
return Kohana::$config->load('config')->language;
|
return Kohana::$config->load('config')->language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
classes/lnApp/StaticList/Title.php
Normal file
28
classes/lnApp/StaticList/Title.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is class renders Person Title responses and forms.
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_StaticList_Title extends StaticList {
|
||||||
|
protected function _table() {
|
||||||
|
return array(
|
||||||
|
'mr'=>_('Mr'),
|
||||||
|
'ms'=>_('Ms'),
|
||||||
|
'mrs'=>_('Mrs'),
|
||||||
|
'miss'=>_('Miss'),
|
||||||
|
'dr'=>_('Dr'),
|
||||||
|
'prof'=>_('Prof')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get($value) {
|
||||||
|
return self::factory()->_get($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -62,7 +62,7 @@ abstract class lnApp_URL extends Kohana_URL {
|
|||||||
case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'fa-globe');
|
case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'fa-globe');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'user': $result[$k] = array('name'=>array_key_exists('auth',Kohana::modules()) ? Auth::instance()->get_user()->name() : 'Guest','icon'=>'fa-user');
|
case 'user': $result[$k] = array('name'=>(array_key_exists('auth',Kohana::modules()) AND $x=Auth::instance()->get_user()) ? $x->name() : 'Guest','icon'=>'icon-user');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: $result[$k] = array('name'=>$k,'icon'=>'fa-question-sign');
|
default: $result[$k] = array('name'=>$k,'icon'=>'fa-question-sign');
|
||||||
|
17
config/auth.php
Normal file
17
config/auth.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration - Authentication
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Configuration
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'driver' => 'ORM',
|
||||||
|
'hash_method' => 'md5',
|
||||||
|
);
|
||||||
|
?>
|
@ -88,3 +88,111 @@ table .text-right {
|
|||||||
right: 0px;
|
right: 0px;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#nav {
|
||||||
|
margin-bottom: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .container > #main-nav {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
border-top: 1px solid #DDD;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .container > #main-nav > li {
|
||||||
|
position: relative;
|
||||||
|
top: -1px;
|
||||||
|
|
||||||
|
float: left;
|
||||||
|
|
||||||
|
padding: 0 40px 0 0;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
list-style: none;
|
||||||
|
|
||||||
|
border-top: 1px solid #DDD;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .container > #main-nav > li:last-child {
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .container > #main-nav > li > a {
|
||||||
|
position: relative;
|
||||||
|
top: -1px;
|
||||||
|
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
padding: 15px 5px 5px;
|
||||||
|
|
||||||
|
color: #999;
|
||||||
|
|
||||||
|
text-transform: uppercase;
|
||||||
|
|
||||||
|
border-top: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .container > #main-nav > li > a:hover,
|
||||||
|
#nav .container > #main-nav > li.dropdown.open > a {
|
||||||
|
color: #333;
|
||||||
|
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
border-top-color: #333;
|
||||||
|
border-top-width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .container > #main-nav > li.active a {
|
||||||
|
padding-top: 12px;
|
||||||
|
|
||||||
|
color: #222;
|
||||||
|
|
||||||
|
border-top-color: #F90;
|
||||||
|
border-top-width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .container > #main-nav > li > a > .caret {
|
||||||
|
position: relative;
|
||||||
|
top: -2px;
|
||||||
|
|
||||||
|
margin-left: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .dropdown-menu a:hover {
|
||||||
|
background-color: #F90;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .dropdown-menu > li > a {
|
||||||
|
padding: 6px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .dropdown-menu i {
|
||||||
|
margin-right: .5em;
|
||||||
|
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .dropdown-menu::before {
|
||||||
|
content: '';
|
||||||
|
display: inline-block;
|
||||||
|
border-left: 7px solid transparent;
|
||||||
|
border-right: 7px solid transparent;
|
||||||
|
border-bottom: 7px solid #CCC;
|
||||||
|
border-bottom-color: rgba(0, 0, 0, 0.2);
|
||||||
|
position: absolute;
|
||||||
|
top: -7px;
|
||||||
|
left: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav .dropdown-menu::after {
|
||||||
|
content: '';
|
||||||
|
display: inline-block;
|
||||||
|
border-left: 6px solid transparent;
|
||||||
|
border-right: 6px solid transparent;
|
||||||
|
border-bottom: 6px solid white;
|
||||||
|
position: absolute;
|
||||||
|
top: -6px;
|
||||||
|
left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
61
views/account/user/edit.php
Normal file
61
views/account/user/edit.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<fieldset>
|
||||||
|
<legend>Account Details</legend>
|
||||||
|
|
||||||
|
<?php echo Form::input('date_last',$o->date_last ? $o->display('date_last') : Site::date(time()),array('label'=>'Last Updated','class'=>'col-md-2','disabled')); ?>
|
||||||
|
|
||||||
|
<?php echo Form::input('email',$o->display('email'),array('label'=>'Email','class'=>'col-md-3','placeholder'=>'Email Address','type'=>'email','required','data-error'=>'Invalid EMAIL address')); ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label" for="Title">Name</label>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-1">
|
||||||
|
<?php echo Form::select('title',StaticList_Title::table(),$o->display('title'),array('class'=>'form-control','required','nocg'=>TRUE)); ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<?php echo Form::input('first_name',$o->display('first_name'),array('class'=>'form-control col-md-2','placeholder'=>'First Name','required','nocg'=>TRUE)); ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<?php echo Form::input('last_name',$o->display('last_name'),array('class'=>'form-control col-md-2','placeholder'=>'Last Name','required','nocg'=>TRUE)); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label" for="address1">Address</label>
|
||||||
|
<?php echo Form::input('address1',$o->display('address1'),array('class'=>'col-md-6','placeholder'=>'Address Line 1','required')); ?>
|
||||||
|
|
||||||
|
<label class="col-md-2 control-label" for="address2"></label>
|
||||||
|
<?php echo Form::input('address2',$o->display('address2'),array('class'=>'col-md-6','placeholder'=>'Address Line 2')); ?>
|
||||||
|
|
||||||
|
<label class="col-md-2 control-label" for="city"></label>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<?php echo Form::input('city',$o->display('city'),array('label'=>'City','placeholder'=>'City','required','nocg'=>TRUE)); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-1">
|
||||||
|
<?php echo Form::input('state',$o->display('state'),array('label'=>'','class'=>'input-mini','placeholder'=>'State','required','nocg'=>TRUE)); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-1">
|
||||||
|
<?php echo Form::input('zip',$o->display('zip'),array('label'=>'','class'=>'input-mini','placeholder'=>'Post Code','required','nocg'=>TRUE)); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label" for="address1">Country</label>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<?php echo Form::select('country_id',ORM::factory('Country')->list_select(),$o->country_id,array('class'=>'form-control','required','nocg'=>TRUE)); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php echo Form::hidden('language_id',Site::language()); ?>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-offset-1">
|
||||||
|
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||||
|
<button type="button" class="btn btn-default">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,10 +1,18 @@
|
|||||||
<?php foreach (URL::navbar() as $type => $details) :
|
<ul id="main-nav">
|
||||||
if ($x = Menu::items($type)) : ?>
|
<li class="active"><a href="<?php echo URL::site(''); ?>">Home</a></li>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
|
||||||
<li class="dropdown">
|
<?php if (class_exists('Company') AND $x=Company::instance()->faq()) : ?>
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa <?php echo Arr::get($details,'icon','fa-asterisk'); ?>"></i> <?php echo Arr::get($details,'name','?'); ?> <b class="caret"></b></a>
|
<li><a href="<?php echo $x; ?>">Faq</a></li>
|
||||||
<?php echo Menu::ul($type,$x,$type == 'user' ? array('logout'=>'Logout') : NULL); ?>
|
<?php endif ?>
|
||||||
</li>
|
|
||||||
|
<?php if (class_exists('Auth') AND Auth::instance()->logged_in()) : ?>
|
||||||
|
<li><a href="<?php echo URL::site('login'); ?>">Login</a></li>
|
||||||
|
<?php else : ?>
|
||||||
|
<li><a href="<?php echo URL::site('login'); ?>" data-toggle="modal" data-target="#modal-login">Login</a></li>
|
||||||
|
<li><a href="<?php echo URL::site('login/register'); ?>">Register</a></li>
|
||||||
|
<?php endif ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php endif;
|
|
||||||
endforeach ?>
|
<div class="modal hide fade" id="modal-login" role="dialog" aria-hidden="true">
|
||||||
|
<div class="modal-body"></div>
|
||||||
|
</div>
|
||||||
|
@ -31,49 +31,27 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php if (! empty($shownavbar)) : ?>
|
<?php if (! empty($shownavbar)) : ?>
|
||||||
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||||
|
<div class="navbar-inner">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><i class="icon-cog"></i> </a>
|
||||||
|
<a class="brand" href="<?php echo URL::site(); ?>"><?php echo Site::Appname(); ?><sup></sup></a>
|
||||||
|
</div> <!-- /container -->
|
||||||
|
</div> <!-- /navbar-inner -->
|
||||||
|
|
||||||
<div class="navbar-header">
|
</div> <!-- /nvarbar -->
|
||||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-top-collapse">
|
|
||||||
<span class="sr-only">Toggle navigation</span>
|
|
||||||
<i class="fa fa-cog"></i>
|
|
||||||
</button>
|
|
||||||
<a class="navbar-brand" href="<?php echo URL::site(); ?>"><?php echo Site::Appname(); ?></a>
|
|
||||||
</div> <!-- /navbar-header -->
|
|
||||||
|
|
||||||
<div class="collapse navbar-collapse navbar-top-collapse">
|
|
||||||
<?php echo $navbar; ?>
|
|
||||||
|
|
||||||
<?php if (class_exists('Controller_Search')) : ?>
|
|
||||||
<form class="navbar-form navbar-right" role="search">
|
|
||||||
<div class="navbar-search-addon form-group">
|
|
||||||
<i class="fa fa-search"></i>
|
|
||||||
<input type="text" class="form-control input-sm search-query" placeholder="Search">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<?php endif ?>
|
|
||||||
</div><!-- /.navbar-collapse -->
|
|
||||||
</div> <!-- /.container -->
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<div class="subnavbar">
|
<div class="subnavbar">
|
||||||
<div class="subnavbar-inner">
|
<div class="subnavbar-inner">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a href="javascript:;" class="subnav-toggle" data-toggle="collapse" data-target=".subnav-collapse"><span class="sr-only">Toggle navigation</span><i class="fa fa-reorder"></i></a>
|
<a class="btn-subnavbar collapsed" data-toggle="collapse" data-target=".subnav-collapse"><i class="icon-reorder"></i></a>
|
||||||
|
|
||||||
<div class="collapse subnav-collapse">
|
<div id="nav" class="clearfix">
|
||||||
<ul class="mainnav">
|
<div class="container">
|
||||||
<li><a href="<?php echo array_key_exists('auth',Kohana::modules()) ? URL::link('user','welcome',TRUE) : URL::site('welcome'); ?>"><i class="fa fa-home"></i><span>Home</span></a></li>
|
<?php echo $navbar; ?>
|
||||||
|
</div> <!-- /container -->
|
||||||
|
</div> <!-- /nav -->
|
||||||
|
|
||||||
<?php if (array_key_exists('auth',Kohana::modules()) AND ($ao = Auth::instance()->get_user()) AND $ao->isAdmin()) : ?>
|
|
||||||
<li><a href="<?php echo URL::link('admin','welcome',TRUE); ?>"><i class="fa fa-tasks"></i><span>Admin</span></a></li>
|
|
||||||
<?php endif ?>
|
|
||||||
<?php foreach (Menu::mainnav() as $name => $attributes) : ?>
|
|
||||||
<li><a href="<?php echo Arr::get($attributes,'url'); ?>"><i class="fa <?php echo Arr::get($attributes,'icon','fa-asterisk'); ?>"></i><span><?php echo $name; ?></span></a></li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
</div> <!-- /.subnav-collapse -->
|
|
||||||
</div> <!-- /container -->
|
</div> <!-- /container -->
|
||||||
</div> <!-- /subnavbar-inner -->
|
</div> <!-- /subnavbar-inner -->
|
||||||
</div> <!-- /subnavbar -->
|
</div> <!-- /subnavbar -->
|
||||||
@ -135,6 +113,7 @@
|
|||||||
echo HTML::script(Site::Protocol('cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js'));
|
echo HTML::script(Site::Protocol('cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo HTML::script('media/theme/bootstrap/js/bootstrap.validator.js');
|
||||||
echo HTML::script('media/js/typeahead.bundle.min.js');
|
echo HTML::script('media/js/typeahead.bundle.min.js');
|
||||||
echo HTML::script('media/js/search.js');
|
echo HTML::script('media/js/search.js');
|
||||||
echo HTML::script('media/js/custom.js');
|
echo HTML::script('media/js/custom.js');
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if (array_key_exists('auth',Kohana::modules()) AND Auth::instance()->logged_in()) : ?>
|
<?php if (array_key_exists('auth',Kohana::modules()) AND Auth::instance()->logged_in()) : ?>
|
||||||
<li><a href="<?php echo URL::site('login'); ?>">Customer Login</a></li>
|
<li><a href="<?php echo URL::site('login'); ?>">Login</a></li>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<li><a href="<?php echo URL::site('login'); ?>" data-toggle="modal" data-target="#modal-login">Customer Login</a></li>
|
<li><a href="<?php echo URL::site('login'); ?>" data-toggle="modal" data-target="#modal-login">Login</a></li>
|
||||||
<li><a href="<?php echo URL::site('login/register'); ?>">Register</a></li>
|
<li><a href="<?php echo URL::site('login/register'); ?>">Register</a></li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
Reference in New Issue
Block a user