Index: trunk/core/kernel/application.php =================================================================== diff -u -r1674 -r1677 --- trunk/core/kernel/application.php (.../application.php) (revision 1674) +++ trunk/core/kernel/application.php (.../application.php) (revision 1677) @@ -165,8 +165,6 @@ if( !$this->GetVar('m_theme') ) $this->SetVar('m_theme', $this->GetDefaultThemeId() ); $this->SetVar('theme.current_id', $this->GetVar('m_theme') ); - if ( $this->GetVar('m_cat_id') === false ) $this->SetVar('m_cat_id', 3); //need to rewrite - if( !$this->RecallVar('UserGroups') ) { $this->StoreVar('UserGroups', $this->ConfigValue('User_GuestGroup')); @@ -1275,17 +1273,24 @@ function CheckPermission($name, $cat_id = null) { - if(!$cat_id) + if( !isset($cat_id) ) { $cat_id = $this->GetVar('m_cat_id'); } - $sql = 'SELECT ParentPath FROM '.$this->getUnitOption('c', 'TableName').' - WHERE CategoryId = '.$cat_id; - $cat_hierarchy = $this->DB->GetOne($sql); - $cat_hierarchy = explode('|', $cat_hierarchy); - array_shift($cat_hierarchy); - array_pop($cat_hierarchy); - $cat_hierarchy = array_reverse($cat_hierarchy); + if( $cat_id == 0 ) + { + $cat_hierarchy = Array(0); + } + else + { + $sql = 'SELECT ParentPath FROM '.$this->getUnitOption('c', 'TableName').' WHERE CategoryId = '.$cat_id; + $cat_hierarchy = $this->DB->GetOne($sql); + $cat_hierarchy = explode('|', $cat_hierarchy); + array_shift($cat_hierarchy); + array_pop($cat_hierarchy); + $cat_hierarchy = array_reverse($cat_hierarchy); + array_push($cat_hierarchy, 0); + } $groups = $this->RecallVar('UserGroups'); @@ -1296,7 +1301,7 @@ AND CatId = '.$category_id.' AND GroupId IN ('.$groups.')'; $res = $this->DB->GetOne($sql); - if( $res !== false ) + if($res !== false) { return $res; } Index: trunk/kernel/units/users/users_event_handler.php =================================================================== diff -u -r1609 -r1677 --- trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 1609) +++ trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 1677) @@ -33,16 +33,22 @@ $object->Load($user_id); if( $object->GetDBField('Status') == STATUS_ACTIVE ) { - $session =& $this->Application->recallObject('Session'); - $session->SetField('PortalUserId', $user_id); - $this->Application->SetVar('u_id', $user_id); - $this->Application->StoreVar('user_id', $user_id); - $sql = 'SELECT DISTINCT GroupId FROM '.TABLE_PREFIX.'UserGroup WHERE PortalUserId = '.$user_id; - if( $groups = $this->Conn->GetCol($sql) ) + if( $groups = $this->Conn->GetCol($sql) ) $this->Application->StoreVar( 'UserGroups', implode(',', $groups) ); + + if( $this->Application->CheckPermission('LOGIN',0) ) { - $this->Application->StoreVar( 'UserGroups', implode(',', $groups) ); + $session =& $this->Application->recallObject('Session'); + $session->SetField('PortalUserId', $user_id); + $this->Application->SetVar('u_id', $user_id); + $this->Application->StoreVar('user_id', $user_id); } + else + { + $object->Load(-2); + $object->SetError('ValidateLogin', 'no_permission', 'lu_no_permissions'); + $event->status = erFAIL; + } $next_template = $this->Application->GetVar('next_template'); if($next_template) $event->redirect = $next_template; Index: trunk/core/units/users/users_event_handler.php =================================================================== diff -u -r1609 -r1677 --- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 1609) +++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 1677) @@ -33,16 +33,22 @@ $object->Load($user_id); if( $object->GetDBField('Status') == STATUS_ACTIVE ) { - $session =& $this->Application->recallObject('Session'); - $session->SetField('PortalUserId', $user_id); - $this->Application->SetVar('u_id', $user_id); - $this->Application->StoreVar('user_id', $user_id); - $sql = 'SELECT DISTINCT GroupId FROM '.TABLE_PREFIX.'UserGroup WHERE PortalUserId = '.$user_id; - if( $groups = $this->Conn->GetCol($sql) ) + if( $groups = $this->Conn->GetCol($sql) ) $this->Application->StoreVar( 'UserGroups', implode(',', $groups) ); + + if( $this->Application->CheckPermission('LOGIN',0) ) { - $this->Application->StoreVar( 'UserGroups', implode(',', $groups) ); + $session =& $this->Application->recallObject('Session'); + $session->SetField('PortalUserId', $user_id); + $this->Application->SetVar('u_id', $user_id); + $this->Application->StoreVar('user_id', $user_id); } + else + { + $object->Load(-2); + $object->SetError('ValidateLogin', 'no_permission', 'lu_no_permissions'); + $event->status = erFAIL; + } $next_template = $this->Application->GetVar('next_template'); if($next_template) $event->redirect = $next_template; Index: trunk/core/kernel/processors/main_processor.php =================================================================== diff -u -r1662 -r1677 --- trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 1662) +++ trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 1677) @@ -708,6 +708,13 @@ $name = $this->SelectParam($params,'name,const'); return $this->Application->isDebugMode() && dbg_ConstOn($name); } + + function SetDefaultCategory($params) + { + $module_name = $params['module']; + $module =& $this->Application->recallObject('mod.'.$module_name); + $this->Application->SetVar('m_cat_id', $module->GetDBField('RootCat') ); + } /* function Login($params)