2011-09-27 11:22:13 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides Admin Account management
|
|
|
|
*
|
|
|
|
* @package lnApp
|
|
|
|
* @subpackage Page/Account
|
|
|
|
* @category Controllers
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 Deon George
|
|
|
|
* @license http://dev.leenooks.net/license.html
|
|
|
|
*/
|
|
|
|
class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
|
|
|
|
protected $secure_actions = array(
|
2011-10-14 05:44:12 +00:00
|
|
|
'autocomplete'=>FALSE, // @todo To Change
|
2011-09-27 11:22:13 +00:00
|
|
|
'listlog'=>TRUE,
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a list of account logins
|
|
|
|
*/
|
|
|
|
public function action_listlog() {
|
|
|
|
Block::add(array(
|
|
|
|
'title'=>_('Account Login Log'),
|
|
|
|
'body'=>Table::display(
|
|
|
|
ORM::factory('account_log')->order_by('id','DESC')->find_all(),
|
|
|
|
25,
|
|
|
|
array(
|
2011-10-13 06:53:43 +00:00
|
|
|
'id'=>array('label'=>'ID'),
|
2011-09-27 11:22:13 +00:00
|
|
|
'date_orig'=>array('label'=>'Date'),
|
|
|
|
'account->name()'=>array('label'=>'Account'),
|
|
|
|
'ip'=>array('label'=>'IP Address'),
|
|
|
|
'details'=>array('label'=>'Details'),
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'page'=>TRUE,
|
|
|
|
)),
|
|
|
|
));
|
|
|
|
}
|
2011-10-14 05:44:12 +00:00
|
|
|
|
|
|
|
public function action_autocomplete() {
|
|
|
|
$return = array();
|
|
|
|
|
|
|
|
$a = ORM::factory('account')->where('status','=',1);
|
|
|
|
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
|
|
|
|
$t = $_REQUEST['term'];
|
|
|
|
|
|
|
|
// @todo - Implement different search criteria, eg: @ by email, space for first/last, etc
|
|
|
|
if (FALSE) {
|
|
|
|
|
|
|
|
// All search
|
|
|
|
} else {
|
|
|
|
$a = $a
|
|
|
|
->where_open()
|
|
|
|
->where('first_name','like','%'.$t.'%')
|
|
|
|
->or_where('last_name','like','%'.$t.'%')
|
|
|
|
->or_where('company','like','%'.$t.'%')
|
|
|
|
->or_where('email','like','%'.$t.'%')
|
|
|
|
->where_close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// @todo The results should be limited so that users dont see what they shouldnt.
|
|
|
|
foreach ($a->find_all() as $ao)
|
|
|
|
array_push($return,array(
|
|
|
|
'id'=>$ao->id,
|
|
|
|
'label'=>sprintf('%s (%s)',$ao->name(),$ao->email),
|
|
|
|
'value'=>$ao->id,
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->auto_render = FALSE;
|
|
|
|
$this->response->headers('Content-Type','application/json');
|
|
|
|
$this->response->body(json_encode($return));
|
|
|
|
}
|
2011-09-27 11:22:13 +00:00
|
|
|
}
|
|
|
|
?>
|