Index: trunk/core/units/groups/groups_config.php =================================================================== diff -u -r4603 -r4607 --- trunk/core/units/groups/groups_config.php (.../groups_config.php) (revision 4603) +++ trunk/core/units/groups/groups_config.php (.../groups_config.php) (revision 4607) @@ -47,7 +47,7 @@ 'icon' => 'usergroups', 'label' => 'la_tab_User_Groups', 'url' => Array('t' => 'groups/groups_list', 'pass' => 'm'), - 'permissions' => Array('view', 'edit', 'delete', 'advanced:send_email'), + 'permissions' => Array('view', 'add', 'edit', 'delete', 'advanced:send_email'), 'priority' => 2, 'type' => stTREE, ), @@ -67,7 +67,7 @@ ) ), -// 'SubItems' => Array('g-ug'), + 'SubItems' => Array('g-perm', /*'g-ug'*/), 'CalculatedFields' => Array( 'total' => Array( 'UserCount' => 'COUNT(ug.PortalUserId)', Index: trunk/core/units/themes/themes_config.php =================================================================== diff -u -r4457 -r4607 --- trunk/core/units/themes/themes_config.php (.../themes_config.php) (revision 4457) +++ trunk/core/units/themes/themes_config.php (.../themes_config.php) (revision 4607) @@ -30,7 +30,7 @@ 'icon' => 'conf_themes', 'label' => 'la_tab_Themes', 'url' => Array('index_file' => 'config/config_theme.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit', 'delete'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 2, 'type' => stTREE, ), Index: trunk/core/units/categories/categories_config.php =================================================================== diff -u -r4582 -r4607 --- trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 4582) +++ trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 4607) @@ -98,7 +98,7 @@ 'icon' => 'cat_settings', 'label' => 'la_tab_Settings', 'url' => Array('index_file' => 'config/edit_config.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 4, 'type' => stTREE, ), @@ -108,7 +108,7 @@ 'icon' => 'settings_search', 'label' => 'la_tab_ConfigSearch', 'url' => Array('t' => 'config/config_search', 'index_file' => 'index4.php', 'module_key' => 'category', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 5, 'type' => stTREE, ), @@ -128,7 +128,7 @@ 'icon' => 'settings_custom', 'label' => 'la_tab_ConfigCustom', 'url' => Array('t' => 'custom_fields/custom_fields_list', 'index_file' => 'index4.php', 'cf_type' => 1, 'pass' => 'm,cf'), - 'permissions' => Array('view', 'edit', 'delete'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 7, 'type' => stTREE, ), @@ -144,7 +144,7 @@ FROM %1$s LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'), - 'SubItems' => Array('c-cdata'), + 'SubItems' => Array('c-cdata', 'c-perm'), 'ListSortings' => Array( '' => Array( Index: trunk/core/units/admin/admin_config.php =================================================================== diff -u -r4577 -r4607 --- trunk/core/units/admin/admin_config.php (.../admin_config.php) (revision 4577) +++ trunk/core/units/admin/admin_config.php (.../admin_config.php) (revision 4607) @@ -24,7 +24,7 @@ 'icon' => 'site', 'label' => $this->Application->ConfigValue('Site_Name'), 'url' => Array('t' => 'sections_list', 'index_file' => 'index4.php', 'pass' => 'm', 'no_amp' => 1), - 'permissions' => Array('view'), + 'permissions' => Array('view', 'advanced:admin', 'advanced:login'), 'priority' => 0, 'type' => stTREE, ), @@ -127,7 +127,7 @@ 'icon' => 'modules', 'label' => 'la_title_Module_Status', 'url' => Array('t' => 'modules/modules_list', 'index_file' => 'index4.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 1, 'type' => stTREE, ), @@ -137,7 +137,7 @@ 'icon' => 'modules', 'label' => 'la_title_Add_Module', 'url' => Array('index_file' => 'modules/addmodule.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 2, 'type' => stTREE, ), Index: trunk/kernel/units/groups/groups_config.php =================================================================== diff -u -r4603 -r4607 --- trunk/kernel/units/groups/groups_config.php (.../groups_config.php) (revision 4603) +++ trunk/kernel/units/groups/groups_config.php (.../groups_config.php) (revision 4607) @@ -47,7 +47,7 @@ 'icon' => 'usergroups', 'label' => 'la_tab_User_Groups', 'url' => Array('t' => 'groups/groups_list', 'pass' => 'm'), - 'permissions' => Array('view', 'edit', 'delete', 'advanced:send_email'), + 'permissions' => Array('view', 'add', 'edit', 'delete', 'advanced:send_email'), 'priority' => 2, 'type' => stTREE, ), @@ -67,7 +67,7 @@ ) ), -// 'SubItems' => Array('g-ug'), + 'SubItems' => Array('g-perm', /*'g-ug'*/), 'CalculatedFields' => Array( 'total' => Array( 'UserCount' => 'COUNT(ug.PortalUserId)', Index: trunk/kernel/units/categories/categories_config.php =================================================================== diff -u -r4582 -r4607 --- trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 4582) +++ trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 4607) @@ -98,7 +98,7 @@ 'icon' => 'cat_settings', 'label' => 'la_tab_Settings', 'url' => Array('index_file' => 'config/edit_config.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 4, 'type' => stTREE, ), @@ -108,7 +108,7 @@ 'icon' => 'settings_search', 'label' => 'la_tab_ConfigSearch', 'url' => Array('t' => 'config/config_search', 'index_file' => 'index4.php', 'module_key' => 'category', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 5, 'type' => stTREE, ), @@ -128,7 +128,7 @@ 'icon' => 'settings_custom', 'label' => 'la_tab_ConfigCustom', 'url' => Array('t' => 'custom_fields/custom_fields_list', 'index_file' => 'index4.php', 'cf_type' => 1, 'pass' => 'm,cf'), - 'permissions' => Array('view', 'edit', 'delete'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 7, 'type' => stTREE, ), @@ -144,7 +144,7 @@ FROM %1$s LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'), - 'SubItems' => Array('c-cdata'), + 'SubItems' => Array('c-cdata', 'c-perm'), 'ListSortings' => Array( '' => Array( Index: trunk/kernel/units/themes/themes_config.php =================================================================== diff -u -r4457 -r4607 --- trunk/kernel/units/themes/themes_config.php (.../themes_config.php) (revision 4457) +++ trunk/kernel/units/themes/themes_config.php (.../themes_config.php) (revision 4607) @@ -30,7 +30,7 @@ 'icon' => 'conf_themes', 'label' => 'la_tab_Themes', 'url' => Array('index_file' => 'config/config_theme.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit', 'delete'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 2, 'type' => stTREE, ), Index: trunk/kernel/units/admin/admin_config.php =================================================================== diff -u -r4577 -r4607 --- trunk/kernel/units/admin/admin_config.php (.../admin_config.php) (revision 4577) +++ trunk/kernel/units/admin/admin_config.php (.../admin_config.php) (revision 4607) @@ -24,7 +24,7 @@ 'icon' => 'site', 'label' => $this->Application->ConfigValue('Site_Name'), 'url' => Array('t' => 'sections_list', 'index_file' => 'index4.php', 'pass' => 'm', 'no_amp' => 1), - 'permissions' => Array('view'), + 'permissions' => Array('view', 'advanced:admin', 'advanced:login'), 'priority' => 0, 'type' => stTREE, ), @@ -127,7 +127,7 @@ 'icon' => 'modules', 'label' => 'la_title_Module_Status', 'url' => Array('t' => 'modules/modules_list', 'index_file' => 'index4.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 1, 'type' => stTREE, ), @@ -137,7 +137,7 @@ 'icon' => 'modules', 'label' => 'la_title_Add_Module', 'url' => Array('index_file' => 'modules/addmodule.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 2, 'type' => stTREE, ), Index: trunk/kernel/units/general/helpers/sections_helper.php =================================================================== diff -u --- trunk/kernel/units/general/helpers/sections_helper.php (revision 0) +++ trunk/kernel/units/general/helpers/sections_helper.php (revision 4607) @@ -0,0 +1,75 @@ +Tree = Array(); + $unit_config_reader =& $this->Application->recallObject('kUnitConfigReader'); + $prefixes = array_keys($unit_config_reader->configData); + foreach ($prefixes as $prefix) { + $config =& $unit_config_reader->configData[$prefix]; + $sections = getArrayValue($config, 'Sections'); + if (!$sections) continue; + +// echo 'Prefix: ['.$prefix.'] has ['.count($sections).'] sections
'; + + foreach ($sections as $section_name => $section_params) { + // we could also skip not allowed sections here in future + if ($section_params['type'] != stTREE) continue; + $section_params['SectionPrefix'] = $prefix; + $section_params['url']['m_opener'] = 'r'; + $section_params['url']['section'] = $section_name; + + if (!isset($section_params['url']['module'])) { + $module_name = $this->Application->findModule('Path', $config['ModuleFolder'].'/', 'Name'); + $section_params['url']['module'] = $module_name; + } + + if (!isset($section_params['url']['t'])) { + $section_params['url']['t'] = 'index'; + } + + $current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array(); + $this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params); + + $this->Tree[ $section_params['parent'] ]['children'][ "{$section_params['priority']}" ] = $section_name; + } + } + } + + /** + * Returns details information about section + * + * @param string $section_name + * @return Array + */ + function &getSectionData($section_name) + { + if (isset($this->Tree[$section_name])) { + $ret =& $this->Tree[$section_name]; + } + else { + $ret = Array(); + } + return $ret; + } + } + +?> \ No newline at end of file Index: trunk/core/units/general/helpers/sections_helper.php =================================================================== diff -u --- trunk/core/units/general/helpers/sections_helper.php (revision 0) +++ trunk/core/units/general/helpers/sections_helper.php (revision 4607) @@ -0,0 +1,75 @@ +Tree = Array(); + $unit_config_reader =& $this->Application->recallObject('kUnitConfigReader'); + $prefixes = array_keys($unit_config_reader->configData); + foreach ($prefixes as $prefix) { + $config =& $unit_config_reader->configData[$prefix]; + $sections = getArrayValue($config, 'Sections'); + if (!$sections) continue; + +// echo 'Prefix: ['.$prefix.'] has ['.count($sections).'] sections
'; + + foreach ($sections as $section_name => $section_params) { + // we could also skip not allowed sections here in future + if ($section_params['type'] != stTREE) continue; + $section_params['SectionPrefix'] = $prefix; + $section_params['url']['m_opener'] = 'r'; + $section_params['url']['section'] = $section_name; + + if (!isset($section_params['url']['module'])) { + $module_name = $this->Application->findModule('Path', $config['ModuleFolder'].'/', 'Name'); + $section_params['url']['module'] = $module_name; + } + + if (!isset($section_params['url']['t'])) { + $section_params['url']['t'] = 'index'; + } + + $current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array(); + $this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params); + + $this->Tree[ $section_params['parent'] ]['children'][ "{$section_params['priority']}" ] = $section_name; + } + } + } + + /** + * Returns details information about section + * + * @param string $section_name + * @return Array + */ + function &getSectionData($section_name) + { + if (isset($this->Tree[$section_name])) { + $ret =& $this->Tree[$section_name]; + } + else { + $ret = Array(); + } + return $ret; + } + } + +?> \ No newline at end of file Index: trunk/core/units/general/helpers/permissions_helper.php =================================================================== diff -u --- trunk/core/units/general/helpers/permissions_helper.php (revision 0) +++ trunk/core/units/general/helpers/permissions_helper.php (revision 4607) @@ -0,0 +1,42 @@ +Application->recallObject($prefix.'-perm', null, Array('skip_autoload' => true)); + + $foreign_key = $this->Application->getUnitOption($prefix.'-perm', 'ForeignKey'); + $foreign_value = $this->Application->GetVar($prefix.'_id'); + $sql = 'SELECT * + FROM '.$object->TableName.' + WHERE '.$foreign_key.' = '.$foreign_value; + $permissions = $this->Conn->Query($sql, 'Permission'); + + $this->Permissions = Array(); + foreach ($permissions as $perm_name => $perm_options) { + $perm_record['value'] = $perm_options['PermissionValue']; + $perm_record['id'] = $perm_options['PermissionId']; + $this->Permissions[$perm_name] = $perm_record; + } + } + + function getPermissionValue($perm_name) + { + return getArrayValue($this->Permissions, $perm_name) ? $this->Permissions[$perm_name]['value'] : 0; + } + + function getPermissionID($perm_name) + { + return getArrayValue($this->Permissions, $perm_name) ? $this->Permissions[$perm_name]['id'] : 0; + } + } + +?> \ No newline at end of file Index: trunk/core/units/languages/languages_config.php =================================================================== diff -u -r4457 -r4607 --- trunk/core/units/languages/languages_config.php (.../languages_config.php) (revision 4457) +++ trunk/core/units/languages/languages_config.php (.../languages_config.php) (revision 4607) @@ -94,7 +94,7 @@ 'icon' => 'conf_regional', 'label' => 'la_tab_Regional', 'url' => Array('t' => 'regional/languages_list', 'index_file' => 'index4.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit', 'delete'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 4, 'type' => stTREE, ), Index: trunk/core/kernel/processors/tag_processor.php =================================================================== diff -u -r4199 -r4607 --- trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 4199) +++ trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 4607) @@ -71,7 +71,7 @@ } trigger_error('Tag '.$Method.' Undefined in '.get_class($this).'[Agregated Tag]:
'.$tag.'', E_USER_WARNING); } - trigger_error('Tag Undefined:
'.$tag.'',E_USER_WARNING); + trigger_error('Tag Undefined:
'.$prefix.':'.$tag.'',E_USER_WARNING); return false; } } Index: trunk/kernel/units/general/helpers/permissions_helper.php =================================================================== diff -u --- trunk/kernel/units/general/helpers/permissions_helper.php (revision 0) +++ trunk/kernel/units/general/helpers/permissions_helper.php (revision 4607) @@ -0,0 +1,42 @@ +Application->recallObject($prefix.'-perm', null, Array('skip_autoload' => true)); + + $foreign_key = $this->Application->getUnitOption($prefix.'-perm', 'ForeignKey'); + $foreign_value = $this->Application->GetVar($prefix.'_id'); + $sql = 'SELECT * + FROM '.$object->TableName.' + WHERE '.$foreign_key.' = '.$foreign_value; + $permissions = $this->Conn->Query($sql, 'Permission'); + + $this->Permissions = Array(); + foreach ($permissions as $perm_name => $perm_options) { + $perm_record['value'] = $perm_options['PermissionValue']; + $perm_record['id'] = $perm_options['PermissionId']; + $this->Permissions[$perm_name] = $perm_record; + } + } + + function getPermissionValue($perm_name) + { + return getArrayValue($this->Permissions, $perm_name) ? $this->Permissions[$perm_name]['value'] : 0; + } + + function getPermissionID($perm_name) + { + return getArrayValue($this->Permissions, $perm_name) ? $this->Permissions[$perm_name]['id'] : 0; + } + } + +?> \ No newline at end of file Index: trunk/kernel/units/languages/languages_config.php =================================================================== diff -u -r4457 -r4607 --- trunk/kernel/units/languages/languages_config.php (.../languages_config.php) (revision 4457) +++ trunk/kernel/units/languages/languages_config.php (.../languages_config.php) (revision 4607) @@ -94,7 +94,7 @@ 'icon' => 'conf_regional', 'label' => 'la_tab_Regional', 'url' => Array('t' => 'regional/languages_list', 'index_file' => 'index4.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit', 'delete'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 4, 'type' => stTREE, ), Index: trunk/core/admin_templates/groups/groups_edit_permissions.tpl =================================================================== diff -u -r4603 -r4607 --- trunk/core/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 4603) +++ trunk/core/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 4607) @@ -60,32 +60,69 @@ - + - [x] + + [][]" name="[][]" value=""> + [][]" name="_cb_[][]" checked onchange="update_checkbox(this, document.getElementById('[][]'));"> + +   + - " id="adm[0][]"> + "> - .gif" border="0" alt="" align="absmiddle"/> - + " alt="" border="0"/> + + .gif" border="0" alt="" title="" align="absmiddle"/> + + + + + + + + + + + +
+ " alt="" border="0"/> + [] +
- - - -
- - + + + + + + + + ', 'PermList');"> + +   + +
- + + + - + + + + + + + + +
Index: trunk/kernel/units/general/helpers/modules.php =================================================================== diff -u -r4592 -r4607 --- trunk/kernel/units/general/helpers/modules.php (.../modules.php) (revision 4592) +++ trunk/kernel/units/general/helpers/modules.php (.../modules.php) (revision 4607) @@ -103,6 +103,55 @@ } /** + * Leaves only domain part from hostname (e.g. extract "intechnic.lv" from "test.intechnic.lv") + * Used for admin login license check + * + * @param string $d + * @return string + */ + function _StripDomainHost($d) + { + $dotcount = substr_count($d, '.'); + if ($dotcount == 3) { + $IsIp = true; + for ($x = 0; $x < strlen($d); $x++) { + if (!is_numeric(substr($d, $x, 1)) && substr($d, $x, 1) != '.') + { + $IsIp = false; + break; + } + } + } + + if ($dotcount > 1 && !$IsIp) { + $p = explode('.', $d); + $ret = $p[count($p) - 2].'.'.$p[count($p) - 1]; + } + else { + $ret = $d; + } + return $ret; + } + + /** + * When logging into admin then check only last 2 parts of host name VS domain in license + * + * @param string $user_domain + * @param string $license_domain + * @return int + */ + function _CheckDomain($user_domain, $license_domain) + { + if ($this->Application->IsAdmin()) { + $user_domain = $this->_StripDomainHost($user_domain); + return preg_match('/(.*)'.preg_quote($user_domain, '/').'$/', $license_domain); + } + else { + return preg_match('/(.*)'.preg_quote($license_domain, '/').'$/', $user_domain); + } + } + + /** * Returns modules list, that are in license * * @return Array @@ -123,7 +172,7 @@ if (!$this->_IsLocalSite($domain)) { for ($x = 0; $x < count($i_Keys); $x++) { $key = $i_Keys[$x]; - if (preg_match('/(.*)'.preg_quote($key['domain'], '/').'$/', $domain)) { + if ($this->_CheckDomain($domain, $key['domain'])) { // used hostname is subdomain or matches domain from license $modules = explode(',', $key['mod']); } Index: trunk/kernel/admin_templates/groups/groups_edit_permissions.tpl =================================================================== diff -u -r4603 -r4607 --- trunk/kernel/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 4603) +++ trunk/kernel/admin_templates/groups/groups_edit_permissions.tpl (.../groups_edit_permissions.tpl) (revision 4607) @@ -60,32 +60,69 @@ - + - [x] + + [][]" name="[][]" value=""> + [][]" name="_cb_[][]" checked onchange="update_checkbox(this, document.getElementById('[][]'));"> + +   + - " id="adm[0][]"> + "> - .gif" border="0" alt="" align="absmiddle"/> - + " alt="" border="0"/> + + .gif" border="0" alt="" title="" align="absmiddle"/> + + + + + + + + + + + +
+ " alt="" border="0"/> + [] +
- - - -
- - + + + + + + + + ', 'PermList');"> + +   + +
- + + + - + + + + + + + + +
Index: trunk/core/units/users/users_config.php =================================================================== diff -u -r4596 -r4607 --- trunk/core/units/users/users_config.php (.../users_config.php) (revision 4596) +++ trunk/core/units/users/users_config.php (.../users_config.php) (revision 4607) @@ -97,7 +97,7 @@ 'icon' => 'users', 'label' => 'la_tab_User_List', 'url' => Array('index_file' => 'users/user_list.php', 'pass' => 'm', 'resetpage' => 1), - 'permissions' => Array('view', 'edit', 'delete', 'advanced:ban', 'advanced:send_email'), + 'permissions' => Array('view', 'add', 'edit', 'delete', 'advanced:ban', 'advanced:send_email'), 'priority' => 1, 'type' => stTREE, ), @@ -107,7 +107,7 @@ 'icon' => 'users_settings', 'label' => 'la_tab_ConfigSettings', 'url' => Array('index_file' => 'config/edit_config.php', 'module' => 'In-Portal:Users', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 3, 'type' => stTREE, ), @@ -117,7 +117,7 @@ 'icon' => 'settings_email', 'label' => 'la_tab_ConfigE-mail', 'url' => Array('index_file' => 'config/module_email.php', 'module' => 'In-Portal:Users', 'lpn' => 1, 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 4, 'type' => stTREE, ), @@ -127,7 +127,7 @@ 'icon' => 'settings_custom', 'label' => 'la_tab_ConfigCustom', 'url' => Array('t' => 'custom_fields/custom_fields_list', 'index_file' => 'index4.php', 'cf_type' => 6, 'pass' => 'm,cf'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 5, 'type' => stTREE, ), @@ -137,7 +137,7 @@ 'icon' => 'banlist', 'label' => 'la_tab_BanList', 'url' => Array('index_file' => 'config/edit_banlist.php', 'DataType' => 6, 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 6, 'type' => stTREE, ), Index: trunk/core/units/general/helpers/modules.php =================================================================== diff -u -r4592 -r4607 --- trunk/core/units/general/helpers/modules.php (.../modules.php) (revision 4592) +++ trunk/core/units/general/helpers/modules.php (.../modules.php) (revision 4607) @@ -103,6 +103,55 @@ } /** + * Leaves only domain part from hostname (e.g. extract "intechnic.lv" from "test.intechnic.lv") + * Used for admin login license check + * + * @param string $d + * @return string + */ + function _StripDomainHost($d) + { + $dotcount = substr_count($d, '.'); + if ($dotcount == 3) { + $IsIp = true; + for ($x = 0; $x < strlen($d); $x++) { + if (!is_numeric(substr($d, $x, 1)) && substr($d, $x, 1) != '.') + { + $IsIp = false; + break; + } + } + } + + if ($dotcount > 1 && !$IsIp) { + $p = explode('.', $d); + $ret = $p[count($p) - 2].'.'.$p[count($p) - 1]; + } + else { + $ret = $d; + } + return $ret; + } + + /** + * When logging into admin then check only last 2 parts of host name VS domain in license + * + * @param string $user_domain + * @param string $license_domain + * @return int + */ + function _CheckDomain($user_domain, $license_domain) + { + if ($this->Application->IsAdmin()) { + $user_domain = $this->_StripDomainHost($user_domain); + return preg_match('/(.*)'.preg_quote($user_domain, '/').'$/', $license_domain); + } + else { + return preg_match('/(.*)'.preg_quote($license_domain, '/').'$/', $user_domain); + } + } + + /** * Returns modules list, that are in license * * @return Array @@ -123,7 +172,7 @@ if (!$this->_IsLocalSite($domain)) { for ($x = 0; $x < count($i_Keys); $x++) { $key = $i_Keys[$x]; - if (preg_match('/(.*)'.preg_quote($key['domain'], '/').'$/', $domain)) { + if ($this->_CheckDomain($domain, $key['domain'])) { // used hostname is subdomain or matches domain from license $modules = explode(',', $key['mod']); } Index: trunk/admin/install/inportal_schema.sql =================================================================== diff -u -r4603 -r4607 --- trunk/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 4603) +++ trunk/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 4607) @@ -312,7 +312,7 @@ CREATE TABLE Permissions ( PermissionId int(11) NOT NULL auto_increment, - Permission varchar(30) NOT NULL default '', + Permission varchar(255) NOT NULL default '', GroupId int(11) default '0', PermissionValue int(11) NOT NULL default '0', Type tinyint(4) NOT NULL default '0', Index: trunk/kernel/units/users/users_config.php =================================================================== diff -u -r4596 -r4607 --- trunk/kernel/units/users/users_config.php (.../users_config.php) (revision 4596) +++ trunk/kernel/units/users/users_config.php (.../users_config.php) (revision 4607) @@ -97,7 +97,7 @@ 'icon' => 'users', 'label' => 'la_tab_User_List', 'url' => Array('index_file' => 'users/user_list.php', 'pass' => 'm', 'resetpage' => 1), - 'permissions' => Array('view', 'edit', 'delete', 'advanced:ban', 'advanced:send_email'), + 'permissions' => Array('view', 'add', 'edit', 'delete', 'advanced:ban', 'advanced:send_email'), 'priority' => 1, 'type' => stTREE, ), @@ -107,7 +107,7 @@ 'icon' => 'users_settings', 'label' => 'la_tab_ConfigSettings', 'url' => Array('index_file' => 'config/edit_config.php', 'module' => 'In-Portal:Users', 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 3, 'type' => stTREE, ), @@ -117,7 +117,7 @@ 'icon' => 'settings_email', 'label' => 'la_tab_ConfigE-mail', 'url' => Array('index_file' => 'config/module_email.php', 'module' => 'In-Portal:Users', 'lpn' => 1, 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 4, 'type' => stTREE, ), @@ -127,7 +127,7 @@ 'icon' => 'settings_custom', 'label' => 'la_tab_ConfigCustom', 'url' => Array('t' => 'custom_fields/custom_fields_list', 'index_file' => 'index4.php', 'cf_type' => 6, 'pass' => 'm,cf'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 5, 'type' => stTREE, ), @@ -137,7 +137,7 @@ 'icon' => 'banlist', 'label' => 'la_tab_BanList', 'url' => Array('index_file' => 'config/edit_banlist.php', 'DataType' => 6, 'pass' => 'm'), - 'permissions' => Array('view', 'edit'), + 'permissions' => Array('view', 'add', 'edit'), 'priority' => 6, 'type' => stTREE, ), Index: trunk/core/units/general/my_application.php =================================================================== diff -u -r4590 -r4607 --- trunk/core/units/general/my_application.php (.../my_application.php) (revision 4590) +++ trunk/core/units/general/my_application.php (.../my_application.php) (revision 4607) @@ -26,6 +26,8 @@ $this->registerClass('kXMLHelper',MODULES_PATH.'/kernel/units/general/xml_helper.php','kXMLHelper'); $this->registerClass('kMultiLanguageHelper',MODULES_PATH.'/kernel/units/general/helpers/multilanguage.php','kMultiLanguageHelper'); $this->registerClass('kSearchHelper', MODULES_PATH.'/kernel/units/general/helpers/search_helper.php', 'SearchHelper'); + $this->registerClass('kSectionsHelper', MODULES_PATH.'/kernel/units/general/helpers/sections_helper.php', 'SectionsHelper'); + $this->registerClass('kPermissionsHelper', MODULES_PATH.'/kernel/units/general/helpers/permissions_helper.php', 'PermissionsHelper'); $this->registerClass('kModulesHelper', MODULES_PATH.'/kernel/units/general/helpers/modules.php', 'ModulesHelper'); } Index: trunk/kernel/units/admin/admin_tag_processor.php =================================================================== diff -u -r4603 -r4607 --- trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4603) +++ trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4607) @@ -2,8 +2,6 @@ class AdminTagProcessor extends kDBTagProcessor { - var $Tree = Array(); - function SetConst($params) { $name = $this->SelectParam($params, 'name,const'); @@ -157,52 +155,24 @@ */ function BuildTree($params) { - $this->Tree = Array(); - $unit_config_reader =& $this->Application->recallObject('kUnitConfigReader'); - $prefixes = array_keys($unit_config_reader->configData); - foreach ($prefixes as $prefix) { - $config =& $unit_config_reader->configData[$prefix]; - $sections = getArrayValue($config, 'Sections'); - if (!$sections) continue; - -// echo 'Prefix: ['.$prefix.'] has ['.count($sections).'] sections
'; - - foreach ($sections as $section_name => $section_params) { - // we could also skip not allowed sections here in future - if ($section_params['type'] != stTREE) continue; - $section_params['SectionPrefix'] = $prefix; - $section_params['url']['m_opener'] = 'r'; - $section_params['url']['section'] = $section_name; - - if (!isset($section_params['url']['module'])) { - $module = $this->Application->findModule('Path', $config['ModuleFolder'].'/'); - $section_params['url']['module'] = $module['Name']; - } - - if (!isset($section_params['url']['t'])) { - $section_params['url']['t'] = 'index'; - } - - $current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array(); - $this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params); - - $this->Tree[ $section_params['parent'] ]['children'][ "{$section_params['priority']}" ] = $section_name; - } - - } - -// return '
'.print_r($this->Tree, true).'
'; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $sections_helper->BuildTree(); } function DrawTree($params) { + static $deep_level = 0; + // when processings, then sort children by priority (key of children array) $ret = ''; $section_name = $params['section_name']; $params['name'] = $this->SelectParam($params, 'name,render_as,block'); - - $section_data =& $this->Tree[$section_name]; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $section_data =& $sections_helper->getSectionData($section_name); + + $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0; + $params['deep_level'] = $deep_level++; $template = $section_data['url']['t']; unset($section_data['url']['t']); $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']); @@ -215,8 +185,10 @@ foreach ($section_data['children'] as $section_name) { $params['section_name'] = $section_name; $ret .= $this->DrawTree($params); + $deep_level--; } + return $ret; } @@ -228,7 +200,9 @@ $section_name = $this->Application->RecallVar('section'); } - $section_data =& $this->Tree[$section_name]; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $section_data =& $sections_helper->getSectionData($section_name); + $params['name'] = $this->SelectParam($params, 'name,render_as,block'); $params['section_name'] = $section_name; @@ -250,7 +224,9 @@ $section_name = $this->Application->RecallVar('section'); } - $section_data =& $this->Tree[$section_name]; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $section_data =& $sections_helper->getSectionData($section_name); + $params['name'] = $this->SelectParam($params, 'name,render_as,block'); if (!isset($section_data['children'])) { return ''; @@ -259,7 +235,7 @@ ksort($section_data['children'], SORT_NUMERIC); foreach ($section_data['children'] as $section_name) { $params['section_name'] = $section_name; - $section_data =& $this->Tree[$section_name]; + $section_data =& $sections_helper->getSectionData($section_name); $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0; $template = $section_data['url']['t']; Index: trunk/core/units/stylesheets/stylesheets_config.php =================================================================== diff -u -r4457 -r4607 --- trunk/core/units/stylesheets/stylesheets_config.php (.../stylesheets_config.php) (revision 4457) +++ trunk/core/units/stylesheets/stylesheets_config.php (.../stylesheets_config.php) (revision 4607) @@ -66,7 +66,7 @@ 'icon' => 'style', 'label' => 'la_tab_Stylesheets', 'url' => Array('t' => 'stylesheets/stylesheets_list', 'index_file' => 'index4.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit', 'delete'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 3, 'type' => stTREE, ), Index: trunk/kernel/units/general/my_application.php =================================================================== diff -u -r4590 -r4607 --- trunk/kernel/units/general/my_application.php (.../my_application.php) (revision 4590) +++ trunk/kernel/units/general/my_application.php (.../my_application.php) (revision 4607) @@ -26,6 +26,8 @@ $this->registerClass('kXMLHelper',MODULES_PATH.'/kernel/units/general/xml_helper.php','kXMLHelper'); $this->registerClass('kMultiLanguageHelper',MODULES_PATH.'/kernel/units/general/helpers/multilanguage.php','kMultiLanguageHelper'); $this->registerClass('kSearchHelper', MODULES_PATH.'/kernel/units/general/helpers/search_helper.php', 'SearchHelper'); + $this->registerClass('kSectionsHelper', MODULES_PATH.'/kernel/units/general/helpers/sections_helper.php', 'SectionsHelper'); + $this->registerClass('kPermissionsHelper', MODULES_PATH.'/kernel/units/general/helpers/permissions_helper.php', 'PermissionsHelper'); $this->registerClass('kModulesHelper', MODULES_PATH.'/kernel/units/general/helpers/modules.php', 'ModulesHelper'); } Index: trunk/admin/install/upgrades/inportal_upgrade_v1.1.9.sql =================================================================== diff -u -r4603 -r4607 --- trunk/admin/install/upgrades/inportal_upgrade_v1.1.9.sql (.../inportal_upgrade_v1.1.9.sql) (revision 4603) +++ trunk/admin/install/upgrades/inportal_upgrade_v1.1.9.sql (.../inportal_upgrade_v1.1.9.sql) (revision 4607) @@ -4,4 +4,6 @@ ALTER TABLE CategoryCustomData ADD INDEX (ResourceId); ALTER TABLE PortalUserCustomData ADD INDEX (ResourceId); +ALTER TABLE Permissions CHANGE Permission Permission VARCHAR(255) NOT NULL; + UPDATE Modules SET Version = '1.1.9' WHERE Name = 'In-Portal'; \ No newline at end of file Index: trunk/core/units/admin/admin_tag_processor.php =================================================================== diff -u -r4603 -r4607 --- trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4603) +++ trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4607) @@ -2,8 +2,6 @@ class AdminTagProcessor extends kDBTagProcessor { - var $Tree = Array(); - function SetConst($params) { $name = $this->SelectParam($params, 'name,const'); @@ -157,52 +155,24 @@ */ function BuildTree($params) { - $this->Tree = Array(); - $unit_config_reader =& $this->Application->recallObject('kUnitConfigReader'); - $prefixes = array_keys($unit_config_reader->configData); - foreach ($prefixes as $prefix) { - $config =& $unit_config_reader->configData[$prefix]; - $sections = getArrayValue($config, 'Sections'); - if (!$sections) continue; - -// echo 'Prefix: ['.$prefix.'] has ['.count($sections).'] sections
'; - - foreach ($sections as $section_name => $section_params) { - // we could also skip not allowed sections here in future - if ($section_params['type'] != stTREE) continue; - $section_params['SectionPrefix'] = $prefix; - $section_params['url']['m_opener'] = 'r'; - $section_params['url']['section'] = $section_name; - - if (!isset($section_params['url']['module'])) { - $module = $this->Application->findModule('Path', $config['ModuleFolder'].'/'); - $section_params['url']['module'] = $module['Name']; - } - - if (!isset($section_params['url']['t'])) { - $section_params['url']['t'] = 'index'; - } - - $current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array(); - $this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params); - - $this->Tree[ $section_params['parent'] ]['children'][ "{$section_params['priority']}" ] = $section_name; - } - - } - -// return '
'.print_r($this->Tree, true).'
'; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $sections_helper->BuildTree(); } function DrawTree($params) { + static $deep_level = 0; + // when processings, then sort children by priority (key of children array) $ret = ''; $section_name = $params['section_name']; $params['name'] = $this->SelectParam($params, 'name,render_as,block'); - - $section_data =& $this->Tree[$section_name]; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $section_data =& $sections_helper->getSectionData($section_name); + + $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0; + $params['deep_level'] = $deep_level++; $template = $section_data['url']['t']; unset($section_data['url']['t']); $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']); @@ -215,8 +185,10 @@ foreach ($section_data['children'] as $section_name) { $params['section_name'] = $section_name; $ret .= $this->DrawTree($params); + $deep_level--; } + return $ret; } @@ -228,7 +200,9 @@ $section_name = $this->Application->RecallVar('section'); } - $section_data =& $this->Tree[$section_name]; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $section_data =& $sections_helper->getSectionData($section_name); + $params['name'] = $this->SelectParam($params, 'name,render_as,block'); $params['section_name'] = $section_name; @@ -250,7 +224,9 @@ $section_name = $this->Application->RecallVar('section'); } - $section_data =& $this->Tree[$section_name]; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $section_data =& $sections_helper->getSectionData($section_name); + $params['name'] = $this->SelectParam($params, 'name,render_as,block'); if (!isset($section_data['children'])) { return ''; @@ -259,7 +235,7 @@ ksort($section_data['children'], SORT_NUMERIC); foreach ($section_data['children'] as $section_name) { $params['section_name'] = $section_name; - $section_data =& $this->Tree[$section_name]; + $section_data =& $sections_helper->getSectionData($section_name); $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0; $template = $section_data['url']['t']; Index: trunk/kernel/units/stylesheets/stylesheets_config.php =================================================================== diff -u -r4457 -r4607 --- trunk/kernel/units/stylesheets/stylesheets_config.php (.../stylesheets_config.php) (revision 4457) +++ trunk/kernel/units/stylesheets/stylesheets_config.php (.../stylesheets_config.php) (revision 4607) @@ -66,7 +66,7 @@ 'icon' => 'style', 'label' => 'la_tab_Stylesheets', 'url' => Array('t' => 'stylesheets/stylesheets_list', 'index_file' => 'index4.php', 'pass' => 'm'), - 'permissions' => Array('view', 'edit', 'delete'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), 'priority' => 3, 'type' => stTREE, ),