Misc many fixes

This commit is contained in:
Deon George
2011-09-17 20:45:08 +10:00
parent 52074d239b
commit 7180e01dcf
18 changed files with 162 additions and 55 deletions

View File

@@ -35,8 +35,8 @@ class Auth_OSB extends Auth_ORM {
if (! empty($role)) {
// Get the module details
$module = ORM::factory('module',array('name'=>Request::current()->controller()));
if (! $module->loaded() OR ! $module->status) {
$mo = ORM::factory('module',array('name'=>Request::current()->controller()));
if (! $mo->loaded() OR ! $mo->status) {
SystemMessage::add(array(
'title'=>'Module is not defined or active in the Database',
'type'=>'warning',
@@ -50,21 +50,21 @@ class Auth_OSB extends Auth_ORM {
$method_name = Request::current()->action();
// Get the method number
$method = ORM::factory('module_method',array('module_id'=>$module->id,'name'=>$method_name));
if (! $method->loaded()) {
$mmo = ORM::factory('module_method',array('module_id'=>$mo->id,'name'=>$method_name));
if (! $mmo->loaded()) {
SystemMessage::add(array(
'title'=>'Method is not defined or active in the Database',
'type'=>'warning',
'body'=>sprintf('Method not defined: %s for %s',Request::current()->action(),$module->name),
'body'=>sprintf('Method not defined: %s for %s',Request::current()->action(),$mo->name),
));
} else {
// If the role has the authorisation to run the method
$group_method = ORM::factory('group_method')
->where('method_id','=',$method->id);
$gmo = ORM::factory('group_method')
->where('method_id','=',$mmo->id);
$roles = '';
foreach ($group_method->find_all() as $gm) {
foreach ($gmo->find_all() as $gm) {
$roles .= ($roles ? '|' : '').$gm->group->name;
$ro = ORM::factory('group', array('name' => $gm->group->name));
@@ -82,7 +82,7 @@ class Auth_OSB extends Auth_ORM {
SystemMessage::add(array(
'title'=>'User is not authorised in Database',
'type'=>'debug',
'body'=>sprintf('Role(s) checked: %s<br/>User: %s</br>Module: %s<br/>Method: %s',$roles,$user->username,$module->name,$method->name),
'body'=>sprintf('Role(s) checked: %s<br/>User: %s</br>Module: %s<br/>Method: %s',$roles,$user->username,$mo->name,$mmo->name),
));
}
}
@@ -199,7 +199,7 @@ class Auth_OSB extends Auth_ORM {
}
// If the passwords match, perform a login
if ($user->has('group', ORM::factory('group', array('name' => 'Registered Users'))) AND $user->password === $password)
if ($user->status AND $user->has_any('group',ORM::factory('group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password)
{
if ($remember === TRUE)
{

View File

@@ -152,6 +152,7 @@ function CORE_database_search($VAR,$construct,$type) {
# Get any static vars to search
$join_list = '';
$pre = AGILE_DB_PREFIX;
/*
if (! empty($VAR['static_relation']) && count($VAR['static_relation']>0)) {
while (list($idx,$value) = each($VAR['static_relation'])) {
if ($value != '') {
@@ -168,7 +169,6 @@ function CORE_database_search($VAR,$construct,$type) {
}
}
/*
# standard where list
$q .= $join_list . $where_list ." ".AGILE_DB_PREFIX."account.site_id = " . $db->qstr(DEFAULT_SITE);

View File

@@ -765,6 +765,7 @@ return false;
####################################################################
### Get all the associated STATIC RELATION records
return false;
$sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'static_relation WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
module_id = ' . $db->qstr($module_id) .' ORDER BY sort_order';
@@ -1031,6 +1032,7 @@ return false;
$module_id = $result->fields['id'];
return false;
####################################################################
### Get all the associated STATIC RELATION records
@@ -1197,6 +1199,7 @@ return false;
$module_id = $result->fields['id'];
return false;
####################################################################
### Get all the associated STATIC RELATION records

View File

@@ -25,13 +25,14 @@ class Email_Template {
throw new Kohana_Exception('Email template :template not defined in DB',array(':template'=>$template));
if (is_null($language_id))
$language_id=$this->default_lang;
$language_id = $this->default_lang;
$this->etto = $this->template->email_template_translate->where('language_id','=',$language_id)->find();
if (! $this->etto->loaded() AND
($this->etto = $this->template->email_template_translate->where('language_id','=',$this->default_lang)->find()) AND ! $this->etto->loaded())
// @todo Change this to log/email the admin
return;
throw new Kohana_Exception('No template (:template) found for user language (:language_id) or default language (:default_lang)',
array(':template'=>$this->template->name,':language_id'=>$language_id,':default_lang'=>$this->default_lang));
}
@@ -110,21 +111,26 @@ class Email_Template {
->setFrom(Kohana::config('config.email_from'));
foreach ($this->components as $component) {
$s = $this->etto->resolve($this->email_data['variables'],$component);
if ($this->etto->loaded()) {
$s = $this->etto->resolve($this->email_data['variables'],$component);
switch ($component) {
case 'message_html':
$sm->setBody($s,'text/html');
break;
case 'message_text':
$sm->setBody($s,'text/plain');
break;
case 'subject':
$sm->setSubject($s);
break;
switch ($component) {
case 'message_html':
$sm->setBody($s,'text/html');
break;
case 'message_text':
$sm->setBody($s,'text/plain');
break;
case 'subject':
$sm->setSubject($s);
break;
default:
throw new Kohana_Exception('Component :component has not been configured in :method',array(':component'=>$component,':method'=>__METHOD__));
default:
throw new Kohana_Exception('Component :component has not been configured in :method',array(':component'=>$component,':method'=>__METHOD__));
}
} else {
$sm->setSubject(_('Email from').' '.Config::sitename());
$sm->setBody(print_r($this->email_data['variables'],TRUE),'text/plain');
}
}

View File

@@ -35,5 +35,23 @@ class Model_Group extends Model_Auth_RoleDefault {
array('StaticList_YesNo::display',array(':value')),
),
);
public function list_childgrps($incParent=FALSE) {
$return = array();
if (! $this->loaded())
return $return;
foreach (ORM::factory('group')->where('status','=',1)->and_where('parent_id','=',$this)->find_all() as $go) {
array_push($return,$go);
$return = array_merge($return,$go->list_childgrps());
}
if ($incParent)
array_push($return,$this);
return $return;
}
}
?>

View File

@@ -1,7 +1,7 @@
<table width="100%" border="0">
<?php foreach ($results as $value) {?>
<?php foreach ($results as $value) { ?>
<tr>
<td class="menu"><a href="<?echo URL::site('product/category/'.$value->id);?>"><?php echo $value->name?></a></td>
<td class="menu"><a href="<?php echo URL::site('product/category/'.$value->id); ?>"><?php echo $value->name; ?></a></td>
</tr>
<?}?>
<?php } ?>
</table>

View File

@@ -56,10 +56,11 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
*/
public function action_listbycheckout() {
// @todo need to add the DB prefix here
// @todo need to remove the explicit references to the group_id
$services = DB::query(Database::SELECT,'
SELECT c.id AS cid,c.name as checkout_plugin_name,s.id AS sid,a.company,a.first_name,a.last_name,a.id as aid
FROM ab_service s LEFT JOIN ab_account_billing ab ON (s.account_billing_id=ab.id) LEFT JOIN ab_checkout c ON (ab.checkout_plugin_id=c.id),ab_account a, ab_account_group ag
WHERE s.active=1 AND s.price > 0 AND s.account_id=a.id AND a.id=ag.account_id AND ((s.account_billing_id IS NOT NULL AND ag.group_id IS NOT NULL) OR (a.id=ag.account_id and ag.group_id=1003))
WHERE s.active=1 AND s.price > 0 AND s.account_id=a.id AND a.id=ag.account_id AND ((s.account_billing_id IS NOT NULL AND ag.group_id!=2 ) OR (a.id=ag.account_id and ag.group_id=1003))
ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
')
->execute();

View File

@@ -27,7 +27,7 @@ class Controller_User_Statement extends Controller_TemplateDefault_User {
$ta[$i]['payment'] = $o;
}
foreach ($this->ao->invoice->find_all() as $o) {
foreach ($this->ao->invoice->where('status','!=',0)->find_all() as $o) {
$i = count($ta);
$ta[$i]['time'] = $o->date_orig;
$ta[$i]['invoice'] = $o;
@@ -76,7 +76,7 @@ class Controller_User_Statement extends Controller_TemplateDefault_User {
$output .= View::factory('statement/user/show_foot');
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Transaactions For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'title'=>sprintf('%s: %s - %s',_('Transactions For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>$output,
));
}

View File

@@ -1,8 +1,8 @@
<!-- @todo Move this back into the controller, so that we only have HTML views -->
<table width="100%" border="0">
<?php foreach ($results as $value) {?>
<?php foreach ($results as $value) { ?>
<tr>
<td class="menu"><a href="<?echo URL::site(Request::current()->uri(array('action'=>'view','id'=>$value->id)));?>"><?php echo $value->name?></a></td>
<td class="menu"><a href="<?php echo URL::site(Request::current()->uri(array('action'=>'view','id'=>$value->id))); ?>"><?php echo $value->name; ?></a></td>
</tr>
<?}?>
<?php } ?>
</table>