Index: trunk/core/units/permissions/permissions_tag_processor.php =================================================================== diff -u -N -r5328 -r6093 --- trunk/core/units/permissions/permissions_tag_processor.php (.../permissions_tag_processor.php) (revision 5328) +++ trunk/core/units/permissions/permissions_tag_processor.php (.../permissions_tag_processor.php) (revision 6093) @@ -1,24 +1,24 @@ Application->recallObject('SectionsHelper'); $section_data =& $sections_helper->getSectionData($section_name); - + return array_search($params['perm_name'], $section_data['permissions']) !== false; } - + function HasAdvancedPermissions($params) { $section_name = $params['section_name']; - + $sections_helper =& $this->Application->recallObject('SectionsHelper'); $section_data =& $sections_helper->getSectionData($section_name); - + $ret = false; foreach ($section_data['permissions'] as $perm_name) { if (preg_match('/^advanced:(.*)/', $perm_name)) { @@ -28,53 +28,59 @@ } return $ret; } - + function PermissionValue($params) { $section_name = $params['section_name']; - + $sections_helper =& $this->Application->recallObject('SectionsHelper'); $section_data =& $sections_helper->getSectionData($section_name); $perm_name = $params['perm_name']; - + $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); if (!$permissions_helper->isOldPermission($section_name, $perm_name)) { $perm_name = $section_name.'.'.$perm_name; } - + return $permissions_helper->getPermissionValue($perm_name); } - + function LoadPermissions($params) { $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); $prefix_parts = explode('-', $this->Prefix, 2); $permissions_helper->LoadPermissions($this->Application->GetVar('g_id'), 0, 1); } - + function LevelIndicator($params) { return $params['level'] * $params['multiply']; } - + function PrintPermissions($params) { $category =& $this->Application->recallObject('c'); - + $group_id = $this->Application->GetVar('group_id'); $prefix = $this->Application->GetVar('item_prefix'); $module = $this->Application->findModule('Var', $prefix, 'Name'); - + $perm_live_table = $this->Application->getUnitOption('c-perm', 'TableName'); $perm_temp_table = $this->Application->GetTempName($perm_live_table); - - $categories = explode('|', substr($category->GetDBField('ParentPath'), 1, -1)); - if (count($categories) == 1) { + + if ($category->GetID() == 0) { + $categories = Array(0); + } + else { + $categories = explode('|', substr($category->GetDBField('ParentPath'), 1, -1)); + } + + if (count($categories) == 1 || $category->GetID() == 0) { // category located in root category ("Home") => then add it to path virtually array_unshift($categories, 0); } $this_cat = array_pop($categories); - + // get permission name + category position in parent path that has value set for that permission $case = 'MAX(CASE c.CategoryId'; foreach ($categories as $pos => $cat_id) { @@ -89,17 +95,17 @@ CategoryId IN ('.implode(',', $categories).') AND ModuleId = "'.$module.'" AND ( - (p.GroupId = '.$group_id.' AND p.Type = 0) + (p.GroupId = '.$group_id.' AND p.Type = 0) ) GROUP BY Perm'; $perm_positions = $this->Conn->GetCol($sql, 'Perm'); - + $pos_sql = ''; foreach ($perm_positions as $perm_name => $category_pos) { - $pos_sql .= '(#TABLE_PREFIX#.Permission = "'.$perm_name.'" AND #TABLE_PREFIX#.CatId = '.$categories[$category_pos].') OR '; + $pos_sql .= '(#TABLE_PREFIX#.Permission = "'.$perm_name.'" AND #TABLE_PREFIX#.CatId = '.$categories[$category_pos].') OR '; } $pos_sql = $pos_sql ? preg_replace('/(.*) OR $/', '\\1', $pos_sql) : '0'; - + // get all permissions list with iheritence status, inherited category id and permission value $sql = 'SELECT pc.PermissionName, pc.Description, @@ -111,13 +117,13 @@ IF(tmp_p.CatId = '.$category->GetID().', 0, 1) AS Inherited, IF(p.PermissionValue IS NOT NULL, p.PermissionValue, 0) AS InheritedValue FROM '.TABLE_PREFIX.'PermissionConfig pc - LEFT JOIN '.$perm_live_table.' p + LEFT JOIN '.$perm_live_table.' p ON (p.Permission = pc.PermissionName) AND ('.str_replace('#TABLE_PREFIX#', 'p', $pos_sql).') AND (p.GroupId = '.$group_id.') - LEFT JOIN '.$perm_temp_table.' tmp_p + LEFT JOIN '.$perm_temp_table.' tmp_p ON (tmp_p.Permission = pc.PermissionName) AND (tmp_p.CatId = '.$this_cat.') AND (tmp_p.GroupId = '.$group_id.') WHERE ModuleId = "'.$module.'"'; $permissions = $this->Conn->Query($sql); - + $ret = ''; $block_params = array_merge_recursive2( $this->prepareTagParams($params), Array('name' => $params['render_as'])); foreach ($permissions as $perm_record) { @@ -126,7 +132,7 @@ } return $ret; } - + /** * Print module tab for each module * @@ -143,7 +149,7 @@ } return $ret; } - + /** * Returns category name by ID * @@ -158,10 +164,11 @@ if ($category_id > 0) { $id_field = $this->Application->getUnitOption('c', 'IDField'); $table_name = $this->Application->getUnitOption('c', 'TableName'); - $sql = 'SELECT CachedNavbar + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $sql = 'SELECT '.$ml_formatter->LangFieldName('CachedNavbar').' FROM '.$table_name.' WHERE '.$id_field.' = '.$category_id; - $category_path = trim($this->CategoryPath( Array('cat_id' => 0) ).'>'.$this->Conn->GetOne($sql), '>'); + $category_path = trim($this->CategoryPath( Array('cat_id' => 0) ).' > '.str_replace('&|&', ' > ', $this->Conn->GetOne($sql)), ' > '); } else { $category_path = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') ); @@ -170,12 +177,12 @@ } return $category_path; } - + function PermInputName($params) { return $this->Prefix.'['.$this->Application->GetVar('group_id').']['.$this->Application->Parser->GetParam('PermissionName').']['.$params['sub_key'].']'; } - + } ?> \ No newline at end of file