Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/permissions/permissions_tag_processor.php
Show All 14 Lines | |||||
defined('FULL_PATH') or die('restricted access!'); | defined('FULL_PATH') or die('restricted access!'); | ||||
class PermissionsTagProcessor extends kDBTagProcessor { | class PermissionsTagProcessor extends kDBTagProcessor { | ||||
function HasPermission($params) | function HasPermission($params) | ||||
{ | { | ||||
$section_name = $params['section_name']; | $section_name = $params['section_name']; | ||||
/** @var kSectionsHelper $sections_helper */ | |||||
$sections_helper = $this->Application->recallObject('SectionsHelper'); | $sections_helper = $this->Application->recallObject('SectionsHelper'); | ||||
/* @var $sections_helper kSectionsHelper */ | |||||
$section_data =& $sections_helper->getSectionData($section_name); | $section_data =& $sections_helper->getSectionData($section_name); | ||||
return array_search($params['perm_name'], $section_data['permissions']) !== false; | return array_search($params['perm_name'], $section_data['permissions']) !== false; | ||||
} | } | ||||
function HasAdvancedPermissions($params) | function HasAdvancedPermissions($params) | ||||
{ | { | ||||
$section_name = $params['section_name']; | $section_name = $params['section_name']; | ||||
/** @var kSectionsHelper $sections_helper */ | |||||
$sections_helper = $this->Application->recallObject('SectionsHelper'); | $sections_helper = $this->Application->recallObject('SectionsHelper'); | ||||
/* @var $sections_helper kSectionsHelper */ | |||||
$section_data =& $sections_helper->getSectionData($section_name); | $section_data =& $sections_helper->getSectionData($section_name); | ||||
$ret = false; | $ret = false; | ||||
foreach ($section_data['permissions'] as $perm_name) { | foreach ($section_data['permissions'] as $perm_name) { | ||||
if (preg_match('/^advanced:(.*)/', $perm_name)) { | if (preg_match('/^advanced:(.*)/', $perm_name)) { | ||||
$ret = true; | $ret = true; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
return $ret; | return $ret; | ||||
} | } | ||||
function PermissionValue($params) | function PermissionValue($params) | ||||
{ | { | ||||
$section_name = $params['section_name']; | $section_name = $params['section_name']; | ||||
$perm_name = $params['perm_name']; | $perm_name = $params['perm_name']; | ||||
/** @var kSectionsHelper $sections_helper */ | |||||
$sections_helper = $this->Application->recallObject('SectionsHelper'); | $sections_helper = $this->Application->recallObject('SectionsHelper'); | ||||
/* @var $sections_helper kSectionsHelper */ | |||||
$section_name = $sections_helper->getPermSection($section_name); | $section_name = $sections_helper->getPermSection($section_name); | ||||
/** @var kPermissionsHelper $permissions_helper */ | |||||
$permissions_helper = $this->Application->recallObject('PermissionsHelper'); | $permissions_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $permissions_helper kPermissionsHelper */ | |||||
if (!$permissions_helper->isOldPermission($section_name, $perm_name)) { | if (!$permissions_helper->isOldPermission($section_name, $perm_name)) { | ||||
$perm_name = $section_name.'.'.$perm_name; | $perm_name = $section_name.'.'.$perm_name; | ||||
} | } | ||||
return $permissions_helper->getPermissionValue($perm_name); | return $permissions_helper->getPermissionValue($perm_name); | ||||
} | } | ||||
function LoadPermissions($params) | function LoadPermissions($params) | ||||
{ | { | ||||
$permissions_helper = $this->Application->recallObject('PermissionsHelper'); | $permissions_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
$prefix_parts = explode('-', $this->Prefix, 2); | $prefix_parts = explode('-', $this->Prefix, 2); | ||||
/* @var $permissions_helper kPermissionsHelper */ | /** @var kPermissionsHelper $permissions_helper */ | ||||
$permissions_helper->LoadPermissions($this->Application->GetVar('g_id'), 0, 1, 'g'); | $permissions_helper->LoadPermissions($this->Application->GetVar('g_id'), 0, 1, 'g'); | ||||
} | } | ||||
function LevelIndicator($params) | function LevelIndicator($params) | ||||
{ | { | ||||
return $params['level'] * $params['multiply']; | return $params['level'] * $params['multiply']; | ||||
} | } | ||||
function PrintPermissions($params) | function PrintPermissions($params) | ||||
{ | { | ||||
/** @var kDBItem $category */ | |||||
$category = $this->Application->recallObject('c'); | $category = $this->Application->recallObject('c'); | ||||
/* @var $category kDBItem */ | |||||
$group_id = $this->Application->GetVar('group_id'); | $group_id = $this->Application->GetVar('group_id'); | ||||
$prefix = $this->Application->GetVar('item_prefix'); | $prefix = $this->Application->GetVar('item_prefix'); | ||||
$module = $this->Application->findModule('Var', $prefix, 'Name'); | $module = $this->Application->findModule('Var', $prefix, 'Name'); | ||||
$perm_live_table = $this->Application->getUnitOption('c-perm', 'TableName'); | $perm_live_table = $this->Application->getUnitOption('c-perm', 'TableName'); | ||||
$perm_temp_table = $this->Application->GetTempName($perm_live_table, 'prefix:'.$this->Prefix); | $perm_temp_table = $this->Application->GetTempName($perm_live_table, 'prefix:'.$this->Prefix); | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | |||||
$category_path = $this->Application->getCache($cache_key); | $category_path = $this->Application->getCache($cache_key); | ||||
if ( $category_path === false ) { | if ( $category_path === false ) { | ||||
// not cached | // not cached | ||||
if ( $category_id > 0 ) { | if ( $category_id > 0 ) { | ||||
$id_field = $this->Application->getUnitOption('c', 'IDField'); | $id_field = $this->Application->getUnitOption('c', 'IDField'); | ||||
$table_name = $this->Application->getUnitOption('c', 'TableName'); | $table_name = $this->Application->getUnitOption('c', 'TableName'); | ||||
/** @var kMultiLanguage $ml_formatter */ | |||||
$ml_formatter = $this->Application->recallObject('kMultiLanguage'); | $ml_formatter = $this->Application->recallObject('kMultiLanguage'); | ||||
/* @var $ml_formatter kMultiLanguage */ | |||||
$sql = 'SELECT ' . $ml_formatter->LangFieldName('CachedNavbar') . ' | $sql = 'SELECT ' . $ml_formatter->LangFieldName('CachedNavbar') . ' | ||||
FROM ' . $table_name . ' | FROM ' . $table_name . ' | ||||
WHERE ' . $id_field . ' = ' . $category_id; | WHERE ' . $id_field . ' = ' . $category_id; | ||||
$cached_navbar = preg_replace('/^Content(&\|&){0,1}/i', '', $this->Conn->GetOne($sql)); | $cached_navbar = preg_replace('/^Content(&\|&){0,1}/i', '', $this->Conn->GetOne($sql)); | ||||
$category_path = trim($this->CategoryPath(Array ('cat_id' => 0)) . ' > ' . str_replace('&|&', ' > ', $cached_navbar), ' > '); | $category_path = trim($this->CategoryPath(Array ('cat_id' => 0)) . ' > ' . str_replace('&|&', ' > ', $cached_navbar), ' > '); | ||||
} | } | ||||
else { | else { | ||||
Show All 15 Lines |