Index: branches/5.0.x/core/units/images/image_event_handler.php =================================================================== diff -u -N -r12299 -r12726 --- branches/5.0.x/core/units/images/image_event_handler.php (.../image_event_handler.php) (revision 12299) +++ branches/5.0.x/core/units/images/image_event_handler.php (.../image_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ Special == 'list' && !$this->Application->IsAdmin()) { + if ($event->Special == 'list' && !$this->Application->isAdmin) { // ListImages aggregated tag uses this special return ''; } @@ -301,8 +301,7 @@ $object =& $event->getObject(); $type_clauses = Array(); - if( !$this->Application->IsAdmin() ) - { + if (!$this->Application->isAdminUser) { $object->addFilter('active', '%1$s.Enabled = 1'); } Index: branches/5.0.x/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r12707 -r12726 --- branches/5.0.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 12707) +++ branches/5.0.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 12726) @@ -1,6 +1,6 @@ SelectParam($params, 'name,field'); - if( !$this->Application->IsAdmin() ) { + if (!$this->Application->isAdmin) { // apply htmlspecialchars on all field values on Front-End $params['no_special'] = 'no_special'; } Index: branches/5.0.x/core/kernel/session/session.php =================================================================== diff -u -N -r12592 -r12726 --- branches/5.0.x/core/kernel/session/session.php (.../session.php) (revision 12592) +++ branches/5.0.x/core/kernel/session/session.php (.../session.php) (revision 12726) @@ -1,6 +1,6 @@ Check(); - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { // 1. Front-End session may not be created (SID is present, but no data in database). // Check expiration LATER from kApplication::Init, because template, used in session // expiration redirect should be retrieved from mod-rewrite url first. @@ -851,7 +851,7 @@ return true; } - if (!$force && !($this->Application->IsAdmin() || $this->Application->GetVar('admin')) && !$this->NeedSession()) { + if (!$force && !($this->Application->isAdmin || $this->Application->GetVar('admin')) && !$this->NeedSession()) { // don't create session (in db) on Front-End, when sid is present (GPC), but data in db isn't if ($this->_fromGet) { // set sid, that was given in GET @@ -887,7 +887,7 @@ $this->Storage->StoreSession($this); - if ($this->Application->IsAdmin() || $this->Special == 'admin') { + if ($this->Application->isAdmin || $this->Special == 'admin') { $this->StoreVar('admin', 1); } @@ -1092,7 +1092,7 @@ // save last_template in persistant session if (!$wid) { - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { // only for main window, not popups, not login template, not temp mode (used in adm:MainFrameLink tag) $temp_mode = false; $passed = explode(',', $this->Application->GetVar('passed')); Index: branches/5.0.x/core/units/languages/languages_item.php =================================================================== diff -u -N -r12299 -r12726 --- branches/5.0.x/core/units/languages/languages_item.php (.../languages_item.php) (revision 12299) +++ branches/5.0.x/core/units/languages/languages_item.php (.../languages_item.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if ($this->Application->isAdmin) { $res = parent::Load(1); } else { Index: branches/5.0.x/core/kernel/db/cat_tag_processor.php =================================================================== diff -u -N -r12570 -r12726 --- branches/5.0.x/core/kernel/db/cat_tag_processor.php (.../cat_tag_processor.php) (revision 12570) +++ branches/5.0.x/core/kernel/db/cat_tag_processor.php (.../cat_tag_processor.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if ($this->Application->isAdminUser) { // path for module root category in admin if (!isset($params['cat_id'])) { $params['cat_id'] = $this->Application->RecallVar($params['session_var'], 0); Index: branches/5.0.x/core/units/custom_fields/custom_fields_event_handler.php =================================================================== diff -u -N -r12511 -r12726 --- branches/5.0.x/core/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 12511) +++ branches/5.0.x/core/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ addFilter('itemtype_filter', '%1$s.Type = '.$item_type); } - if (!($this->Application->isDebugMode() && $this->Application->IsAdmin())) { + if (!($this->Application->isDebugMode() && $this->Application->isAdminUser)) { $object->addFilter('user_filter', '%1$s.IsSystem = 0'); } } Index: branches/5.0.x/core/units/users/users_event_handler.php =================================================================== diff -u -N -r12511 -r12726 --- branches/5.0.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 12511) +++ branches/5.0.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ addFilter('primary_filter', 'ug.GroupId <> 11'); } - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $object->addFilter('status_filter', '%1$s.Status = '.STATUS_ACTIVE); } @@ -104,7 +104,7 @@ return true; } - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $user_id = $this->Application->RecallVar('user_id'); $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); @@ -164,8 +164,7 @@ 'no_pass_through' => 1, // this way kApplication::HREF won't add them again ); - if ($this->Application->IsAdmin()) { - + if ($this->Application->isAdmin) { $this->Application->Redirect('index', $admin_url_params, '', 'index.php'); } @@ -199,11 +198,11 @@ function OnLogin(&$event) { // persistent session data after login is not refreshed, because redirect will follow in any case - $prefix_special = $this->Application->IsAdmin() ? 'u.current' : 'u'; // "u" used on front not to change theme + $prefix_special = $this->Application->isAdmin ? 'u.current' : 'u'; // "u" used on front not to change theme $object =& $this->Application->recallObject($prefix_special, null, Array('skip_autoload' => true)); $password = $this->Application->GetVar('password'); - $invalid_pseudo = $this->Application->IsAdmin() ? 'la_invalid_password' : 'lu_invalid_password'; + $invalid_pseudo = $this->Application->isAdmin ? 'la_invalid_password' : 'lu_invalid_password'; $remember_login_cookie = $this->Application->GetVar('remember_login'); if (!$password && !$remember_login_cookie) { @@ -213,18 +212,18 @@ } $email_as_login = $this->Application->ConfigValue('Email_As_Login'); - list ($login_field, $submit_field) = $email_as_login && !$this->Application->IsAdmin() ? Array('Email', 'email') : Array('Login', 'login'); + list ($login_field, $submit_field) = $email_as_login && !$this->Application->isAdmin ? Array('Email', 'email') : Array('Login', 'login'); $login_value = $this->Application->GetVar($submit_field); // process "Save Username" checkbox - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { $save_username = $this->Application->GetVar('cb_save_username') ? $login_value : ''; $this->Application->Session->SetCookie('save_username', $save_username, adodb_mktime() + 31104000); // 1 year expiration $this->Application->SetVar('save_username', $save_username); // cookie will be set on next refresh, but refresh won't occur if login error present, so duplicate cookie in HTTPQuery } $super_admin = ($login_value == 'super-root') && $this->verifySuperAdmin(); - if ($this->Application->IsAdmin() && ($login_value == 'root') || ($super_admin && $login_value == 'super-root')) { + if ($this->Application->isAdmin && ($login_value == 'root') || ($super_admin && $login_value == 'super-root')) { // logging in "root" (admin only) $login_value = 'root'; @@ -350,7 +349,7 @@ { $remember_login_cookie = $this->Application->GetVar('remember_login'); - if (!$remember_login_cookie || $this->Application->IsAdmin() || $this->Application->LoggedIn()) { + if (!$remember_login_cookie || $this->Application->isAdmin || $this->Application->LoggedIn()) { return ; } @@ -377,8 +376,9 @@ function checkLoginPermission($user_name) { $ret = true; - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { $modules_helper =& $this->Application->recallObject('ModulesHelper'); + if ($user_name != 'root') { // root is virtual user, so allow him to login to admin in any case $ret = $this->Application->CheckPermission('ADMIN', 1); @@ -387,6 +387,7 @@ else { $ret = $this->Application->CheckPermission('LOGIN', 1); } + return $ret; } @@ -397,7 +398,7 @@ */ function processLoginRedirect(&$event, $password) { - $prefix_special = $this->Application->IsAdmin() ? 'u.current' : 'u'; // "u" used on front not to change theme + $prefix_special = $this->Application->isAdmin ? 'u.current' : 'u'; // "u" used on front not to change theme $object =& $this->Application->recallObject($prefix_special, null, Array('skip_autoload' => true)); $next_template = $this->Application->GetVar('next_template'); @@ -533,7 +534,7 @@ $this->Conn->Query($sql); // set primary group to user - if ($this->Application->IsAdmin() && $this->Application->GetVar('user_group')) { + if ($this->Application->isAdminUser && $this->Application->GetVar('user_group')) { // while in admin you can set any group for new users $group_id = $this->Application->GetVar('user_group'); } @@ -640,7 +641,9 @@ { $this->OnAfterItemCreate($event); $object->SendEmailEvents(); - if( !$this->Application->IsAdmin() && ($event->status == erSUCCESS) && $event->redirect) $this->autoLoginUser($event); + if (!$this->Application->isAdmin && ($event->status == erSUCCESS) && $event->redirect) { + $this->autoLoginUser($event); + } } } return $is_subscriber; @@ -653,10 +656,11 @@ */ function OnCreate(&$event) { - if( !$this->Application->IsAdmin() ) $this->setUserStatus($event); + if (!$this->Application->isAdminUser) { + $this->setUserStatus($event); + } - if( !$this->isSubscriberOnly($event) ) - { + if (!$this->isSubscriberOnly($event)) { $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); $cs_helper->CheckStateField($event, 'State', 'Country'); @@ -674,8 +678,7 @@ $this->setNextTemplate($event); - if( !$this->Application->IsAdmin() && ($event->status == erSUCCESS) && $event->redirect) - { + if (!$this->Application->isAdmin && ($event->status == erSUCCESS) && $event->redirect) { $object->SendEmailEvents(); $this->autoLoginUser($event); } @@ -1144,14 +1147,18 @@ */ function setNextTemplate(&$event) { - if( !$this->Application->IsAdmin() ) - { - $event->redirect_params['opener'] = 's'; - $object =& $event->getObject(); - if($object->GetDBField('Status') == STATUS_ACTIVE) - { - $next_template = $this->Application->GetVar('next_template'); - if($next_template) $event->redirect = $next_template; + if ($this->Application->isAdmin) { + return ; + } + + $event->redirect_params['opener'] = 's'; + $object =& $event->getObject(); + + if ($object->GetDBField('Status') == STATUS_ACTIVE) { + $next_template = $this->Application->GetVar('next_template'); + + if ($next_template) { + $event->redirect = $next_template; } } } @@ -1437,7 +1444,7 @@ $object =& $event->getObject(); /* @var $object UsersItem */ - if (!$this->Application->IsAdmin() || $object->IsTempTable()) { + if (!$this->Application->isAdmin || $object->IsTempTable()) { return ; } @@ -1549,7 +1556,7 @@ $file_helper->createItemFiles($event->Prefix, true); // create image fields - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { // 4. when in administrative console, then create all users with Active status $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); // $fields['Password']['required'] = 1; // set password required (will broke approve/decline buttons) @@ -1728,7 +1735,7 @@ */ function saveUserImages(&$event) { - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdmin) { $image_helper =& $this->Application->recallObject('ImageHelper'); /* @var $image_helper ImageHelper */ Index: branches/5.0.x/core/units/images/image_tag_processor.php =================================================================== diff -u -N -r12299 -r12726 --- branches/5.0.x/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 12299) +++ branches/5.0.x/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 12726) @@ -1,6 +1,6 @@ Application->BaseURL(), '/'); - $sub_folder = $this->Application->IsAdmin() ? rtrim(IMAGES_PATH, '/') : THEMES_PATH; + $sub_folder = $this->Application->isAdmin ? rtrim(IMAGES_PATH, '/') : THEMES_PATH; if ($max_width > 0 || $max_height > 0) { $image_helper =& $this->Application->recallObject('ImageHelper'); Index: branches/5.0.x/core/units/themes/themes_eh.php =================================================================== diff -u -N -r12588 -r12726 --- branches/5.0.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 12588) +++ branches/5.0.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if ($this->Application->isAdminUser) { // for structure theme dropdown $this->Application->StoreVar('theme_id', $this->Application->GetVar('theme')); $this->Application->StoreVar('RefreshStructureTree', 1); @@ -152,7 +152,7 @@ { parent::SetCustomQuery($event); - if ($event->Special == 'enabled' || !$this->Application->IsAdmin()) { + if ($event->Special == 'enabled' || !$this->Application->isAdminUser) { // "enabled" special or Front-End $object =& $event->getObject(); Index: branches/5.0.x/core/units/form_submissions/form_submissions_eh.php =================================================================== diff -u -N -r12511 -r12726 --- branches/5.0.x/core/units/form_submissions/form_submissions_eh.php (.../form_submissions_eh.php) (revision 12511) +++ branches/5.0.x/core/units/form_submissions/form_submissions_eh.php (.../form_submissions_eh.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if (!$this->Application->isAdmin) { if ($event->Name == 'OnCreate') { // anybody can submit forms on front return true; @@ -118,9 +118,11 @@ function getPassedID(&$event) { - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { + // no way to see other user's form submission by giving it's ID directly in url return 0; } + return parent::getPassedID($event); } Index: branches/5.0.x/core/units/files/file_eh.php =================================================================== diff -u -N -r12299 -r12726 --- branches/5.0.x/core/units/files/file_eh.php (.../file_eh.php) (revision 12299) +++ branches/5.0.x/core/units/files/file_eh.php (.../file_eh.php) (revision 12726) @@ -1,6 +1,6 @@ getObject(); - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $object->addFilter('active_filter', '%1$s.Status = '.STATUS_ACTIVE); } } Index: branches/5.0.x/core/units/themes/theme_item.php =================================================================== diff -u -N -r12299 -r12726 --- branches/5.0.x/core/units/themes/theme_item.php (.../theme_item.php) (revision 12299) +++ branches/5.0.x/core/units/themes/theme_item.php (.../theme_item.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if ($this->Application->isAdmin) { $res = parent::Load(1); } } Index: branches/5.0.x/core/kernel/nparser/template_cache.php =================================================================== diff -u -N -r12323 -r12726 --- branches/5.0.x/core/kernel/nparser/template_cache.php (.../template_cache.php) (revision 12323) +++ branches/5.0.x/core/kernel/nparser/template_cache.php (.../template_cache.php) (revision 12726) @@ -1,6 +1,6 @@ _compileToDatabase = defined('SAFE_MODE') && SAFE_MODE; $this->_compressOutput = $this->Application->ConfigValue('UseTemplateCompression'); - $this->_isAdmin = $this->Application->IsAdmin(); + + if ($this->Application->isAdmin) { + // prepare module template paths for quick access + $module_paths = Array (); + + foreach ($this->Application->ModuleInfo as $module_name => $module_info) { + $module_paths[$module_name] = rtrim($module_info['Path'], '/'); + } + + $this->_modulePaths = $module_paths; + } } /** @@ -73,7 +83,7 @@ */ function GetTemplatePaths($filename) { - if ($this->_isAdmin && array_key_exists($filename, $this->Application->ReplacementTemplates)) { + if ($this->Application->isAdmin && array_key_exists($filename, $this->Application->ReplacementTemplates)) { $filename = $this->Application->ReplacementTemplates[$filename]; } @@ -95,7 +105,7 @@ } // !preg_match for backward compatability with full-path plugins - if ($this->_isAdmin && ($first_dir == 'plugins') && !preg_match('/admin_templates/', $module_filename)) { + if ($this->Application->isAdmin && ($first_dir == 'plugins') && !preg_match('/admin_templates/', $module_filename)) { if (preg_match('#^[\/]{0,1}([^\/]*)\/(.*)#', $module_filename, $regs)) {; $path = MODULES_PATH.'/'.mb_strtolower($first_dir).'/'.$regs[1].'/admin_templates'; $module_filename = $regs[2]; @@ -105,7 +115,8 @@ $module_filename = $filename; } } - elseif ($this->_isAdmin && $this->Application->findModule('Name', $first_dir)) { + elseif ($this->Application->isAdmin && in_array($first_dir, $this->_modulePaths)) { + // $this->Application->findModule('Name', $first_dir) /*if ($first_dir == 'in-portal') { $first_dir = 'kernel'; }*/ Index: branches/5.0.x/core/kernel/languages/phrases_cache.php =================================================================== diff -u -N -r12591 -r12726 --- branches/5.0.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 12591) +++ branches/5.0.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 12726) @@ -1,6 +1,6 @@ Conn =& $this->Application->GetADODBConnection(); - if (defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->IsAdmin()) { + if (defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->isAdmin) { // only has effect in admin, because on front-end phrases are translated in "Content Mode" $this->_editMissing = defined('DBG_PHRASES') && DBG_PHRASES; } @@ -94,7 +94,7 @@ */ function setPhraseEditing() { - if (!$this->Application->IsAdmin() && (EDITING_MODE == EDITING_MODE_CONTENT)) { + if (!$this->Application->isAdmin && (EDITING_MODE == EDITING_MODE_CONTENT)) { $this->_editExisting = true; $this->_editMissing = true; $this->_simpleEditingMode = true; @@ -108,7 +108,7 @@ $this->LanguageId = 1; } else { - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { $id_field = $this->Application->getUnitOption('lang', 'IDField'); $table_name = $this->Application->getUnitOption('lang', 'TableName'); $sql = 'SELECT '.$id_field.' Index: branches/5.0.x/core/units/thesaurus/thesaurus_eh.php =================================================================== diff -u -N -r12299 -r12726 --- branches/5.0.x/core/units/thesaurus/thesaurus_eh.php (.../thesaurus_eh.php) (revision 12299) +++ branches/5.0.x/core/units/thesaurus/thesaurus_eh.php (.../thesaurus_eh.php) (revision 12726) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBList */ - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $keywords = unhtmlentities( trim($this->Application->GetVar('keywords')) ); $object->addFilter('search_filter', '%1$s.SearchTerm LIKE ' . $this->Conn->qstr($keywords).' OR %1$s.SearchTerm LIKE ' . $this->Conn->qstr($keywords . '_')); } Index: branches/5.0.x/core/units/helpers/themes_helper.php =================================================================== diff -u -N -r12634 -r12726 --- branches/5.0.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 12634) +++ branches/5.0.x/core/units/helpers/themes_helper.php (.../themes_helper.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if ($this->Application->isAdmin) { // get theme, that user selected in catalog $theme_id = $this->Application->RecallVar('theme_id'); Index: branches/5.0.x/core/kernel/processors/main_processor.php =================================================================== diff -u -N -r12716 -r12726 --- branches/5.0.x/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 12716) +++ branches/5.0.x/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin() || $force_admin) { + if ($this->Application->isAdmin || $force_admin) { if ($module == 'in-portal') { $module = 'kernel'; } @@ -227,12 +227,12 @@ if (array_key_exists($name, $this->Application->Parser->Captures)) { $capture_params = $params; $capture_params['name'] = '__capture_' . $name; - + $this->Application->Parser->SetParam($name, $this->Application->ParseBlock($capture_params)); } - + $res = $this->Application->Parser->GetParam($name); - + if ($res === false) { $res = ''; } @@ -587,15 +587,15 @@ $module_key = mb_strtolower($module_name); if ($module_name == 'In-Portal') { - if (!$cms_mode && $this->Application->IsAdmin()) { + if (!$cms_mode && $this->Application->isAdmin) { // don't process In-Portal templates in admin continue; } // Front-End still relies on In-Portal module $module_prefix = $module_data['TemplatePath']; } - elseif ($this->Application->IsAdmin()) { + elseif ($this->Application->isAdmin) { $module_prefix = $module_data['Path']; // was $module_key . '/'; } else { @@ -805,7 +805,7 @@ */ function CheckSSL($params) { - $ssl = $this->Application->IsAdmin() ? $this->Application->ConfigValue('AdminSSL_URL') : false; + $ssl = $this->Application->isAdmin ? $this->Application->ConfigValue('AdminSSL_URL') : false; if (!$ssl) { // not in admin or admin ssl url is empty Index: branches/5.0.x/core/units/theme_files/theme_file_eh.php =================================================================== diff -u -N -r12299 -r12726 --- branches/5.0.x/core/units/theme_files/theme_file_eh.php (.../theme_file_eh.php) (revision 12299) +++ branches/5.0.x/core/units/theme_files/theme_file_eh.php (.../theme_file_eh.php) (revision 12726) @@ -1,6 +1,6 @@ Name == 'OnLoadBlock' || $event->Name == 'OnSaveBlock') { - return $this->Application->LoggedIn() && $this->Application->IsAdmin(); + return $this->Application->isAdminUser; } return parent::CheckPermission($event); Index: branches/5.0.x/core/kernel/kbase.php =================================================================== diff -u -N -r12299 -r12726 --- branches/5.0.x/core/kernel/kbase.php (.../kbase.php) (revision 12299) +++ branches/5.0.x/core/kernel/kbase.php (.../kbase.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if ($this->Application->isAdminUser) { // can change upload dir on the fly (admin only!) $allowed_modifiers[] = 'upload_dir'; } Index: branches/5.0.x/core/units/helpers/category_helper.php =================================================================== diff -u -N -r12706 -r12726 --- branches/5.0.x/core/units/helpers/category_helper.php (.../category_helper.php) (revision 12706) +++ branches/5.0.x/core/units/helpers/category_helper.php (.../category_helper.php) (revision 12726) @@ -1,6 +1,6 @@ $page_id, 'pass' => 'm'); $page_url = $this->Application->HREF(strtolower($templates[$page_id]), '', $url_params); - /*if ($this->Application->IsAdmin()) { + /*if ($this->Application->isAdmin) { $page_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $page_url); }*/ Index: branches/5.0.x/core/kernel/utility/http_query.php =================================================================== diff -u -N -r12511 -r12726 --- branches/5.0.x/core/kernel/utility/http_query.php (.../http_query.php) (revision 12511) +++ branches/5.0.x/core/kernel/utility/http_query.php (.../http_query.php) (revision 12726) @@ -1,6 +1,6 @@ Conn =& $this->Application->GetADODBConnection(); + $this->Conn =& $this->Application->GetADODBConnection(); $this->Order = $order; - $this->Admin = $this->Application->IsAdmin(); // better cache this value, not to calculate it each time in foreach if (array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { // when AJAX request is made from jQuery, then create ajax variable, @@ -546,23 +545,29 @@ function StripSlashes($array) { - //if( !get_magic_quotes_gpc() ) return $array; - foreach($array as $key=>$value) - { - if( is_array($value) ) - { + static $magic_quotes = null; + + if (!isset($magic_quotes)) { + $magic_quotes = get_magic_quotes_gpc(); + } + + foreach ($array as $key => $value) { + if (is_array($value)) { $array[$key] = $this->StripSlashes($value); } - else - { -// $value = iconv('UTF-8', 'windows-1257', $value); + else { + if ($magic_quotes) { + $value = stripslashes($value); + } - if( get_magic_quotes_gpc() ) $value = stripslashes($value); - if(!$this->Admin) $value = htmlspecialchars($value); + if (!$this->Application->isAdmin) { + $value = htmlspecialchars($value); + } + $array[$key] = $value; } - //$array[$key]=is_array($value)?$this->StripSlashes($value):stripslashes($value); } + return $array; } @@ -591,7 +596,7 @@ if ($access_error) { $vars = $this->_removePassThroughVariables($vars); - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { // place 1 of 2 (also in UsersEventHandler::OnSessionExpire) $vars['m_cat_id'] = 0; // category means nothing on admin login screen $vars['m_wid'] = ''; // remove wid, otherwise parent window may add wid to its name breaking all the frameset (for targets) @@ -651,7 +656,7 @@ if ($fp) { $session =& $this->Application->recallObject('Session'); $user_id = $session->GetField('PortalUserId'); - $admin_mark = $this->Application->IsAdmin() ? 'ADMIN' : 'FRONT'; + $admin_mark = $this->Application->isAdmin ? 'ADMIN' : 'FRONT'; $data = '['.date('D M d H:i:s Y').'] '.$admin_mark.'; ip: '.$_SERVER['REMOTE_ADDR'].'; user_id: '.$user_id.'; sid: '.$this->Application->GetSID().'; request: '."\n"; if ($this->Get) { Index: branches/5.0.x/core/kernel/db/dbitem.php =================================================================== diff -u -N -r12706 -r12726 --- branches/5.0.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 12706) +++ branches/5.0.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 12726) @@ -1,6 +1,6 @@ Application->GetTopmostPrefix($this->Prefix); - $this->Application->StoreVar($main_prefix.'_modified', '1', !$this->Application->IsAdmin()); + $this->Application->StoreVar($main_prefix.'_modified', '1', !$this->Application->isAdmin); if ($this->ShouldLogChanges()) { $this->LogChanges($main_prefix, $mode); Index: branches/5.0.x/core/units/phrases/phrases_event_handler.php =================================================================== diff -u -N -r12640 -r12726 --- branches/5.0.x/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 12640) +++ branches/5.0.x/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin() && $this->Application->isDebugMode() && constOn('DBG_PHRASES')) { + if (!$this->Application->isAdmin && $this->Application->isDebugMode() && constOn('DBG_PHRASES')) { $allow_events = Array ('OnCreate', 'OnUpdate'); if (in_array($event->Name, $allow_events)) { Index: branches/5.0.x/core/units/reviews/reviews_event_handler.php =================================================================== diff -u -N -r12466 -r12726 --- branches/5.0.x/core/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 12466) +++ branches/5.0.x/core/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ Special == 'product' && !$this->Application->IsAdmin()) { + if ($event->Special == 'product' && !$this->Application->isAdmin) { // rev.product should auto-link return ''; } @@ -172,7 +172,7 @@ $object =& $event->getObject(); /* @var $object kDBList */ - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $object->addFilter('active', '%1$s.Status = '.STATUS_ACTIVE); } @@ -264,7 +264,8 @@ $object->SetDBField('ItemType', $item_type); $object->SetDBField('Module', $this->Application->findModule('Var', $parent_info['ParentPrefix'], 'Name')); - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { + // don't perform spam control on admin return ; } @@ -315,7 +316,7 @@ { $this->updateSubitemCounters($event); - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $spam_helper =& $this->Application->recallObject('SpamHelper'); /* @var $spam_helper SpamHelper */ @@ -352,7 +353,7 @@ $object =& $event->getObject(); /* @var $object kDBItem */ - if ($this->Application->IsAdmin() && !$object->IsTempTable()) { + if ($this->Application->isAdminUser && !$object->IsTempTable()) { // send email on review status change from reviews grid in admin $review_status = $object->GetDBField('Status'); $process_status = Array (STATUS_ACTIVE, STATUS_DISABLED); @@ -481,7 +482,7 @@ { parent::OnCreate($event); - if ($event->status != erSUCCESS || $this->Application->IsAdmin()) { + if ($event->status != erSUCCESS || $this->Application->isAdmin) { return ; } Index: branches/5.0.x/core/units/languages/languages_event_handler.php =================================================================== diff -u -N -r12640 -r12726 --- branches/5.0.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 12640) +++ branches/5.0.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ Application->SetVar('m_lang', $this->Application->GetVar('language')); - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { // without this language change in admin will cause erase of last remembered tree section $this->Application->SetVar('skip_last_template', 1); } Index: branches/5.0.x/core/units/helpers/permissions_helper.php =================================================================== diff -u -N -r12511 -r12726 --- branches/5.0.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 12511) +++ branches/5.0.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 12726) @@ -1,6 +1,6 @@ check by current (before editing started, saved in OnPreCreate event) category permissions // note: category in session is placed on catalog data import start - $category_id = $this->Application->IsAdmin() ? $this->Application->RecallVar('m_cat_id') : $this->Application->GetVar('m_cat_id'); + $category_id = $this->Application->isAdmin ? $this->Application->RecallVar('m_cat_id') : $this->Application->GetVar('m_cat_id'); } elseif ($top_prefix == 'c' || $top_prefix == 'st') { $category_id = $id; @@ -212,7 +212,7 @@ $new_item = false; } else { - $new_item = $this->Application->IsAdmin() && $event_handler->isNewItemCreate($event) ? true : false; + $new_item = $this->Application->isAdminUser && $event_handler->isNewItemCreate($event) ? true : false; $check_status = $this->checkCombinedPermissions($event, $owner_id, (int)$category_id, $new_item); } @@ -329,7 +329,7 @@ */ function CheckEventCategoryPermission(&$event, $event_perm_mapping) { - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdmin) { // check front-end permission by old scheme return $this->_frontCheckEventCategoryPermission($event, $event_perm_mapping); } @@ -348,7 +348,7 @@ } // 1. most of events does require admin login only - $perm_status = $this->Application->LoggedIn() && $this->Application->IsAdmin(); + $perm_status = $this->Application->isAdminUser; // 2. in case, when event require more, then "view" right, then restrict it to temporary tables only if (!in_array('view', $check_perms)) { @@ -450,7 +450,7 @@ if (!$this->Application->LoggedIn()) { $redirect_template = array_key_exists('login_template', $params) ? $params['login_template'] : ''; - if (!$redirect_template && $this->Application->IsAdmin()) { + if (!$redirect_template && $this->Application->isAdmin) { $redirect_template = 'login'; } $redirect_params['next_template'] = $t; @@ -460,7 +460,7 @@ $redirect_template = $params['no_permissions_template']; } else { - $redirect_template = $this->Application->IsAdmin() ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate'); + $redirect_template = $this->Application->isAdmin ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate'); } if ($this->Application->isDebugMode()) { Index: branches/5.0.x/core/units/admin/admin_events_handler.php =================================================================== diff -u -N -r12706 -r12726 --- branches/5.0.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 12706) +++ branches/5.0.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 12726) @@ -1,6 +1,6 @@ Name == 'OnSaveMenuFrameWidth') { - $perm_value = $this->Application->IsAdmin() && $this->Application->LoggedIn(); + $perm_value = $this->Application->isAdminUser; } if (isset($perm_value)) { Index: branches/5.0.x/core/units/fck/fck_eh.php =================================================================== diff -u -N -r12511 -r12726 --- branches/5.0.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 12511) +++ branches/5.0.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 12726) @@ -1,6 +1,6 @@ Application->LoggedIn() && $this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { // this limits all event execution only to logged-in users in admin return true; } Index: branches/5.0.x/core/kernel/event_manager.php =================================================================== diff -u -N -r12525 -r12726 --- branches/5.0.x/core/kernel/event_manager.php (.../event_manager.php) (revision 12525) +++ branches/5.0.x/core/kernel/event_manager.php (.../event_manager.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if ($this->Application->isAdmin) { array_push($all_passed, $prefix_special); } else { @@ -421,7 +421,7 @@ if ($event->status == erPERM_FAIL) { // should do redirect but to no_permissions template - $event->redirect = $this->Application->IsAdmin() ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate'); + $event->redirect = $this->Application->isAdmin ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate'); $event->redirect_params['pass'] = 'm'; $themes_helper =& $this->Application->recallObject('ThemesHelper'); Index: branches/5.0.x/core/kernel/session/inp_session.php =================================================================== diff -u -N -r12399 -r12726 --- branches/5.0.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 12399) +++ branches/5.0.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin() && $special !== 'front') || ($special == 'admin'); + $admin_session = ($this->Application->isAdmin && $special !== 'front') || ($special == 'admin'); if ($admin_session) { $cookie_name = 'adm_' . $cookie_name; @@ -56,7 +56,7 @@ parent::Init($prefix, $special); - if (!$this->Application->IsAdmin() && $this->GetField('PortalUserId') <= 0) { + if (!$this->Application->isAdmin && $this->GetField('PortalUserId') <= 0) { $group_list = $this->Application->ConfigValue('User_GuestGroup').','.$this->Application->ConfigValue('User_LoggedInGroup'); $this->SetField('GroupId', $this->Application->ConfigValue('User_GuestGroup')); $this->SetField('GroupList', $group_list); @@ -114,7 +114,7 @@ function StoreSession(&$session, $additional_fields = Array()) { $fields_hash = Array ( - 'PortalUserId' => $this->Application->IsAdmin() ? 0 : -2, // Guest + 'PortalUserId' => $this->Application->isAdmin ? 0 : -2, // Guest 'Language' => $this->Application->GetDefaultLanguageId(), 'Theme' => $this->Application->GetDefaultThemeId(), 'IpAddress' => $_SERVER['REMOTE_ADDR'], // getenv('REMOTE_ADDR') won't work on IIS, so use $_SERVER instead Index: branches/5.0.x/core/kernel/db/cat_dbitem.php =================================================================== diff -u -N -r12715 -r12726 --- branches/5.0.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 12715) +++ branches/5.0.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 12726) @@ -1,6 +1,6 @@ SetDBField('Modified_date', adodb_mktime() ); $this->SetDBField('Modified_time', adodb_mktime() ); - $is_admin = $this->Application->IsAdmin(); + $is_admin = $this->Application->isAdminUser; $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField'); if (!$owner_field) { Index: branches/5.0.x/core/units/email_events/email_events_event_handler.php =================================================================== diff -u -N -r12466 -r12726 --- branches/5.0.x/core/units/email_events/email_events_event_handler.php (.../email_events_event_handler.php) (revision 12466) +++ branches/5.0.x/core/units/email_events/email_events_event_handler.php (.../email_events_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ GetDBField('FrontEndOnly') && $this->Application->IsAdmin()) { + if ($email_event->GetDBField('FrontEndOnly') && $this->Application->isAdmin) { return false; } Index: branches/5.0.x/core/units/visits/visits_event_handler.php =================================================================== diff -u -N -r12366 -r12726 --- branches/5.0.x/core/units/visits/visits_event_handler.php (.../visits_event_handler.php) (revision 12366) +++ branches/5.0.x/core/units/visits/visits_event_handler.php (.../visits_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin() || !$this->Application->ConfigValue('UseVisitorTracking')) { + if ($this->Application->isAdmin || !$this->Application->ConfigValue('UseVisitorTracking')) { // admin logins are not registred in visits list return true; } Index: branches/5.0.x/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r12666 -r12726 --- branches/5.0.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 12666) +++ branches/5.0.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if (!$this->Application->isAdmin) { if ($event->Name == 'OnSetSortingDirect') { // allow sorting on front event without view permission return true; @@ -306,7 +306,7 @@ $object->addFilter('perm_filter2', $view_filter); } - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { // apply status filter only on front $object->addFilter('status_filter', $object->TableName.'.Status = 1'); } @@ -538,7 +538,7 @@ return $this->_getPassedStructureID($event); } - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { return parent::getPassedID($event); } @@ -593,7 +593,7 @@ $created = $this->_prepareAutoPage($object, $template, null, SMS_MODE_AUTO, false); // create virtual (not system!) page if ($created) { - if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild') || !$this->Application->IsAdmin()) { + if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild') || !$this->Application->isAdmin) { $updater =& $this->Application->recallObject('kPermCacheUpdater'); /* @var $updater kPermCacheUpdater */ @@ -614,7 +614,7 @@ } } - if (!$page_id && !$this->Application->IsAdmin()) { + if (!$page_id && !$this->Application->isAdmin) { $page_id = $this->Application->GetVar('m_cat_id'); } @@ -1220,7 +1220,7 @@ { $this->_beforeItemChange($event); - if ($this->Application->IsAdmin() || $event->Prefix == 'st') { + if ($this->Application->isAdminUser || $event->Prefix == 'st') { // don't check category permissions when auto-creating structure pages return ; } @@ -1247,7 +1247,7 @@ $min_priority = $this->_getNextPriority($object->GetDBField('ParentId'), $object->TableName); $object->SetDBField('Priority', $min_priority); - /*if (!$this->Application->IsAdmin()) { + /*if (!$this->Application->isAdminUser) { $object->SetDBField('IsMenu', 0); // add all suggested categories as non-menu }*/ } @@ -1298,7 +1298,8 @@ { parent::OnCreate($event); - if ($this->Application->IsAdmin() || $event->status != erSUCCESS) { + if ($this->Application->isAdminUser || $event->status != erSUCCESS) { + // don't sent email or rebuild cache directly after category is created by admin return ; } @@ -1330,7 +1331,7 @@ */ function getPerPage(&$event) { - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdmin) { $event->setEventParam('same_special', true); } @@ -1349,7 +1350,7 @@ { parent::SetPagination($event); - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdmin) { $page_var = $event->getEventParam('page_var'); if ($page_var !== false) { $page = $this->Application->GetVar($page_var); @@ -1533,7 +1534,7 @@ $object->SetError('Template', 'no_inherit'); } - if (!$this->Application->IsAdmin() || !$this->Application->LoggedIn()) { + if (!$this->Application->isAdminUser) { // only administrator can set/change "cust_RssSource" field if ($object->GetDBField('cust_RssSource') != $object->GetOriginalField('cust_RssSource')) { @@ -1824,7 +1825,7 @@ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { // don't sort by Front-End sorting fields $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping'); $remove_keys = Array ('DefaultSorting1Field', 'DefaultSorting2Field', 'DefaultSorting1Dir', 'DefaultSorting2Dir'); @@ -1860,7 +1861,8 @@ { parent::OnAfterItemLoad($event); - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdmin) { + // calculate priorities dropdown only for admin return ; } Index: branches/5.0.x/core/kernel/constants.php =================================================================== diff -u -N -r12299 -r12726 --- branches/5.0.x/core/kernel/constants.php (.../constants.php) (revision 12299) +++ branches/5.0.x/core/kernel/constants.php (.../constants.php) (revision 12726) @@ -1,6 +1,6 @@ BaseURL().'core/admin_templates/img/spacer.gif'; define('SPACER_URL', $spacer_url); - if (!$application->IsAdmin()) { + if (!$application->isAdmin) { // don't show debugger buttons on front (if not overrided in "debug.php") safeDefine('DBG_TOOLBAR_BUTTONS', 0); } Index: branches/5.0.x/core/units/helpers/captcha_helper.php =================================================================== diff -u -N -r12368 -r12726 --- branches/5.0.x/core/units/helpers/captcha_helper.php (.../captcha_helper.php) (revision 12368) +++ branches/5.0.x/core/units/helpers/captcha_helper.php (.../captcha_helper.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin() || $this->Application->RecallVar($variable_name)) { + if ($this->Application->isAdmin || $this->Application->RecallVar($variable_name)) { // when code found don't generate it 2nd time return $this->Application->RecallVar($variable_name); } @@ -150,7 +150,7 @@ */ function validateCode(&$event, $check_request = true) { - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdmin) { // no captcha codes in admin return true; } Index: branches/5.0.x/core/kernel/application.php =================================================================== diff -u -N -r12511 -r12726 --- branches/5.0.x/core/kernel/application.php (.../application.php) (revision 12511) +++ branches/5.0.x/core/kernel/application.php (.../application.php) (revision 12726) @@ -1,6 +1,6 @@ InitDone) return false; + if($this->InitDone) { + return false; + } + $this->isAdmin = constOn('ADMIN'); + $this->InitMemcached(); if (!constOn('SKIP_OUT_COMPRESSION')) { @@ -326,7 +346,7 @@ $rewrite_on = $this->ConfigValue('UseModRewrite'); // admin=1 - when front is browsed using admin session - $admin_on = getArrayValue($_REQUEST, 'admin') || $this->IsAdmin(); + $admin_on = getArrayValue($_REQUEST, 'admin') || $this->isAdmin; define('MOD_REWRITE', $rewrite_on && !$admin_on ? 1 : 0); $this->HttpQuery =& $this->recallObject('HTTPQuery'); @@ -465,18 +485,26 @@ function VerifyLanguageId() { $language_id = $this->GetVar('m_lang'); + if (!$language_id) { $language_id = 'default'; } + $this->SetVar('lang.current_id', $language_id ); $this->SetVar('m_lang', $language_id ); $lang_mode = $this->GetVar('lang_mode'); $this->SetVar('lang_mode', ''); + $lang =& $this->recallObject('lang.current'); - if ( !$lang->IsLoaded() || (!$this->Application->IsAdmin() && !$lang->GetDBField('Enabled')) ) { - if (!defined('IS_INSTALL')) $this->ApplicationDie('Unknown or disabled language'); + /* @var $lang kDBItem */ + + if (!$lang->isLoaded() || (!$this->isAdmin && !$lang->GetDBField('Enabled'))) { + if (!defined('IS_INSTALL')) { + $this->ApplicationDie('Unknown or disabled language'); + } } + $this->SetVar('lang_mode',$lang_mode); } @@ -486,7 +514,7 @@ */ function VerifyThemeId() { - if ($this->Application->IsAdmin()) { + if ($this->isAdmin) { safeDefine('THEMES_PATH', '/core/admin_templates'); return; } @@ -567,7 +595,7 @@ if (constOn('DBG_FORCE_THEME')) { $theme_id = DBG_FORCE_THEME; } - elseif (!$force_front && $this->IsAdmin()) { + elseif (!$force_front && $this->isAdmin) { $theme_id = 999; } else { @@ -804,7 +832,7 @@ $this->Debugger->appendMemoryUsage('Application before Run:'); } - if ($this->IsAdmin()) { + if ($this->isAdminUser) { // for permission checking in events & templates $this->LinkVar('module'); // for common configuration templates $this->LinkVar('module_key'); // for common search templates @@ -813,8 +841,6 @@ if ($this->GetVar('m_opener') == 'p') { $this->LinkVar('main_prefix'); // window prefix, that opened selector $this->LinkVar('dst_field'); // field to set value choosed in selector -// $this->LinkVar('return_template'); // template to go, when something was coosen from popup (from finalizePopup) -// $this->LinkVar('return_m'); // main env part to restore after popup will be closed (from finalizePopup) } if ($this->GetVar('ajax') == 'yes' && !$this->GetVar('debug_ajax')) { @@ -844,7 +870,7 @@ $this->InitParser(); $t = $this->GetVar('t'); - if (!$this->TemplatesCache->TemplateExists($t) && !$this->IsAdmin()) { + if (!$this->TemplatesCache->TemplateExists($t) && !$this->isAdmin) { $cms_handler =& $this->recallObject('st_EventHandler'); /* @var $cms_handler CategoriesEventHandler */ @@ -927,7 +953,7 @@ $this->Session->SaveData(); } - if (defined('DBG_CAPTURE_STATISTICS') && DBG_CAPTURE_STATISTICS && !$this->IsAdmin()) { + if (defined('DBG_CAPTURE_STATISTICS') && DBG_CAPTURE_STATISTICS && !$this->isAdmin) { $this->_storeStatistics(); } } @@ -1310,26 +1336,19 @@ */ function HREF($t, $prefix='', $params=null, $index_file=null) { - if(!$t) $t = $this->GetVar('t'); // moved from kMainTagProcessor->T() + if (!$t) { + $t = $this->GetVar('t'); // moved from kMainTagProcessor->T() + } $t = preg_replace('/^Content\//i', '', $t); - - /*if ($this->GetVar('skip_last_template')) { - $params['opener'] = 'p'; - $this->SetVar('m_opener', 'p'); + if (substr($t, -4) == '.tpl') { + $t = substr($t, 0, strlen($t) - 4); } - if ($t == 'incs/close_popup') { - // because this template closes the popup and we don't need popup mark here anymore - $params['m_opener'] = 's'; - }*/ + if ($this->isAdmin && $prefix == '') $prefix = ADMIN_DIRECTORY; + if ($this->isAdmin && $prefix == '_FRONT_END_') $prefix = ''; - if( substr($t, -4) == '.tpl' ) $t = substr($t, 0, strlen($t) - 4 ); - - if ( $this->IsAdmin() && $prefix == '') $prefix = ADMIN_DIRECTORY; - if ( $this->IsAdmin() && $prefix == '_FRONT_END_') $prefix = ''; - $index_file = $this->getIndexFile($prefix, $index_file, $params); if (isset($params['_auto_prefix_'])) { @@ -1952,16 +1971,23 @@ { $session =& $this->recallObject('Session'); $user_id = $session->GetField('PortalUserId'); - if (!$user_id && $user_id != -1) $user_id = -2; + + if (!$user_id && $user_id != -1) { + $user_id = -2; + + } + $this->SetVar('u.current_id', $user_id); - if (!$this->IsAdmin()) { + if (!$this->isAdmin) { // needed for "profile edit", "registration" forms ON FRONT ONLY $this->SetVar('u_id', $user_id); } $this->StoreVar('user_id', $user_id, $user_id == -2); // storing Guest user_id (-2) is optional + $this->isAdminUser = $this->isAdmin && $this->LoggedIn(); + if ($this->GetVar('expired') == 1) { // this parameter is set only from admin $user =& $this->recallObject('u.current'); @@ -1989,7 +2015,7 @@ } function LoadCache() { - $cache_key = $this->GetVar('t').$this->GetVar('m_theme').$this->GetVar('m_lang').$this->IsAdmin(); + $cache_key = $this->GetVar('t').$this->GetVar('m_theme').$this->GetVar('m_lang').$this->isAdmin; $query = sprintf("SELECT PhraseList, ConfigVariables FROM %s WHERE Template = %s", TABLE_PREFIX.'PhraseCache', $this->Conn->qstr(md5($cache_key))); @@ -2017,7 +2043,7 @@ $update = $update || $this->Phrases->NeedsCacheUpdate(); $update = $update || (count($this->ConfigCacheIds) && $this->ConfigCacheIds != $this->Caches['ConfigVariables']); if ($update) { - $cache_key = $this->GetVar('t').$this->GetVar('m_theme').$this->GetVar('m_lang').$this->IsAdmin(); + $cache_key = $this->GetVar('t').$this->GetVar('m_theme').$this->GetVar('m_lang').$this->isAdmin; $query = sprintf("REPLACE %s (PhraseList, CacheDate, Template, ConfigVariables) VALUES (%s, %s, %s, %s)", TABLE_PREFIX.'PhraseCache', @@ -2263,17 +2289,6 @@ } /** - * Checks if it is admin - * - * @return bool - * @author Alex - */ - function IsAdmin() - { - return constOn('ADMIN'); - } - - /** * Apply url rewriting used by mod_rewrite or not * * @param bool $ssl Force ssl link to be build @@ -2628,7 +2643,7 @@ */ function setVisitField($field, $value) { - if ($this->IsAdmin() || !$this->ConfigValue('UseVisitorTracking')) { + if ($this->isAdmin || !$this->ConfigValue('UseVisitorTracking')) { // admin logins are not registred in visits list return ; } Index: branches/5.0.x/core/kernel/utility/formatters/formatter.php =================================================================== diff -u -N -r12117 -r12726 --- branches/5.0.x/core/kernel/utility/formatters/formatter.php (.../formatter.php) (revision 12117) +++ branches/5.0.x/core/kernel/utility/formatters/formatter.php (.../formatter.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin() && isset($options['allow_html']) && $options['allow_html']) { + if (!$this->Application->isAdmin && isset($options['allow_html']) && $options['allow_html']) { // this allows to revert htmlspecialchars call for each field submitted on front-end $value = unhtmlentities($value); } Index: branches/5.0.x/core/units/categories/categories_item.php =================================================================== diff -u -N -r12634 -r12726 --- branches/5.0.x/core/units/categories/categories_item.php (.../categories_item.php) (revision 12634) +++ branches/5.0.x/core/units/categories/categories_item.php (.../categories_item.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin(); + $is_admin = $this->Application->isAdminUser; if ((!$this->IsTempTable() && !$is_admin) || ($is_admin && !$this->GetDBField('CreatedById'))) { $this->SetDBField('CreatedById', $this->Application->RecallVar('user_id')); Index: branches/5.0.x/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r12707 -r12726 --- branches/5.0.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 12707) +++ branches/5.0.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 12726) @@ -1,6 +1,6 @@ getUniqueListKey($params); // check for "admin" variable, because we are parsing front-end template from admin when using template editor feature - if ($this->Application->GetVar('admin') || !$this->Application->IsAdmin()) { + if ($this->Application->GetVar('admin') || !$this->Application->isAdmin) { // add parent category to special, when on Front-End, // because there can be many category lists on same page $list_unique_key .= $parent_cat_id; @@ -1539,7 +1539,7 @@ { $template = $this->Application->GetVar('t'); - if (!$this->Application->TemplatesCache->TemplateExists($template) && !$this->Application->IsAdmin()) { + if (!$this->Application->TemplatesCache->TemplateExists($template) && !$this->Application->isAdmin) { $cms_handler =& $this->Application->recallObject($this->Prefix . '_EventHandler'); /* @var $cms_handler CategoriesEventHandler */ Index: branches/5.0.x/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r12644 -r12726 --- branches/5.0.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 12644) +++ branches/5.0.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if (!$this->Application->isAdmin) { $allow_events = Array('OnSearch', 'OnSearchReset', 'OnNew'); if (in_array($event->Name, $allow_events)) { // allow search on front @@ -98,7 +98,7 @@ } if ($event->Name == 'OnSaveWidths') { - return $this->Application->IsAdmin() && $this->Application->LoggedIn(); + return $this->Application->isAdminUser; } return parent::CheckPermission($event); @@ -517,7 +517,7 @@ $status_checked = true; $editing_mode = defined('EDITING_MODE') ? EDITING_MODE : false; - if ($user_id != -1 && !$this->Application->IsAdmin() && !($editing_mode || $this->checkItemStatus($event))) { + if ($user_id != -1 && !$this->Application->isAdmin && !($editing_mode || $this->checkItemStatus($event))) { // non-root user AND on front-end AND (not editing mode || incorrect status) $perm_status = false; } @@ -532,7 +532,7 @@ $this->Application->Debugger->appendTrace(); } trigger_error('ItemLoad Permission Failed for prefix ['.$event->getPrefixSpecial().'] in '.($status_checked ? 'checkItemStatus' : 'CheckPermission').'', E_USER_WARNING); - $next_template = $this->Application->IsAdmin() ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate'); + $next_template = $this->Application->isAdmin ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate'); $this->Application->Redirect($next_template, Array('next_template' => $this->Application->GetVar('t'))); } } @@ -2460,7 +2460,7 @@ */ function OnSuggestValues(&$event) { - if (!$this->Application->IsAdmin() || !$this->Application->LoggedIn()) { + if (!$this->Application->isAdminUser) { // very careful here, because this event allows to // view every object field -> limit only to logged-in admins return ; Index: branches/5.0.x/core/kernel/db/cat_event_handler.php =================================================================== diff -u -N -r12666 -r12726 --- branches/5.0.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 12666) +++ branches/5.0.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 12726) @@ -1,6 +1,6 @@ Application->IsAdmin()) { + if (!$this->Application->isAdmin) { if ($event->Name == 'OnSetSortingDirect') { // allow sorting on front event without view permission return true; @@ -673,7 +673,7 @@ } } - /*if ( !$this->Application->IsAdmin() ) { + /*if (!$this->Application->isAdminUser) { $object->addFilter('expire_filter', '%1$s.Expire IS NULL OR %1$s.Expire > UNIX_TIMESTAMP()'); }*/ @@ -722,7 +722,7 @@ // Link1 (before modifications) [Status = 1, OrgId = NULL], Link2 (after modifications) [Status = -2, OrgId = Link1_ID] $pending_editing = $this->Application->getUnitOption($object->Prefix, 'UsePendingEditing'); - if ( !$this->Application->IsAdmin() ) { + if (!$this->Application->isAdminUser) { $types = explode(',', $types); if (in_array('my_items', $types)) { $allow_statuses = Array (STATUS_ACTIVE, STATUS_PENDING, STATUS_PENDING_EDITING); @@ -872,7 +872,7 @@ $object =& $event->getObject(); /* @var $object kCatDBItem */ - if( $this->Application->IsAdmin() && ($this->Application->GetVar($click_field.'_original') !== false) && + if( $this->Application->isAdminUser && ($this->Application->GetVar($click_field.'_original') !== false) && floor($this->Application->GetVar($click_field.'_original')) != $object->GetDBField($click_field) ) { $sql = 'SELECT MAX('.$click_field.') FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' @@ -953,7 +953,7 @@ $this->setCustomExportColumns($event); } - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $object =& $event->getObject(); /* @var $object kDBItem */ @@ -987,7 +987,7 @@ $this->setCustomExportColumns($event); } - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdminUser) { $object =& $event->getObject(); /* @var $object kDBItem */ @@ -2183,7 +2183,8 @@ */ function OnBeforeItemCreate(&$event) { - if ($this->Application->IsAdmin()) { + if ($this->Application->isAdminUser) { + // don't set permission-based status, when creating categories in admin return true; } @@ -2278,7 +2279,7 @@ function OnUpdate(&$event) { $use_pending = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); - if ($this->Application->IsAdmin() || !$use_pending) { + if ($this->Application->isAdminUser || !$use_pending) { parent::OnUpdate($event); $this->SetFrontRedirectTemplate($event, 'modify'); return ; @@ -2370,7 +2371,7 @@ */ function SetFrontRedirectTemplate(&$event, $template_key) { - if ($this->Application->IsAdmin() || $event->status != erSUCCESS) { + if ($this->Application->isAdminUser || $event->status != erSUCCESS) { return ; } @@ -2454,7 +2455,7 @@ { parent::OnDelete($event); - if ($event->status == erSUCCESS && !$this->Application->IsAdmin()) { + if ($event->status == erSUCCESS && !$this->Application->isAdmin) { $event->SetRedirectParam('pass', 'm'); $event->SetRedirectParam('m_cat_id', 0); } @@ -2496,7 +2497,7 @@ */ function SetSorting(&$event) { - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdmin) { $event->setEventParam('same_special', true); } @@ -2511,7 +2512,7 @@ */ function getPerPage(&$event) { - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdmin) { $event->setEventParam('same_special', true); }