More use of list_active(), setup ajax actions that are check to be ajax
This commit is contained in:
@@ -117,7 +117,7 @@ class Model_Account extends Model_Auth_UserDefault {
|
||||
|
||||
// @todo This shouldnt really be required
|
||||
if ($result < 0)
|
||||
$result = 0;
|
||||
throw new Kohana_Exception($result);
|
||||
|
||||
return $format ? Currency::display($result) : $result;
|
||||
}
|
||||
@@ -133,10 +133,6 @@ class Model_Account extends Model_Auth_UserDefault {
|
||||
return $alo->saved();
|
||||
}
|
||||
|
||||
private function _where_active() {
|
||||
return $this->where('status','=',TRUE);
|
||||
}
|
||||
|
||||
public function list_active() {
|
||||
return $this->_where_active()->order_by('company,last_name,first_name')->find_all();
|
||||
}
|
||||
@@ -158,10 +154,11 @@ class Model_Account extends Model_Auth_UserDefault {
|
||||
/**
|
||||
* Search for accounts matching a term
|
||||
*/
|
||||
public function list_autocomplete($term,$index='id') {
|
||||
public function list_autocomplete($term,$index='id',array $limit=array()) {
|
||||
$return = array();
|
||||
|
||||
$this->clear();
|
||||
$this->where_active();
|
||||
$value = 'name(TRUE)';
|
||||
|
||||
// Build our where clause
|
||||
@@ -183,13 +180,20 @@ class Model_Account extends Model_Auth_UserDefault {
|
||||
$value = 'email';
|
||||
|
||||
} else {
|
||||
$this->where('company','like','%'.$term.'%')
|
||||
$this->where_open()
|
||||
->where('company','like','%'.$term.'%')
|
||||
->or_where('first_name','like','%'.$term.'%')
|
||||
->or_where('last_name','like','%'.$term.'%')
|
||||
->or_where('email','like','%'.$term.'%');
|
||||
->or_where('email','like','%'.$term.'%')
|
||||
->where_close();
|
||||
}
|
||||
|
||||
foreach ($limit as $w) {
|
||||
list($k,$s,$v) = $w;
|
||||
|
||||
$this->and_where($k,$s,$v);
|
||||
}
|
||||
|
||||
// @todo This should limit the results so that users dont see other users services.
|
||||
foreach ($this->find_all() as $o)
|
||||
$return[$o->$index] = array(
|
||||
'value'=>$o->$index,
|
||||
|
@@ -47,7 +47,7 @@ class Model_Group extends Model_Auth_RoleDefault {
|
||||
if (! $this->loaded())
|
||||
return $return;
|
||||
|
||||
foreach (ORM::factory('group')->where('status','=',1)->and_where('parent_id','=',$this)->find_all() as $go) {
|
||||
foreach (ORM::factory('group')->where_active()->and_where('parent_id','=',$this)->find_all() as $go) {
|
||||
array_push($return,$go);
|
||||
|
||||
$return = array_merge($return,$go->list_childgrps());
|
||||
@@ -69,7 +69,7 @@ class Model_Group extends Model_Auth_RoleDefault {
|
||||
if (! $this->loaded())
|
||||
return $return;
|
||||
|
||||
foreach (ORM::factory('group')->where('status','=',1)->and_where('id','=',$this->parent_id)->find_all() as $go) {
|
||||
foreach (ORM::factory('group')->where_active()->and_where('id','=',$this->parent_id)->find_all() as $go) {
|
||||
array_push($return,$go);
|
||||
|
||||
$return = array_merge($return,$go->list_parentgrps());
|
||||
|
Reference in New Issue
Block a user