Index: trunk/admin/reviews.php =================================================================== diff -u -N -r3184 -r4243 --- trunk/admin/reviews.php (.../reviews.php) (revision 3184) +++ trunk/admin/reviews.php (.../reviews.php) (revision 4243) @@ -13,8 +13,6 @@ ## privileges along maximum prosecution allowed by law. ## ############################################################## -//KERNEL4 STARTUP - FOR ACTIONS HANDLING - function k4getmicrotime() { list($usec, $sec) = explode(" ", microtime()); @@ -23,22 +21,17 @@ $start = k4getmicrotime(); -define('ADMIN', 1); -define('FULL_PATH', realpath(dirname(__FILE__).'/..')); -define('APPLICATION_CLASS', 'MyApplication'); -include_once(FULL_PATH."/kernel/kernel4/startup.php"); +// new startup: begin +define('REL_PATH', 'admin'); +$relation_level = count( explode('/', REL_PATH) ); +define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) ); +require_once FULL_PATH.'/kernel/startup.php'; +// new startup: end -$application =& kApplication::Instance(); -$application->Init(); -$application->ProcessRequest(); - -//KERNEL4 END - define('REQUIRE_LAYER_HEADER', 1); $b_topmargin = "0"; //$b_header_addon = "

"; -require_once FULL_PATH.'/kernel/startup.php'; require_login(); $indexURL = $rootURL."index.php"; Index: trunk/kernel/include/usersession.php =================================================================== diff -u -N -r3983 -r4243 --- trunk/kernel/include/usersession.php (.../usersession.php) (revision 3983) +++ trunk/kernel/include/usersession.php (.../usersession.php) (revision 4243) @@ -32,7 +32,7 @@ $this->adodbConnection = &GetADODBConnection(); $this->PermCache = array(); - $this->PermCacheGroups =""; + $this->PermCacheGroups = ''; $this->UseTempKeys = $TempKeys; $this->AdminSearchFields = array("UserName", "GroupName", "us.IpAddress"); @@ -772,86 +772,98 @@ } } - function SetSysPermCache() - { + function SetSysPermCache() + { unset($this->SysPermCache); - $GroupList = $this->Get("GroupList"); + $GroupList = $this->Get('GroupList'); - if(strlen($GroupList) && $GroupList !="0") - { - $this->SysPermCache = array(); - $sql = "SELECT * FROM ".GetTablePrefix()."Permissions WHERE Type=1 AND GroupId IN (".$GroupList.")"; - //echo $sql."
\n"; - $rs = $this->adodbConnection->Execute($sql); - - while($rs && !$rs->EOF) - { - $val = $rs->fields["PermissionValue"]; - //if($val==1) - $this->SysPermCache[$rs->fields["Permission"]] = $val; - $PermList[] = $rs->fields["Permission"]; - $rs->MoveNext(); - } - if( isset($PermList) && count($PermList) > 0) // I think this is never issued (comment by Alex) - $this->SetVariable("SysPerm",implode(",",$PermList)); + if ($GroupList && $GroupList != '0') { + $this->SysPermCache = Array(); + $sql = 'SELECT * + FROM '.GetTablePrefix().'Permissions + WHERE Type = 1 AND GroupId IN ('.$GroupList.')'; // AND PermissionValue = 1'; + + $rs = $this->adodbConnection->Execute($sql); + + $PermList = Array(); + while (!$rs->EOF) { + $this->SysPermCache[ $rs->fields['Permission'] ] = $rs->fields['PermissionValue']; + $PermList[] = $rs->fields['Permission']; + $rs->MoveNext(); + } + + if ($PermList) { + $this->SetVariable('SysPerm', implode(',', $PermList)); + } } } + /** + * Fills system permission cache in session (memory only, not db) + * + */ function GetSysPermCache() { - $perms = trim($this->GetVariable("SysPerm")); - if(!strlen($perms)) - { + $perms = trim($this->GetVariable('SysPerm')); + if (!$perms) { $this->SetSysPermCache(); } - else - { - $p = explode(",",$perms); - - $this->SysPermCache = array(); - for($i=0;$iSysPermCache = Array(); + for($i = 0; $i < count($p); $i++) { $n = $p[$i]; - $this->SysPermCache[$n]=1; + $this->SysPermCache[$n] = 1; } } } + /** + * Allows to detect if system permissions are loaded + * + * @return bool + */ function SysPermCacheLoaded() { - return (isset($this->SysPermCache)); + return isset($this->SysPermCache); } + /** + * Resets system permission cache + * + */ function ResetSysPermCache() { - // echo "Resetting Perm Cache
\n"; - $this->SetVariable("SysPerm",""); + $this->SetVariable('SysPerm', ''); unset($this->SysPermCache); - //$this->SysPermCache=array(); } function HasSystemPermission($PermissionName) { global $objGroups; - if($this->Get("PortalUserId")==-1 && ($PermissionName=="ADMIN" || $PermissionName=="LOGIN")) - return TRUE; - //echo "Looking up $PermissionName:".$this->Get("GroupList")."
\n"; - //echo $this->Get("GroupList")." - ".$this->PermCacheGroups; - $GroupList = $this->Get("GroupList"); - if(substr($GroupList,-1)==",") - { - $GroupList = substr($GroupList,0,-1); - $this->Set("GroupList",$GroupList); + // "root" is always allowed to login to admin + if ($this->Get('PortalUserId') == -1 && ($PermissionName == 'ADMIN' || $PermissionName == 'LOGIN') ) { + return true; } - //print_pre( $GroupList); - if($this->Get("GroupList")!=$this->PermCacheGroups) - $this->ResetSysPermCache(); - if(!$this->SysPermCacheLoaded()) - { - //echo "Loading Perm Cache
\n"; + + // cut last comma (just in case in-portal made a mistake before) + $GroupList = $this->Get('GroupList'); + if (substr($GroupList, -1) == ',') { + $GroupList = substr($GroupList, 0, -1); + $this->Set('GroupList', $GroupList); + } + + // if loaded permissions are from other group list, then current (e.g. user is become logged-in during script run) + if ($this->Get('GroupList') != $this->PermCacheGroups) { + $this->ResetSysPermCache(); + } + + // load system permission cache if not already loaded + if (!$this->SysPermCacheLoaded()) { $this->GetSysPermCache(); - $this->PermCacheGroups = $this->Get("GroupList"); + $this->PermCacheGroups = $this->Get('GroupList'); } //echo "SysPerm $PermissionName: [". $this->SysPermCache[$PermissionName]."]
\n"; return isset($this->SysPermCache[$PermissionName]) ? $this->SysPermCache[$PermissionName] == 1 : false; Index: trunk/admin/include/sections.php =================================================================== diff -u -N -r4199 -r4243 --- trunk/admin/include/sections.php (.../sections.php) (revision 4199) +++ trunk/admin/include/sections.php (.../sections.php) (revision 4243) @@ -93,9 +93,10 @@ { global $rootURL, $m_var_list_update; - if (!$this->IsJavaScriptLink()) { - $m_var_list_update['opener'] = 'r'; - if ($this->IsKernel4Link()) { + if(!$this->IsJavaScriptLink()) + { + $m_var_list_update['opener']='r'; + if ( $this->IsKernel4Link() ) { global $var_list_update; $stack_t = isset($var_list_update['t']) ? $var_list_update['t'] : null; $var_list_update['t'] = $this->Get('file'); Index: trunk/kernel/admin_templates/incs/script.js =================================================================== diff -u -N -r4199 -r4243 --- trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 4199) +++ trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 4243) @@ -1,5 +1,4 @@ -if( !( isset($init_made) && $init_made ) ) -{ +if ( !( isset($init_made) && $init_made ) ) { var Grids = new Array(); var Toolbars = new Array(); var $Menus = new Array(); @@ -11,8 +10,64 @@ var submitted = false; var $edit_mode = false; var $init_made = true; // in case of double inclusion of script.js :) + + // hook processing + var hBEFORE = 1; // this is const, but including this twice causes errors + var hAFTER = 2; // this is const, but including this twice causes errors + var $hooks = new Array(); } +function getArrayValue() +{ + var $value = arguments[0]; + var $current_key = 0; + $i = 1; + while ($i < arguments.length) { + $current_key = arguments[$i]; + if (isset($value[$current_key])) { + $value = $value[$current_key]; + } + else { + return false; + } + $i++; + } + return $value; +} + +function setArrayValue() +{ + // first argument - array, other arguments - keys (arrays too), last argument - value + var $array = arguments[0]; + var $current_key = 0; + $i = 1; + while ($i < arguments.length - 1) { + $current_key = arguments[$i]; + if (!isset($array[$current_key])) { + $array[$current_key] = new Array(); + } + $array = $array[$current_key]; + $i++; + } + $array[$array.length] = arguments[arguments.length - 1]; +} + +function processHooks($function_name, $hook_type) +{ + var $i = 0; + var $local_hooks = getArrayValue($hooks, $function_name, $hook_type); + + while($i < $local_hooks.length) { + $local_hooks[$i]($function_name); + $i++; + } +} + +function registerHook($function_name, $hook_type, $hook_body) +{ + setArrayValue($hooks, $function_name, $hook_type, $hook_body); +} + function resort_grid(prefix_special,field,form_action) { set_hidden_field(prefix_special+'_Sort1', field); @@ -255,7 +310,7 @@ if(!isset($width)) $width=750; if(!isset($height)) $height=400; if(!isset($event)) $event=''; - + processHooks('openSelector', hBEFORE); cur_opener = get_hidden_field('m_opener'); set_hidden_field('m_opener','p'); @@ -265,6 +320,7 @@ var old_action = document.kernel_form.action; document.kernel_form.action = $url; submit_event($prefix,$event,$t); + processHooks('openSelector', hAFTER); document.kernel_form.action = old_action; set_hidden_field('m_opener',cur_opener); } @@ -723,12 +779,53 @@ { var $src_html = $aSelect.options[$src_num].innerHTML; var $dst_html = $aSelect.options[$dst_num].innerHTML; - - var $src_option = new Option($aSelect.options[$src_num].innerHTML, $aSelect.options[$src_num].value); - $src_option.innerHTML = $src_html; - var $dst_option = new Option($aSelect.options[$dst_num].innerHTML, $aSelect.options[$dst_num].value); + var $src_value = $aSelect.options[$src_num].value; + var $dst_value = $aSelect.options[$dst_num].value; + + var $src_option = document.createElement('OPTION'); + var $dst_option = document.createElement('OPTION'); + + $aSelect.remove($src_num); + $aSelect.options.add($dst_option, $src_num); + $dst_option.innerText = $dst_html; + $dst_option.value = $dst_value; $dst_option.innerHTML = $dst_html; - - $aSelect.options[$src_num] = $dst_option; - $aSelect.options[$dst_num] = $src_option; - } \ No newline at end of file + + $aSelect.remove($dst_num); + $aSelect.options.add($src_option, $dst_num); + $src_option.innerText = $src_html; + $src_option.value = $src_value; + $src_option.innerHTML = $src_html; + } + + function getXMLHTTPObject() + { + var http_request = false; + if (window.XMLHttpRequest) { // Mozilla, Safari,... + http_request = new XMLHttpRequest(); + if (http_request.overrideMimeType) { + http_request.overrideMimeType('text/plain'); + // See note below about this line + } + } else if (window.ActiveXObject) { // IE + try { + http_request = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + http_request = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) {} + } + } + return http_request; + } + + function str_repeat($symbol, $count) + { + var $i = 0; + var $ret = ''; + while($i < $count) { + $ret += $symbol; + $i++; + } + return $ret; + } Index: trunk/admin/advanced_view.php =================================================================== diff -u -N -r3184 -r4243 --- trunk/admin/advanced_view.php (.../advanced_view.php) (revision 3184) +++ trunk/admin/advanced_view.php (.../advanced_view.php) (revision 4243) @@ -13,8 +13,6 @@ ## privileges along maximum prosecution allowed by law. ## ############################################################## -//KERNEL4 STARTUP - FOR ACTIONS HANDLING - function k4getmicrotime() { list($usec, $sec) = explode(" ", microtime()); @@ -23,23 +21,17 @@ $start = k4getmicrotime(); -define('ADMIN', 1); -define('FULL_PATH', realpath(dirname(__FILE__).'/..')); -define('APPLICATION_CLASS', 'MyApplication'); -include_once(FULL_PATH."/kernel/kernel4/startup.php"); +// new startup: begin +define('REL_PATH', 'admin'); +$relation_level = count( explode('/', REL_PATH) ); +define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) ); +require_once FULL_PATH.'/kernel/startup.php'; +// new startup: end -$application =& kApplication::Instance(); -$application->Init(); -$application->ProcessRequest(); - -//KERNEL4 END - define('REQUIRE_LAYER_HEADER', 1); $b_topmargin = "0"; //$b_header_addon = "

"; -require_once(FULL_PATH.'/kernel/startup.php'); - require_login(); $indexURL = $rootURL."index.php"; Index: trunk/admin/install/langpacks/english.lang =================================================================== diff -u -N -r4199 -r4243 --- trunk/admin/install/langpacks/english.lang (.../english.lang) (revision 4199) +++ trunk/admin/install/langpacks/english.lang (.../english.lang) (revision 4243) @@ -247,6 +247,7 @@ U3VnZ2VzdCB0byBhIGZyaWVuZA== VXNlciB1bnN1YnNjcmliZWQ= VmFsaWRhdGUgVXNlcg== + QW4gZXJyb3IgaGFzIG9jY3VyZWQgZHVyaW5nIGV4cG9ydC4= QWR2YW5jZWQgQ1NT QXV0b21hdGljIEZpbGVuYW1l QXZhaWxhYmxlIENvbHVtbnM= @@ -359,6 +360,7 @@ VGhpcyBoZWxwIHNlY3Rpb24gZG9lcyBub3QgeWV0IGV4aXN0LCBpdCdzIGNvbWluZyBzb29uIQ== aHRtbA== SUQgRmllbGQ= + QW4gZXJyb3IgaGFzIG9jY3VyZWQgZHVyaW5nIGltcG9ydC4= SW1wb3J0aW5nIEVtYWlsIEV2ZW50cyAuLi4= SW1wb3J0aW5nIExhbmd1YWdlcyAuLi4= SW1wb3J0aW5nIFBocmFzZXMgLi4u @@ -374,6 +376,7 @@ S0I= TGFuZ3VhZ2U= SW1wb3J0IHByb2dyZXNz + TGFzdCBSZXNwb25jZQ== TGFzdCBVcGRhdGVk RGF0ZQ== TGluayBEZXNjcmlwdGlvbg== @@ -1439,6 +1442,8 @@ WW91ciBsaW5rIGhhcyBiZWVuIGFkZGVkIHBlbmRpbmcgYWRtaW5pc3RyYXRpdmUgYXBwcm92YWwu VGhlIGxpbmsgeW91IGhhdmUgc3VnZ2VzdGVkIGhhcyBiZWVuIGFkZGVkIHRvIHRoZSBkYXRhYmFzZS4= QWRkcmVzcw== + QWRkcmVzcyBMaW5lIDE= + QWRkcmVzcyBMaW5lIDI= QWRkIEZyaWVuZA== QWRkIExpbms= U2VuZCBQcml2YXRlIE1lc3NhZ2U= @@ -1922,14 +1927,17 @@ cG9zdHMgdXBkYXRlZA== UG93ZXJlZCBieQ== Q2l0eQ== + Q29tcGFueQ== Q291bnRyeQ== QmlydGhkYXRl RS1tYWls + RmF4 Rmlyc3QgTmFtZQ== TGFzdCBOYW1l UGhvbmU= U3RhdGU= U3RyZWV0 + U3RyZWV0IDI= Wmlw UHJpdmFjeQ== UHJpdmF0ZSBtZXNzYWdlcyB1cGRhdGVk Index: trunk/core/units/general/cat_dbitem_export.php =================================================================== diff -u -N -r4085 -r4243 --- trunk/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4085) +++ trunk/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4243) @@ -1,7 +1,7 @@ cacheTable = TABLE_PREFIX.'ImportCache'; + } + /** * Returns value from cache if found or false otherwise * @@ -61,12 +77,48 @@ * @param int $key * @param mixed $value */ - function addToCache($type, $key, $value) + function addToCache($type, $key, $value, $is_new = true) { // if (!isset($this->cache[$type])) $this->cache[$type] = Array(); $this->cache[$type][$key] = $value; + if ($is_new) { + $this->cacheStatus[$type][$key] = true; + } } + function storeCache($cache_types) + { + $cache_types = explode(',', $cache_types); + + $values_sql = ''; + foreach ($cache_types as $cache_type) { + $sql_mask = '('.$this->Conn->qstr($cache_type).',%s,%s),'; + $cache = getArrayValue($this->cacheStatus, $cache_type); + if (!$cache) $cache = Array(); + foreach ($cache as $var_name => $cache_status) { + $var_value = $this->cache[$cache_type][$var_name]; + $values_sql .= sprintf($sql_mask, $this->Conn->qstr($var_name), $this->Conn->qstr($var_value) ); + } + } + $values_sql = preg_replace('/(.*),$/', '\\1', $values_sql); + if ($values_sql) { + $sql = 'INSERT INTO '.$this->cacheTable.'(`CacheName`,`VarName`,`VarValue`) VALUES '.$values_sql; + $this->Conn->Query($sql); + } + + } + + function loadCache() + { + $sql = 'SELECT * FROM '.$this->cacheTable; + $records = $this->Conn->Query($sql); + + $this->cache = Array(); + foreach ($records as $record) { + $this->addToCache($record['CacheName'], $record['VarName'], $record['VarValue'], false); + } + } + /** * Fill required fields with dummy values * @@ -146,7 +198,7 @@ if ($event->Special == 'import') { - $this->exportOptions = unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); + $this->exportOptions = $this->loadOptions($event); $automatic_fields = ($object->GetDBField('FieldTitles') == 1); $object->setRequired('ExportColumns', !$automatic_fields); @@ -238,6 +290,7 @@ } } } + $this->saveOptions($event); } return $ret; @@ -369,7 +422,7 @@ */ function performExport(&$event) { - $this->exportOptions = unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); + $this->exportOptions = $this->loadOptions($event); $this->exportFields = $this->exportOptions['ExportColumns']; $this->curItem =& $event->getObject( Array('skip_autoload' => true) ); @@ -421,7 +474,7 @@ $this->closeFile(); $this->exportOptions['start_from'] += $records_exported; - $this->Application->StoreVar($event->getPrefixSpecial().'_options', serialize($this->exportOptions) ); + $this->saveOptions($event); return $this->exportOptions; } @@ -460,7 +513,7 @@ { if (!$this->exportOptions) { // load import options in case if not previously loaded in verification function - $this->exportOptions = unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); + $this->exportOptions = $this->loadOptions($event); } $backup_category_id = $this->Application->GetVar('m_cat_id'); @@ -489,8 +542,9 @@ $this->exportOptions['total_records'] = filesize($this->getImportFilename()); } else { - $this->cache['new_ids'] = $this->exportOptions['new_ids_hash']; + $this->loadCache(); } + $this->exportFields = $this->exportOptions['ExportColumns']; $this->addToCache('category_parent_path', $this->Application->GetVar('m_cat_id'), $this->exportOptions['ImportCategoryPath']); @@ -515,9 +569,14 @@ $this->Application->SetVar('m_cat_id', $backup_category_id); $this->exportOptions['start_from'] += $bytes_imported; - $this->exportOptions['new_ids_hash'] = getArrayValue($this->cache, 'new_ids'); - $this->Application->StoreVar($event->getPrefixSpecial().'_options', serialize($this->exportOptions) ); + $this->storeCache('new_ids'); + $this->saveOptions($event); + + if ($this->exportOptions['start_from'] == $this->exportOptions['total_records']) { + $this->Conn->Query('TRUNCATE TABLE '.$this->cacheTable); + } + return $this->exportOptions; } @@ -532,7 +591,7 @@ $value = null; } - $field_name = $this->exportFields[$field_index]; + $field_name = getArrayValue($this->exportFields, $field_index); if ($field_name == 'ResourceId') { return false; } @@ -541,12 +600,15 @@ $field_name = 'cust_'.substr($field_name, 7); $this->curItem->SetField($field_name, $value); } - elseif ($field_name == 'CategoryPath') { + elseif ($field_name == 'CategoryPath' || $field_name == '__CATEGORY__CategoryPath') { $this->curItem->CategoryPath = $value ? explode($this->exportOptions['CategorySeparator'], $value) : Array(); } elseif (substr($field_name, 0, 8) == 'Category') { - $this->curItem->CategoryPath[ (int)substr($field_name, 8) ] = $value; + $this->curItem->CategoryPath[ (int)substr($field_name, 8) - 1 ] = $value; } + elseif (substr($field_name, 0, 20) == '__CATEGORY__Category') { + $this->curItem->CategoryPath[ (int)substr($field_name, 20) ] = $value; + } elseif (substr($field_name, 0, 11) == '__VIRTUAL__') { $field_name = substr($field_name, 11); $this->curItem->SetField($field_name, $value); @@ -588,6 +650,61 @@ $this->setCurrentID(); } + + function getItemCategory() + { + $backup_category_id = $this->Application->GetVar('m_cat_id'); + + $category_id = $this->getFromCache('category_names', implode(':', $this->curItem->CategoryPath)); + if ($category_id) { + $this->Application->SetVar('m_cat_id', $category_id); + return $category_id; + } + + foreach ($this->curItem->CategoryPath as $category_index => $category_name) { + if (!$category_name) continue; + $category_key = crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); + + $category_id = $this->getFromCache('category_names', $category_key); + if ($category_id === false) { + // get parent category path to search only in it + $current_category_id = $this->Application->GetVar('m_cat_id'); +// $parent_path = $this->getParentPath($current_category_id); + + // get category id from database by name + $sql = 'SELECT CategoryId + FROM '.TABLE_PREFIX.'Category + WHERE (Name = '.$this->Conn->qstr($category_name).') AND (ParentId = '.$current_category_id.')'; + $category_id = $this->Conn->GetOne($sql); + + if ($category_id === false) { + // category not in db -> create + $category_fields = Array( 'Name' => $category_name, 'Description' => $category_name, + 'Status' => STATUS_ACTIVE, 'ParentId' => $current_category_id, 'AutomaticFilename' => 1 + ); + $this->dummyCategory->SetDBFieldsFromHash($category_fields); + if ($this->dummyCategory->Create()) { + $category_id = $this->dummyCategory->GetID(); + $this->addToCache('category_parent_path', $category_id, $this->dummyCategory->GetDBField('ParentPath')); + $this->addToCache('category_names', $category_key, $category_id); + } + } + else { + $this->addToCache('category_names', $category_key, $category_id); + } + } + + if ($category_id) { + $this->Application->SetVar('m_cat_id', $category_id); + } + } + if (!$this->curItem->CategoryPath) { + $category_id = $backup_category_id; + } + + return $category_id; + } + /** * Enter description here... * @@ -596,10 +713,15 @@ function processCurrentItem(&$event, $record_data) { $save_method = 'Create'; + $load_keys = Array(); + + // create/update categories + $backup_category_id = $this->Application->GetVar('m_cat_id'); + // perform replace duplicates code if ($this->exportOptions['ReplaceDuplicates']) { // get replace keys first, then reset current item to empty one - $load_keys = Array(); + $category_id = $this->getItemCategory(); if ($this->exportOptions['CheckDuplicatesMethod'] == 1) { if ($this->curItem->GetID()) { $load_keys = Array($this->curItem->IDField => $this->curItem->GetID()); @@ -621,7 +743,7 @@ } $where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause); - $item_id = $this->getFromCache('new_ids', $where_clause); + $item_id = $this->getFromCache('new_ids', crc32($where_clause)); if (!$item_id) { if ($this->exportOptions['CheckDuplicatesMethod'] == 2) { // by other fields @@ -643,64 +765,24 @@ } else { $this->resetImportObject($event, IMPORT_LIVE, $record_data); + $category_id = $this->getItemCategory(); } - // create/update categories - $backup_category_id = $this->Application->GetVar('m_cat_id'); - - foreach ($this->curItem->CategoryPath as $category_index => $category_name) { - if (!$category_name) continue; - $category_key = crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); - - $category_id = $this->getFromCache('category_names', $category_key); - if ($category_id === false) { - // get parent category path to search only in it - $current_category_id = $this->Application->GetVar('m_cat_id'); - $parent_path = $this->getParentPath($current_category_id); - - // get category id from database by name - $sql = 'SELECT CategoryId - FROM '.TABLE_PREFIX.'Category - WHERE (Name = '.$this->Conn->qstr($category_name).') AND (ParentPath LIKE "'.$parent_path.'%")'; - $category_id = $this->Conn->GetOne($sql); - - if ($category_id === false) { - // category not in db -> create - $category_fields = Array( 'Name' => $category_name, 'Description' => $category_name, - 'Status' => STATUS_ACTIVE, 'ParentId' => $current_category_id, 'AutomaticFilename' => 1 - ); - $this->dummyCategory->SetDBFieldsFromHash($category_fields); - if ($this->dummyCategory->Create()) { - $category_id = $this->dummyCategory->GetID(); - $this->addToCache('category_parent_path', $category_id, $this->dummyCategory->GetDBField('ParentPath')); - $this->addToCache('category_names', $category_key, $category_id); - } - } - else { - $this->addToCache('category_names', $category_key, $category_id); - } - } - - if ($category_id) { - $this->Application->SetVar('m_cat_id', $category_id); - } - } - if (!$this->curItem->CategoryPath) { - $category_id = $backup_category_id; - } - // create main record if ($save_method == 'Create') { $this->fillRequiredFields($this->false, $this->curItem, true); } +// $sql_start = getmicrotime(); if (!$this->curItem->$save_method()) { return false; } +// $sql_end = getmicrotime(); +// $this->saveLog('SQL ['.$save_method.'] Time: '.($sql_end - $sql_start).'s'); if ($load_keys && ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates']) { // map new id to old id - $this->addToCache('new_ids', $where_clause, $this->curItem->GetID() ); + $this->addToCache('new_ids', crc32($where_clause), $this->curItem->GetID() ); } // assign item to categories @@ -709,7 +791,14 @@ $this->Application->SetVar('m_cat_id', $backup_category_id); return true; } - + + /*function saveLog($msg) + { + $fp = fopen(FULL_PATH.'/sqls.log', 'a'); + fwrite($fp, $msg."\n"); + fclose($fp); + }*/ + /** * Returns category parent path, if possible, then from cache * @@ -929,6 +1018,19 @@ { return fgetcsv($this->filePointer, 10000, $this->exportOptions['FieldsSeparatedBy'], $this->exportOptions['FieldsEnclosedBy']); } + + function saveOptions(&$event, $options = null) + { + if (!isset($options)) { + $options = $this->exportOptions; + } + $this->Application->StoreVar($event->getPrefixSpecial().'_options', serialize($options) ); + } + + function loadOptions(&$event) + { + return unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); + } } ?> Index: trunk/core/units/general/cat_event_handler.php =================================================================== diff -u -N -r4231 -r4243 --- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4231) +++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4243) @@ -1323,13 +1323,15 @@ if (!$items_info) { $items_info = unserialize( $this->Application->RecallVar($event->getPrefixSpecial().'_ItemsInfo') ); + $this->Application->SetVar($event->getPrefixSpecial(true), $items_info); } list($item_id, $field_values) = each($items_info); $object =& $event->getObject( Array('skip_autoload' => true) ); $object->SetFieldsFromHash($field_values); $field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! + $object->setID($item_id); $this->setRequiredFields($event); @@ -1348,77 +1350,42 @@ $field_values['ExportColumns'] = $field_values['ExportColumns'] ? explode('|', substr($field_values['ExportColumns'], 1, -1) ) : Array(); $field_values['start_from'] = 0; - $this->Application->StoreVar($event->getPrefixSpecial().'_options', serialize($field_values) ); - + $export_object->saveOptions($event, $field_values); + if( $export_object->verifyOptions($event) ) { - $this->doExport($event); + $event->redirect = $this->getModuleFolder($event).'/'.$event->Special.'_progress'; + } else { + // make uploaded file local & change source selection + $filename = getArrayValue($field_values, 'ImportFilename'); + if ($filename) { + $this->updateImportFiles($event); + $object->SetDBField('ImportSource', 2); + $field_values['ImportSource'] = 2; + $object->SetDBField('ImportLocalFilename', $filename); + $field_values['ImportLocalFilename'] = $filename; + $export_object->saveOptions($event, $field_values); + } + $event->status = erFAIL; $event->redirect = false; } } - + /** * Enter description here... * * @param kEvent $event */ - function doExport(&$event) + function OnExportCancel(&$event) { - if ($event->Name == 'OnExportBegin') - { - $done_percent = 0; - } - else { - $export_options = unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); - $done_percent = round($export_options['start_from'] * 100 / $export_options['total_records'], 0); - } - - $block_params = Array( 'name' => $this->getModuleFolder($event).'/'.$event->Special.'_progress', - 'percent_done' => $done_percent, - 'percent_left' => 100 - $done_percent); - - $this->Application->InitParser(); - $this->Application->setUnitOption($event->Prefix, 'AutoLoad', false); - echo $this->Application->ParseBlock($block_params); - flush(); - - $export_object =& $this->Application->recallObject('CatItemExportHelper'); - - $action_method = 'perform'.ucfirst($event->Special); - $field_values = $export_object->$action_method($event); - - if ($field_values['start_from'] == $field_values['total_records']) - { - if ($event->Special == 'import') { - $this->Application->StoreVar('PermCache_UpdateRequired', 1); - $event->SetRedirectParam('index_file', 'category/category_maint.php'); - } - else { - $event->redirect = $this->getModuleFolder($event).'/'.$event->Special.'_finish'; - } - } - else { - $event->redirect = $this->getModuleFolder($event).'/'.$event->Special.'_progress'; - $redirect_params = Array($event->getPrefixSpecial().'_event' => 'OnExportProgress', 'pass' => 'm,'.$event->getPrefixSpecial(), 'rand' => rand(0,1000000)); - $event->setRedirectParams($redirect_params); - } + $this->OnGoBack($event); } - + /** - * Next export steps - * - * @param kEvent $event - */ - function OnExportProgress(&$event) - { - $this->doExport($event); - } - - /** * Sets correct available & export fields * * @param kEvent $event @@ -1487,25 +1454,39 @@ $options['options'] = $available_columns; $object->SetFieldOptions('AvailableColumns', $options); - if ($event->Special == 'import') - { - $import_filenames = Array(); + $this->updateImportFiles($event); + } - if ($folder_handle = opendir(EXPORT_PATH)) { - while (false !== ($file = readdir($folder_handle))) { - if (is_dir(EXPORT_PATH.'/'.$file) || substr($file, 0, 1) == '.' || strtolower($file) == 'cvs' || strtolower($file) == 'dummy' || filesize(EXPORT_PATH.'/'.$file) == 0) continue; + /** + * Updates uploaded files list + * + * @param kEvent $event + */ + function updateImportFiles(&$event) + { + if ($event->Special != 'import') { + return false; + } + + $object =& $event->getObject(); + + $import_filenames = Array(); - $file_size = formatSize( filesize(EXPORT_PATH.'/'.$file) ); - $import_filenames[$file] = $file.' ('.$file_size.')'; - } - closedir($folder_handle); + if ($folder_handle = opendir(EXPORT_PATH)) { + while (false !== ($file = readdir($folder_handle))) { + if (is_dir(EXPORT_PATH.'/'.$file) || substr($file, 0, 1) == '.' || strtolower($file) == 'cvs' || strtolower($file) == 'dummy' || filesize(EXPORT_PATH.'/'.$file) == 0) continue; + + $file_size = formatSize( filesize(EXPORT_PATH.'/'.$file) ); + $import_filenames[$file] = $file.' ('.$file_size.')'; } - $options = $object->GetFieldOptions('ImportLocalFilename'); - $options['options'] = $import_filenames; - $object->SetFieldOptions('ImportLocalFilename', $options); + closedir($folder_handle); } + + $options = $object->GetFieldOptions('ImportLocalFilename'); + $options['options'] = $import_filenames; + $object->SetFieldOptions('ImportLocalFilename', $options); } - + /** * Returns specific to each item type columns only * @@ -1710,6 +1691,15 @@ $event->redirect = false; $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); if ($items_info) { + list($id, $field_values) = each($items_info); + + $object =& $event->getObject( Array('skip_autoload' => true) ); + $object->SetFieldsFromHash($field_values); + $field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! + $field_values['ImportSource'] = 2; + $field_values['ImportLocalFilename'] = $object->GetDBField('ImportFilename'); + $items_info[$id] = $field_values; + $this->Application->StoreVar($event->getPrefixSpecial().'_ItemsInfo', serialize($items_info)); } } Index: trunk/globals.php =================================================================== diff -u -N -r4199 -r4243 --- trunk/globals.php (.../globals.php) (revision 4199) +++ trunk/globals.php (.../globals.php) (revision 4243) @@ -1551,30 +1551,6 @@ if($SFValue == 1 || $SFValue == 2) $list->Clear(); } -if( !function_exists('getArrayValue') ) -{ - /** - * Returns array value if key exists - * - * @param Array $array searchable array - * @param int $key array key - * @return string - * @access public - */ - // - function getArrayValue(&$array,$key) - { - $ret = isset($array[$key]) ? $array[$key] : false; - if ($ret && func_num_args() > 2) { - for ($i = 2; $i < func_num_args(); $i++) { - $cur_key = func_get_arg($i); - $ret = getArrayValue( $ret, $cur_key ); - if ($ret === false) break; - } - } - return $ret; - } -} function MakeHTMLTag($element, $attrib_prefix) { $result = Array(); @@ -1956,21 +1932,6 @@ header('Location: '.$adminURL.'/index.php?'.$redirect_params); exit; } - - if( !function_exists('safeDefine') ) - { - /** - * Define constant if it was not already defined before - * - * @param string $const_name - * @param string $const_value - * @access public - */ - function safeDefine($const_name, $const_value) - { - if(!defined($const_name)) define($const_name,$const_value); - } - } /** * Builds up K4 url from data supplied by in-portal @@ -2022,20 +1983,6 @@ return $ret; } - if( !function_exists('constOn') ) - { - /** - * Checks if constant is defined and has positive value - * - * @param string $const_name - * @return bool - */ - function constOn($const_name) - { - return defined($const_name) && constant($const_name); - } - } - function &recallObject($var_name, $class_name) { if (!isset($GLOBALS[$var_name]) || !is_object($GLOBALS[$var_name])) Index: trunk/admin/install/inportal_schema.sql =================================================================== diff -u -N -r4237 -r4243 --- trunk/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 4237) +++ trunk/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 4243) @@ -694,6 +694,16 @@ KEY AffiliateId (AffiliateId) ) # -------------------------------------------------------- +CREATE TABLE ImportCache ( + CacheId int(11) NOT NULL auto_increment, + CacheName varchar(255) NOT NULL default '', + VarName int(11) NOT NULL default '0', + VarValue text NOT NULL, + PRIMARY KEY (CacheId), + KEY CacheName (CacheName), + KEY VarName (VarName) +) +# -------------------------------------------------------- CREATE TABLE PortalUserCustomData ( CustomDataId int(11) NOT NULL auto_increment, ResourceId int(10) unsigned NOT NULL default '0', Index: trunk/core/units/categories/categories_item.php =================================================================== diff -u -N -r3787 -r4243 --- trunk/core/units/categories/categories_item.php (.../categories_item.php) (revision 3787) +++ trunk/core/units/categories/categories_item.php (.../categories_item.php) (revision 4243) @@ -55,7 +55,7 @@ $sql = 'SELECT ParentPath FROM '.$cat_table.' WHERE CategoryId = %s'; $parent_path = $this->Conn->GetOne( sprintf($sql, $parent_id) ); - if(!$parent_path) $parent_path = '|'.$parent_id.'|'; + if(!$parent_path && $parent_id) $parent_path = '|'.$parent_id.'|'; return $parent_path.$this->GetID().'|'; } Index: trunk/admin/install/upgrades/inportal_upgrade_v1.1.7.sql =================================================================== diff -u -N -r3983 -r4243 --- trunk/admin/install/upgrades/inportal_upgrade_v1.1.7.sql (.../inportal_upgrade_v1.1.7.sql) (revision 3983) +++ trunk/admin/install/upgrades/inportal_upgrade_v1.1.7.sql (.../inportal_upgrade_v1.1.7.sql) (revision 4243) @@ -13,4 +13,8 @@ UPDATE Language SET InputDateFormat = 'm/d/Y', InputTimeFormat = 'g:i:s A'; +CREATE TABLE ImportCache (CacheId int(11) NOT NULL auto_increment, CacheName varchar(255) NOT NULL default '', VarName int(11) NOT NULL default '0', VarValue text NOT NULL, PRIMARY KEY (CacheId), KEY CacheName (CacheName), KEY VarName (VarName)); + +DELETE FROM Permissions WHERE Type = 1 AND PermissionValue = 0; + UPDATE Modules SET Version = '1.1.7' WHERE Name = 'In-Portal'; \ No newline at end of file Index: trunk/admin/browse.php =================================================================== diff -u -N -r3648 -r4243 --- trunk/admin/browse.php (.../browse.php) (revision 3648) +++ trunk/admin/browse.php (.../browse.php) (revision 4243) @@ -13,8 +13,6 @@ ## privileges along maximum prosecution allowed by law. ## ############################################################## -//KERNEL4 STARTUP - FOR ACTIONS HANDLING - function k4getmicrotime() { list($usec, $sec) = explode(" ", microtime()); @@ -23,24 +21,19 @@ $start = k4getmicrotime(); -define('ADMIN', 1); -define('FULL_PATH', realpath(dirname(__FILE__).'/..')); -define('APPLICATION_CLASS', 'MyApplication'); -include_once(FULL_PATH."/kernel/kernel4/startup.php"); +// new startup: begin +define('REL_PATH', 'admin'); +$relation_level = count( explode('/', REL_PATH) ); +define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) ); +require_once FULL_PATH.'/kernel/startup.php'; +// new startup: end -$application =& kApplication::Instance(); -$application->Init(); -$application->ProcessRequest(); if($application->GetVar('Action') == 'm_paste') define('REDIRECT_REQUIRED',1); // this script can issue redirect header -//KERNEL4 END - define('REQUIRE_LAYER_HEADER', 1); $b_topmargin = "0"; //$b_header_addon = "

"; -require_once FULL_PATH.'/kernel/startup.php'; - require_login(); $indexURL = $rootURL."index.php"; Index: trunk/kernel/units/config_general/config_general_tag_processor.php =================================================================== diff -u -N -r3723 -r4243 --- trunk/kernel/units/config_general/config_general_tag_processor.php (.../config_general_tag_processor.php) (revision 3723) +++ trunk/kernel/units/config_general/config_general_tag_processor.php (.../config_general_tag_processor.php) (revision 4243) @@ -54,20 +54,21 @@ } } - $block_params['current'] = 1; $block_params['separator'] = $params['separator']; - if($params['cat_id'] == 0) - { + if ($params['cat_id'] == 0) { $block_params['name'] = $params['rootcatblock']; return $this->Application->ParseBlock($block_params); } - else - { + else { $cat_object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List' ); $sql = 'SELECT CategoryId, ParentId, Name FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$params['cat_id']; $res = $this->Conn->GetRow($sql); + if ($res === false) { + // in case if category is deleted + return ''; + } $block_params['name'] = $params['block']; $block_params['cat_name'] = $res['Name']; $block_params['separator'] = $params['separator']; Index: trunk/core/units/general/cat_tag_processor.php =================================================================== diff -u -N -r3827 -r4243 --- trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 3827) +++ trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 4243) @@ -63,7 +63,10 @@ $cat_object =& $this->Application->recallObject('c', 'c_List'); $sql = 'SELECT CategoryId, ParentId, Name FROM '.$cat_object->TableName.' WHERE CategoryId = '.$params['cat_id']; $res = $this->Conn->GetRow($sql); - + if ($res === false) { + // in case if category is deleted + return ''; + } $block_params['name'] = $params['block']; $block_params['cat_name'] = $res['Name']; $block_params['cat_id'] = $res['CategoryId']; @@ -100,7 +103,31 @@ $special = crc32($parent_cat_id.$types.$except.$recursive); return $special; - } + } + + function ExportStatus($params) + { + define('DBG_SKIP_REPORTING', 1); + + $export_object =& $this->Application->recallObject('CatItemExportHelper'); + + $event = new kEvent($this->getPrefixSpecial().':OnDummy'); + + $action_method = 'perform'.ucfirst($this->Special); + $field_values = $export_object->$action_method($event); + + // finish code is done from JS now + if ($field_values['start_from'] == $field_values['total_records']) + { + if ($this->Special == 'import') { + $this->Application->StoreVar('PermCache_UpdateRequired', 1); + } + } + + $export_options = $export_object->loadOptions($event); + return $export_options['start_from'] * 100 / $export_options['total_records']; + } + } ?> \ No newline at end of file Index: trunk/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r3723 -r4243 --- trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 3723) +++ trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 4243) @@ -142,7 +142,11 @@ $sql = 'SELECT CategoryId, ParentId, Name FROM '.$this->Application->getUnitOption($this->Prefix, 'TableName').' WHERE CategoryId='.$params['cat_id']; $res = $this->Conn->GetRow($sql); - + if ($res === false) { + // in case if category is deleted + return ''; + } + $block_params['cat_name'] = $res['Name']; $block_params['cat_id'] = $res['CategoryId']; Index: trunk/admin/email/sendmail.php =================================================================== diff -u -N -r2853 -r4243 --- trunk/admin/email/sendmail.php (.../sendmail.php) (revision 2853) +++ trunk/admin/email/sendmail.php (.../sendmail.php) (revision 4243) @@ -52,7 +52,7 @@ int_header($objListToolBar); -if(count(explode(",",$recip_ids))>1) +if(count(explode(",",$recip_ids))>1 || $_POST["idtype"] == 'group') { $action = "email_multi_send"; } Index: trunk/kernel/include/portalgroup.php =================================================================== diff -u -N -r3983 -r4243 --- trunk/kernel/include/portalgroup.php (.../portalgroup.php) (revision 3983) +++ trunk/kernel/include/portalgroup.php (.../portalgroup.php) (revision 4243) @@ -45,38 +45,38 @@ } /* set $Value to -1 to delete the permission row from the DB */ - function SetSystemPermission($PermName,$Value) + function SetSystemPermission($PermName, $Value) { - //echo "Setting $PermName to $Value
\n"; - $oldval = $this->HasSystemPermission($PermName); - if($Value != $oldval) - { - if($Value>-1) - { - if($oldval>-1) - { - $sql = "UPDATE ".GetTablePrefix()."Permissions SET PermissionValue=$Value "; - $sql .=" WHERE Type=1 AND Permission='$PermName' AND GroupId=".$this->Get("GroupId"); - - //echo "UPDATE SQL: $sql
"; - } - else - { - $sql = "INSERT INTO ".GetTablePrefix()."Permissions (Permission, GroupId, PermissionValue, Type, CatId) "; - $sql .="VALUES ('$PermName',".$this->Get("GroupId").",$Value,1,0)"; - //echo "INSERT SQL: $sql
"; - } - $this->adodbConnection->Execute($sql); - //echo $sql."
\n"; - } - else - { - $sql = "DELETE FROM ".GetTablePrefix()."Permissions "; - $sql .=" WHERE Type=1 AND Permission='$PermName' AND GroupId=".$this->Get("GroupId"); - //echo "DELETE SQL: $sql
"; - $this->adodbConnection->Execute($sql); + // don't save DENY system permissions + + //echo "Setting $PermName to $Value
\n"; + $old_value = $this->HasSystemPermission($PermName); + if ($Value == $old_value) { + return true; } - } + + if ($Value == 1) { + // new value is ALLOWED + if ($old_value > -1) { + // old value is ALLOWED/DENIED + $sql = 'UPDATE '.GetTablePrefix().'Permissions + SET PermissionValue = '.$Value.' + WHERE Type = 1 AND Permission = '.$this->adodbConnection->qstr($PermName).' AND GroupId = '.$this->Get('GroupId'); + } + else { + // permission was inherited before => no record in db + $sql = 'INSERT INTO '.GetTablePrefix().'Permissions (Permission, GroupId, PermissionValue, Type, CatId) '; + $sql .= 'VALUES ('.$this->adodbConnection->qstr($PermName).','.$this->Get('GroupId').','.$Value.',1,0)'; + } + $this->adodbConnection->Execute($sql); + } + else { + // permission becomes inherited now or set to DENIED + $sql = 'DELETE FROM '.GetTablePrefix().'Permissions + WHERE Type = 1 AND Permission = '.$this->adodbConnection->qstr($PermName).' AND GroupId = '.$this->Get('GroupId'); + $this->adodbConnection->Execute($sql); + } + } function CheckPermission($permissionName) Index: trunk/admin/install/upgrades/readme_1_1_7.txt =================================================================== diff -u -N -r3889 -r4243 --- trunk/admin/install/upgrades/readme_1_1_7.txt (.../readme_1_1_7.txt) (revision 3889) +++ trunk/admin/install/upgrades/readme_1_1_7.txt (.../readme_1_1_7.txt) (revision 4243) @@ -1,5 +1,13 @@ -0011144 search log record is created/updated when simple search is made from onlinestore theme -0011217 error message was not shown on search form (on front, default theme) -0011210 custom field values were not stripslashed after submit -0011209 mod_rewrite now works a bit faster -0011211 category sorting in admin in case when we have non-editor pics new categories and already edited ones \ No newline at end of file +Readme notes for In-Portal 1.1.7 +Intechnic Corporation, April 4, 2006 + +New features: + - Import/Export progress bars are now using AJAX technology to allow smooth progress bar display and eliminate possible browser redirection limit error when importing or exporting large databases + +Bug fixes: + - Logging of advanced searche queries + - Error message was not displayed on the quick search form in default theme + - Special characaters, quotes and slashes handling for custom fields were handled incorrectly + - Incorrect category sorting in administrative console after creating new non editor pick category + - Incorrect group permissions treating when user is a member of two or more groups and the groups have different settings for the same permission + - Standard error messages were hardcoded in english Index: trunk/kernel/action.php =================================================================== diff -u -N -r4124 -r4243 --- trunk/kernel/action.php (.../action.php) (revision 4124) +++ trunk/kernel/action.php (.../action.php) (revision 4243) @@ -206,32 +206,29 @@ break; case "m_group_sysperm": if($ro_perm) break; - if($_POST["GroupEditStatus"]==0) - { + if ($_POST["GroupEditStatus"] == 0) { $objSession->ResetSysPermCache(); - $GroupId = $_POST["GroupId"]; - if($GroupId) - { + $GroupId = $_POST['GroupId']; + if ($GroupId) { $objEditItems = new clsGroupList(); - $objEditItems->SourceTable = $objSession->GetEditTable("PortalGroup"); - $g = $objEditItems->GetItemByField("ResourceId",$GroupId); - if(is_object($g)) - { - - $PermList = explode(",",$_POST["PermList"]); - for($i=0;$iSourceTable = $objSession->GetEditTable('PortalGroup'); + $g = $objEditItems->GetItemByField('ResourceId', $GroupId); + if (is_object($g)) { + $PermList = explode(',', $_POST['PermList']); + $inheritance = GetVar('inherit') ? GetVar('inherit') : Array(); + $permission_values = GetVar('permvalue') ? GetVar('permvalue') : Array(); + for($i = 0; $i < count($PermList); $i++) { + if (@in_array($PermList[$i], $inheritance)) { $value = -1; } - else - { + else { $value = 0; - if(@in_array($PermList[$i],$_POST["permvalue"])) - $value = 1; + if (@in_array($PermList[$i], $permission_values)) { + $value = 1; + } } - $g->SetSystemPermission($PermList[$i],$value); + + $g->SetSystemPermission($PermList[$i], $value); } } } Index: trunk/kernel/units/general/cat_dbitem_export.php =================================================================== diff -u -N -r4085 -r4243 --- trunk/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4085) +++ trunk/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4243) @@ -1,7 +1,7 @@ cacheTable = TABLE_PREFIX.'ImportCache'; + } + /** * Returns value from cache if found or false otherwise * @@ -61,12 +77,48 @@ * @param int $key * @param mixed $value */ - function addToCache($type, $key, $value) + function addToCache($type, $key, $value, $is_new = true) { // if (!isset($this->cache[$type])) $this->cache[$type] = Array(); $this->cache[$type][$key] = $value; + if ($is_new) { + $this->cacheStatus[$type][$key] = true; + } } + function storeCache($cache_types) + { + $cache_types = explode(',', $cache_types); + + $values_sql = ''; + foreach ($cache_types as $cache_type) { + $sql_mask = '('.$this->Conn->qstr($cache_type).',%s,%s),'; + $cache = getArrayValue($this->cacheStatus, $cache_type); + if (!$cache) $cache = Array(); + foreach ($cache as $var_name => $cache_status) { + $var_value = $this->cache[$cache_type][$var_name]; + $values_sql .= sprintf($sql_mask, $this->Conn->qstr($var_name), $this->Conn->qstr($var_value) ); + } + } + $values_sql = preg_replace('/(.*),$/', '\\1', $values_sql); + if ($values_sql) { + $sql = 'INSERT INTO '.$this->cacheTable.'(`CacheName`,`VarName`,`VarValue`) VALUES '.$values_sql; + $this->Conn->Query($sql); + } + + } + + function loadCache() + { + $sql = 'SELECT * FROM '.$this->cacheTable; + $records = $this->Conn->Query($sql); + + $this->cache = Array(); + foreach ($records as $record) { + $this->addToCache($record['CacheName'], $record['VarName'], $record['VarValue'], false); + } + } + /** * Fill required fields with dummy values * @@ -146,7 +198,7 @@ if ($event->Special == 'import') { - $this->exportOptions = unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); + $this->exportOptions = $this->loadOptions($event); $automatic_fields = ($object->GetDBField('FieldTitles') == 1); $object->setRequired('ExportColumns', !$automatic_fields); @@ -238,6 +290,7 @@ } } } + $this->saveOptions($event); } return $ret; @@ -369,7 +422,7 @@ */ function performExport(&$event) { - $this->exportOptions = unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); + $this->exportOptions = $this->loadOptions($event); $this->exportFields = $this->exportOptions['ExportColumns']; $this->curItem =& $event->getObject( Array('skip_autoload' => true) ); @@ -421,7 +474,7 @@ $this->closeFile(); $this->exportOptions['start_from'] += $records_exported; - $this->Application->StoreVar($event->getPrefixSpecial().'_options', serialize($this->exportOptions) ); + $this->saveOptions($event); return $this->exportOptions; } @@ -460,7 +513,7 @@ { if (!$this->exportOptions) { // load import options in case if not previously loaded in verification function - $this->exportOptions = unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); + $this->exportOptions = $this->loadOptions($event); } $backup_category_id = $this->Application->GetVar('m_cat_id'); @@ -489,8 +542,9 @@ $this->exportOptions['total_records'] = filesize($this->getImportFilename()); } else { - $this->cache['new_ids'] = $this->exportOptions['new_ids_hash']; + $this->loadCache(); } + $this->exportFields = $this->exportOptions['ExportColumns']; $this->addToCache('category_parent_path', $this->Application->GetVar('m_cat_id'), $this->exportOptions['ImportCategoryPath']); @@ -515,9 +569,14 @@ $this->Application->SetVar('m_cat_id', $backup_category_id); $this->exportOptions['start_from'] += $bytes_imported; - $this->exportOptions['new_ids_hash'] = getArrayValue($this->cache, 'new_ids'); - $this->Application->StoreVar($event->getPrefixSpecial().'_options', serialize($this->exportOptions) ); + $this->storeCache('new_ids'); + $this->saveOptions($event); + + if ($this->exportOptions['start_from'] == $this->exportOptions['total_records']) { + $this->Conn->Query('TRUNCATE TABLE '.$this->cacheTable); + } + return $this->exportOptions; } @@ -532,7 +591,7 @@ $value = null; } - $field_name = $this->exportFields[$field_index]; + $field_name = getArrayValue($this->exportFields, $field_index); if ($field_name == 'ResourceId') { return false; } @@ -541,12 +600,15 @@ $field_name = 'cust_'.substr($field_name, 7); $this->curItem->SetField($field_name, $value); } - elseif ($field_name == 'CategoryPath') { + elseif ($field_name == 'CategoryPath' || $field_name == '__CATEGORY__CategoryPath') { $this->curItem->CategoryPath = $value ? explode($this->exportOptions['CategorySeparator'], $value) : Array(); } elseif (substr($field_name, 0, 8) == 'Category') { - $this->curItem->CategoryPath[ (int)substr($field_name, 8) ] = $value; + $this->curItem->CategoryPath[ (int)substr($field_name, 8) - 1 ] = $value; } + elseif (substr($field_name, 0, 20) == '__CATEGORY__Category') { + $this->curItem->CategoryPath[ (int)substr($field_name, 20) ] = $value; + } elseif (substr($field_name, 0, 11) == '__VIRTUAL__') { $field_name = substr($field_name, 11); $this->curItem->SetField($field_name, $value); @@ -588,6 +650,61 @@ $this->setCurrentID(); } + + function getItemCategory() + { + $backup_category_id = $this->Application->GetVar('m_cat_id'); + + $category_id = $this->getFromCache('category_names', implode(':', $this->curItem->CategoryPath)); + if ($category_id) { + $this->Application->SetVar('m_cat_id', $category_id); + return $category_id; + } + + foreach ($this->curItem->CategoryPath as $category_index => $category_name) { + if (!$category_name) continue; + $category_key = crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); + + $category_id = $this->getFromCache('category_names', $category_key); + if ($category_id === false) { + // get parent category path to search only in it + $current_category_id = $this->Application->GetVar('m_cat_id'); +// $parent_path = $this->getParentPath($current_category_id); + + // get category id from database by name + $sql = 'SELECT CategoryId + FROM '.TABLE_PREFIX.'Category + WHERE (Name = '.$this->Conn->qstr($category_name).') AND (ParentId = '.$current_category_id.')'; + $category_id = $this->Conn->GetOne($sql); + + if ($category_id === false) { + // category not in db -> create + $category_fields = Array( 'Name' => $category_name, 'Description' => $category_name, + 'Status' => STATUS_ACTIVE, 'ParentId' => $current_category_id, 'AutomaticFilename' => 1 + ); + $this->dummyCategory->SetDBFieldsFromHash($category_fields); + if ($this->dummyCategory->Create()) { + $category_id = $this->dummyCategory->GetID(); + $this->addToCache('category_parent_path', $category_id, $this->dummyCategory->GetDBField('ParentPath')); + $this->addToCache('category_names', $category_key, $category_id); + } + } + else { + $this->addToCache('category_names', $category_key, $category_id); + } + } + + if ($category_id) { + $this->Application->SetVar('m_cat_id', $category_id); + } + } + if (!$this->curItem->CategoryPath) { + $category_id = $backup_category_id; + } + + return $category_id; + } + /** * Enter description here... * @@ -596,10 +713,15 @@ function processCurrentItem(&$event, $record_data) { $save_method = 'Create'; + $load_keys = Array(); + + // create/update categories + $backup_category_id = $this->Application->GetVar('m_cat_id'); + // perform replace duplicates code if ($this->exportOptions['ReplaceDuplicates']) { // get replace keys first, then reset current item to empty one - $load_keys = Array(); + $category_id = $this->getItemCategory(); if ($this->exportOptions['CheckDuplicatesMethod'] == 1) { if ($this->curItem->GetID()) { $load_keys = Array($this->curItem->IDField => $this->curItem->GetID()); @@ -621,7 +743,7 @@ } $where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause); - $item_id = $this->getFromCache('new_ids', $where_clause); + $item_id = $this->getFromCache('new_ids', crc32($where_clause)); if (!$item_id) { if ($this->exportOptions['CheckDuplicatesMethod'] == 2) { // by other fields @@ -643,64 +765,24 @@ } else { $this->resetImportObject($event, IMPORT_LIVE, $record_data); + $category_id = $this->getItemCategory(); } - // create/update categories - $backup_category_id = $this->Application->GetVar('m_cat_id'); - - foreach ($this->curItem->CategoryPath as $category_index => $category_name) { - if (!$category_name) continue; - $category_key = crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); - - $category_id = $this->getFromCache('category_names', $category_key); - if ($category_id === false) { - // get parent category path to search only in it - $current_category_id = $this->Application->GetVar('m_cat_id'); - $parent_path = $this->getParentPath($current_category_id); - - // get category id from database by name - $sql = 'SELECT CategoryId - FROM '.TABLE_PREFIX.'Category - WHERE (Name = '.$this->Conn->qstr($category_name).') AND (ParentPath LIKE "'.$parent_path.'%")'; - $category_id = $this->Conn->GetOne($sql); - - if ($category_id === false) { - // category not in db -> create - $category_fields = Array( 'Name' => $category_name, 'Description' => $category_name, - 'Status' => STATUS_ACTIVE, 'ParentId' => $current_category_id, 'AutomaticFilename' => 1 - ); - $this->dummyCategory->SetDBFieldsFromHash($category_fields); - if ($this->dummyCategory->Create()) { - $category_id = $this->dummyCategory->GetID(); - $this->addToCache('category_parent_path', $category_id, $this->dummyCategory->GetDBField('ParentPath')); - $this->addToCache('category_names', $category_key, $category_id); - } - } - else { - $this->addToCache('category_names', $category_key, $category_id); - } - } - - if ($category_id) { - $this->Application->SetVar('m_cat_id', $category_id); - } - } - if (!$this->curItem->CategoryPath) { - $category_id = $backup_category_id; - } - // create main record if ($save_method == 'Create') { $this->fillRequiredFields($this->false, $this->curItem, true); } +// $sql_start = getmicrotime(); if (!$this->curItem->$save_method()) { return false; } +// $sql_end = getmicrotime(); +// $this->saveLog('SQL ['.$save_method.'] Time: '.($sql_end - $sql_start).'s'); if ($load_keys && ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates']) { // map new id to old id - $this->addToCache('new_ids', $where_clause, $this->curItem->GetID() ); + $this->addToCache('new_ids', crc32($where_clause), $this->curItem->GetID() ); } // assign item to categories @@ -709,7 +791,14 @@ $this->Application->SetVar('m_cat_id', $backup_category_id); return true; } - + + /*function saveLog($msg) + { + $fp = fopen(FULL_PATH.'/sqls.log', 'a'); + fwrite($fp, $msg."\n"); + fclose($fp); + }*/ + /** * Returns category parent path, if possible, then from cache * @@ -929,6 +1018,19 @@ { return fgetcsv($this->filePointer, 10000, $this->exportOptions['FieldsSeparatedBy'], $this->exportOptions['FieldsEnclosedBy']); } + + function saveOptions(&$event, $options = null) + { + if (!isset($options)) { + $options = $this->exportOptions; + } + $this->Application->StoreVar($event->getPrefixSpecial().'_options', serialize($options) ); + } + + function loadOptions(&$event) + { + return unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); + } } ?> Index: trunk/admin/index4.php =================================================================== diff -u -N -r3216 -r4243 --- trunk/admin/index4.php (.../index4.php) (revision 3216) +++ trunk/admin/index4.php (.../index4.php) (revision 4243) @@ -17,8 +17,7 @@ $end = getmicrotime(); -if ( constOn('DEBUG_MODE') ) -{ +if ($application->isDebugMode() && !dbg_ConstOn('DBG_SKIP_REPORTING')) { echo '

Index: trunk/kernel/units/general/cat_event_handler.php =================================================================== diff -u -N -r4231 -r4243 --- trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4231) +++ trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4243) @@ -1323,13 +1323,15 @@ if (!$items_info) { $items_info = unserialize( $this->Application->RecallVar($event->getPrefixSpecial().'_ItemsInfo') ); + $this->Application->SetVar($event->getPrefixSpecial(true), $items_info); } list($item_id, $field_values) = each($items_info); $object =& $event->getObject( Array('skip_autoload' => true) ); $object->SetFieldsFromHash($field_values); $field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! + $object->setID($item_id); $this->setRequiredFields($event); @@ -1348,77 +1350,42 @@ $field_values['ExportColumns'] = $field_values['ExportColumns'] ? explode('|', substr($field_values['ExportColumns'], 1, -1) ) : Array(); $field_values['start_from'] = 0; - $this->Application->StoreVar($event->getPrefixSpecial().'_options', serialize($field_values) ); - + $export_object->saveOptions($event, $field_values); + if( $export_object->verifyOptions($event) ) { - $this->doExport($event); + $event->redirect = $this->getModuleFolder($event).'/'.$event->Special.'_progress'; + } else { + // make uploaded file local & change source selection + $filename = getArrayValue($field_values, 'ImportFilename'); + if ($filename) { + $this->updateImportFiles($event); + $object->SetDBField('ImportSource', 2); + $field_values['ImportSource'] = 2; + $object->SetDBField('ImportLocalFilename', $filename); + $field_values['ImportLocalFilename'] = $filename; + $export_object->saveOptions($event, $field_values); + } + $event->status = erFAIL; $event->redirect = false; } } - + /** * Enter description here... * * @param kEvent $event */ - function doExport(&$event) + function OnExportCancel(&$event) { - if ($event->Name == 'OnExportBegin') - { - $done_percent = 0; - } - else { - $export_options = unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); - $done_percent = round($export_options['start_from'] * 100 / $export_options['total_records'], 0); - } - - $block_params = Array( 'name' => $this->getModuleFolder($event).'/'.$event->Special.'_progress', - 'percent_done' => $done_percent, - 'percent_left' => 100 - $done_percent); - - $this->Application->InitParser(); - $this->Application->setUnitOption($event->Prefix, 'AutoLoad', false); - echo $this->Application->ParseBlock($block_params); - flush(); - - $export_object =& $this->Application->recallObject('CatItemExportHelper'); - - $action_method = 'perform'.ucfirst($event->Special); - $field_values = $export_object->$action_method($event); - - if ($field_values['start_from'] == $field_values['total_records']) - { - if ($event->Special == 'import') { - $this->Application->StoreVar('PermCache_UpdateRequired', 1); - $event->SetRedirectParam('index_file', 'category/category_maint.php'); - } - else { - $event->redirect = $this->getModuleFolder($event).'/'.$event->Special.'_finish'; - } - } - else { - $event->redirect = $this->getModuleFolder($event).'/'.$event->Special.'_progress'; - $redirect_params = Array($event->getPrefixSpecial().'_event' => 'OnExportProgress', 'pass' => 'm,'.$event->getPrefixSpecial(), 'rand' => rand(0,1000000)); - $event->setRedirectParams($redirect_params); - } + $this->OnGoBack($event); } - + /** - * Next export steps - * - * @param kEvent $event - */ - function OnExportProgress(&$event) - { - $this->doExport($event); - } - - /** * Sets correct available & export fields * * @param kEvent $event @@ -1487,25 +1454,39 @@ $options['options'] = $available_columns; $object->SetFieldOptions('AvailableColumns', $options); - if ($event->Special == 'import') - { - $import_filenames = Array(); + $this->updateImportFiles($event); + } - if ($folder_handle = opendir(EXPORT_PATH)) { - while (false !== ($file = readdir($folder_handle))) { - if (is_dir(EXPORT_PATH.'/'.$file) || substr($file, 0, 1) == '.' || strtolower($file) == 'cvs' || strtolower($file) == 'dummy' || filesize(EXPORT_PATH.'/'.$file) == 0) continue; + /** + * Updates uploaded files list + * + * @param kEvent $event + */ + function updateImportFiles(&$event) + { + if ($event->Special != 'import') { + return false; + } + + $object =& $event->getObject(); + + $import_filenames = Array(); - $file_size = formatSize( filesize(EXPORT_PATH.'/'.$file) ); - $import_filenames[$file] = $file.' ('.$file_size.')'; - } - closedir($folder_handle); + if ($folder_handle = opendir(EXPORT_PATH)) { + while (false !== ($file = readdir($folder_handle))) { + if (is_dir(EXPORT_PATH.'/'.$file) || substr($file, 0, 1) == '.' || strtolower($file) == 'cvs' || strtolower($file) == 'dummy' || filesize(EXPORT_PATH.'/'.$file) == 0) continue; + + $file_size = formatSize( filesize(EXPORT_PATH.'/'.$file) ); + $import_filenames[$file] = $file.' ('.$file_size.')'; } - $options = $object->GetFieldOptions('ImportLocalFilename'); - $options['options'] = $import_filenames; - $object->SetFieldOptions('ImportLocalFilename', $options); + closedir($folder_handle); } + + $options = $object->GetFieldOptions('ImportLocalFilename'); + $options['options'] = $import_filenames; + $object->SetFieldOptions('ImportLocalFilename', $options); } - + /** * Returns specific to each item type columns only * @@ -1710,6 +1691,15 @@ $event->redirect = false; $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); if ($items_info) { + list($id, $field_values) = each($items_info); + + $object =& $event->getObject( Array('skip_autoload' => true) ); + $object->SetFieldsFromHash($field_values); + $field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! + $field_values['ImportSource'] = 2; + $field_values['ImportLocalFilename'] = $object->GetDBField('ImportFilename'); + $items_info[$id] = $field_values; + $this->Application->StoreVar($event->getPrefixSpecial().'_ItemsInfo', serialize($items_info)); } } Index: trunk/core/kernel/globals.php =================================================================== diff -u -N -r4216 -r4243 --- trunk/core/kernel/globals.php (.../globals.php) (revision 4216) +++ trunk/core/kernel/globals.php (.../globals.php) (revision 4243) @@ -37,51 +37,51 @@ return $return; } - if (!function_exists('print_pre')) { - /** - * Same as print_r, budet designed for viewing in web page - * - * @param Array $data - * @param string $label - */ - function print_pre($data, $label='') + /** + * Same as print_r, budet designed for viewing in web page + * + * @param Array $data + * @param string $label + */ + function print_pre($data, $label='') + { + $is_debug = false; + if (class_exists('kApplication')) { + $application =& kApplication::Instance(); + $is_debug = $application->isDebugMode(); + } + + if ($is_debug) { + if ($label) $application->Debugger->appendHTML(''.$label.''); + $application->Debugger->dumpVars($data); + } + else { - if( constOn('DEBUG_MODE') ) - { - global $debugger; - if($label) $debugger->appendHTML(''.$label.''); - $debugger->dumpVars($data); - } - else - { - if($label) echo '',$label,'
'; - echo '
',print_r($data,true),'
'; - } + if ($label) echo '', $label, '
'; + echo '
', print_r($data, true), '
'; } } - if (!function_exists('getArrayValue')) { - /** - * Returns array value if key exists - * - * @param Array $array searchable array - * @param int $key array key - * @return string - * @access public - */ - // - function getArrayValue(&$array,$key) - { - $ret = isset($array[$key]) ? $array[$key] : false; - if ($ret && func_num_args() > 2) { - for ($i = 2; $i < func_num_args(); $i++) { - $cur_key = func_get_arg($i); - $ret = getArrayValue( $ret, $cur_key ); - if ($ret === false) break; - } + /** + * Returns array value if key exists + * + * @param Array $array searchable array + * @param int $key array key + * @return string + * @access public + */ + // + function getArrayValue(&$array, $key) + { + $ret = isset($array[$key]) ? $array[$key] : false; + if ($ret && func_num_args() > 2) { + for ($i = 2; $i < func_num_args(); $i++) { + $cur_key = func_get_arg($i); + $ret = getArrayValue( $ret, $cur_key ); + if ($ret === false) break; } - return $ret; } + return $ret; } /** @@ -101,19 +101,16 @@ $array = $new_array; } - if( !function_exists('safeDefine') ) + /** + * Define constant if it was not already defined before + * + * @param string $const_name + * @param string $const_value + * @access public + */ + function safeDefine($const_name, $const_value) { - /** - * Define constant if it was not already defined before - * - * @param string $const_name - * @param string $const_value - * @access public - */ - function safeDefine($const_name, $const_value) - { - if(!defined($const_name)) define($const_name,$const_value); - } + if(!defined($const_name)) define($const_name,$const_value); } if( !function_exists('parse_portal_ini') ) @@ -315,6 +312,18 @@ $ch = curl_init($url); + $dbg = false; + if (defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_CURL')) { + $dbg = true; + safeDefine('DBG_CURL_LOGFILE', '/curl.log'); + $log = fopen(FULL_PATH.DBG_CURL_LOGFILE, 'a'); + + curl_setopt($ch, CURLOPT_FILE, $log); + curl_setopt($ch, CURLOPT_VERBOSE, TRUE); + curl_setopt($ch, CURLOPT_STDERR, $log); + //curl_setopt($ch, CURLOPT_WRITEHEADER, $log); + } + if (!is_null($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } @@ -330,6 +339,12 @@ $ret = curl_exec($ch); curl_close($ch); + + if ($dbg) { + fwrite($log, "\n".$ret); + fclose($log); + } + return $ret; } } @@ -375,18 +390,15 @@ return $result; } - if( !function_exists('constOn') ) + /** + * Checks if constant is defined and has positive value + * + * @param string $const_name + * @return bool + */ + function constOn($const_name) { - /** - * Checks if constant is defined and has positive value - * - * @param string $const_name - * @return bool - */ - function constOn($const_name) - { - return defined($const_name) && constant($const_name); - } + return defined($const_name) && constant($const_name); } function Kg2Pounds($kg) Index: trunk/admin/install/upgrades/changelog_1_1_7.txt =================================================================== diff -u -N -r3983 -r4243 --- trunk/admin/install/upgrades/changelog_1_1_7.txt (.../changelog_1_1_7.txt) (revision 3983) +++ trunk/admin/install/upgrades/changelog_1_1_7.txt (.../changelog_1_1_7.txt) (revision 4243) @@ -1,28 +1,40 @@ +File in-portal/.cvsignore changed File in-portal/globals.php changed +File in-portal/index.php changed +File in-portal/admin/advanced_view.php changed +File in-portal/admin/browse.php changed File in-portal/admin/head.php changed File in-portal/admin/index.php changed +File in-portal/admin/index4.php changed File in-portal/admin/install.php changed +File in-portal/admin/reviews.php changed File in-portal/admin/category/addcategory_permissions.php changed File in-portal/admin/category/addpermission.php changed File in-portal/admin/category/addpermission_modules.php changed +File in-portal/admin/email/sendmail.php changed +File in-portal/admin/help/manual.pdf changed File in-portal/admin/include/mainscript.php changed File in-portal/admin/include/sections.php changed File in-portal/admin/include/tabs.js changed File in-portal/admin/install/inportal_data.sql changed File in-portal/admin/install/inportal_schema.sql changed File in-portal/admin/install/inst_ado.php changed File in-portal/admin/install/langpacks/english.lang changed -File in-portal/admin/install/upgrades/changelog_1_1_7.txt is new; release_1_1_7 revision 1.1.2.1 -File in-portal/admin/install/upgrades/inportal_upgrade_v1.1.7.sql is new; release_1_1_7 revision 1.4.2.1 -File in-portal/admin/install/upgrades/readme_1_1_7.txt is new; release_1_1_7 revision 1.3 +File in-portal/admin/install/upgrades/changelog_1_1_7.txt is new; release_1_1_7 revision 1.1.2.9 +File in-portal/admin/install/upgrades/inportal_upgrade_v1.1.7.sql is new; release_1_1_7 revision 1.4.2.3 +File in-portal/admin/install/upgrades/readme_1_1_7.txt is new; release_1_1_7 revision 1.3.2.3 File in-portal/admin/logs/session_list.php changed File in-portal/admin/users/adduser.php changed File in-portal/kernel/action.php changed File in-portal/kernel/frontaction.php changed File in-portal/kernel/parser.php changed File in-portal/kernel/startup.php changed +File in-portal/kernel/admin/include/help/configure_general.txt changed +File in-portal/kernel/admin_templates/incs/export.js is new; release_1_1_7 revision 1.1.2.2 File in-portal/kernel/admin_templates/incs/form_blocks.tpl changed File in-portal/kernel/admin_templates/incs/grid_blocks.tpl changed +File in-portal/kernel/admin_templates/incs/script.js changed +File in-portal/kernel/admin_templates/incs/style.css changed File in-portal/kernel/admin_templates/regional/languages_edit.tpl changed File in-portal/kernel/admin_templates/visits/visits_list.tpl changed File in-portal/kernel/include/category.php changed @@ -38,6 +50,10 @@ File in-portal/kernel/include/searchitems.php changed File in-portal/kernel/include/usersession.php changed File in-portal/kernel/include/adodb/drivers/adodb-mysql.inc.php changed +File in-portal/kernel/units/categories/categories_item.php changed +File in-portal/kernel/units/categories/categories_tag_processor.php changed +File in-portal/kernel/units/config_general/config_general_tag_processor.php changed +File in-portal/kernel/units/custom_fields/custom_fields_event_handler.php changed File in-portal/kernel/units/general/cat_dbitem_export.php changed File in-portal/kernel/units/general/cat_event_handler.php changed File in-portal/kernel/units/general/cat_tag_processor.php changed @@ -51,6 +67,10 @@ File in-portal/kernel/units/users/users_event_handler.php changed File in-portal/kernel/units/users/users_item.php changed File in-portal/kernel/units/users/users_syncronize.php changed +File in-portal/themes/default/my_account.tpl changed +File in-portal/themes/default/inc/style.css changed +File in-portal/themes/default/my_info/myinfo_form.tpl changed +File in-portal/themes/default/register/register_form.tpl changed File in-portal/themes/default/search_results/error.tpl changed File kernel4_dev/kernel4/application.php changed File kernel4_dev/kernel4/event_handler.php changed Index: trunk/admin/help/manual.pdf =================================================================== diff -u -N -r3760 -r4243 Binary files differ Index: trunk/index.php =================================================================== diff -u -N -r3307 -r4243 --- trunk/index.php (.../index.php) (revision 3307) +++ trunk/index.php (.../index.php) (revision 4243) @@ -16,8 +16,7 @@ $end = getmicrotime(); -if ( $application->isDebugMode() ) -{ +if ($application->isDebugMode() && !dbg_ConstOn('DBG_SKIP_REPORTING')) { echo '

Memory used: '.round(memory_get_usage()/1024/1024, 1).' Mb
'; echo 'Time used: '.round(($end - $start), 5).' Sec
'; } Index: trunk/kernel/admin/include/help/configure_general.txt =================================================================== diff -u -N -r3484 -r4243 --- trunk/kernel/admin/include/help/configure_general.txt (.../configure_general.txt) (revision 3484) +++ trunk/kernel/admin/include/help/configure_general.txt (.../configure_general.txt) (revision 4243) @@ -30,7 +30,7 @@
  • Use mod_rewrite with SSL � this option specifies whether the new URL format should be used when redirecting to an SSL connection (configured by Requre SSL for login & checkout option). Generally, this option should be off when using a shared SSL certificate.
  • File not found (404) template � the template name relative to theme base folder, which will be displayed when requested URL is not found on the server.
  • Use JavaScript redirection after login/logout (for IIS) - if set to on then JavaScript redirection is used instead of HTTP redirection after login, logout and session expiration. This setting is required when running In-portal on IIS web server, which is not able to set cookies and issue HTTP redirection in one request. - +
  • Use Cron for Running Regular Events � controls if the system should use �cron� (a Linux daemon that executes scheduled commands) to perform regular activities such as checking the expiration dates, processing recurring orders etc. To setup In-portal to use the cron operation, the server should be configured to execute the �/tools/cron.php� script at least every 30 minutes. When this setting is off, the system will determine if there are any pending regular events to be executed on every page load (such as when navigating the site or accessing the administrative console). If such events are found, the system will execute them at that time.
  • Time zone of the server � this setting controls the time zone your server is located in. This refers to the system time that your server will report to In-portal scripts. You can find out this information from your server administrator.
  • Time zone of the site � this setting controls your time zone. This will determine what time zone you will see on all of the date/time stamps issued by the system. Index: trunk/kernel/units/categories/categories_item.php =================================================================== diff -u -N -r3787 -r4243 --- trunk/kernel/units/categories/categories_item.php (.../categories_item.php) (revision 3787) +++ trunk/kernel/units/categories/categories_item.php (.../categories_item.php) (revision 4243) @@ -55,7 +55,7 @@ $sql = 'SELECT ParentPath FROM '.$cat_table.' WHERE CategoryId = %s'; $parent_path = $this->Conn->GetOne( sprintf($sql, $parent_id) ); - if(!$parent_path) $parent_path = '|'.$parent_id.'|'; + if(!$parent_path && $parent_id) $parent_path = '|'.$parent_id.'|'; return $parent_path.$this->GetID().'|'; } Index: trunk/kernel/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r3723 -r4243 --- trunk/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 3723) +++ trunk/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 4243) @@ -142,7 +142,11 @@ $sql = 'SELECT CategoryId, ParentId, Name FROM '.$this->Application->getUnitOption($this->Prefix, 'TableName').' WHERE CategoryId='.$params['cat_id']; $res = $this->Conn->GetRow($sql); - + if ($res === false) { + // in case if category is deleted + return ''; + } + $block_params['cat_name'] = $res['Name']; $block_params['cat_id'] = $res['CategoryId']; Index: trunk/kernel/startup.php =================================================================== diff -u -N -r4065 -r4243 --- trunk/kernel/startup.php (.../startup.php) (revision 4065) +++ trunk/kernel/startup.php (.../startup.php) (revision 4243) @@ -11,7 +11,9 @@ if( defined('REL_PATH') ) { $ps = preg_replace("/".preg_quote(rtrim(REL_PATH, '/'), '/')."$/", '', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']))); - safeDefine('BASE_PATH', $ps); // in case in-portal has defined it before + if (!defined('BASE_PATH')) { + define('BASE_PATH', $ps); // in case in-portal has defined it before + } # New path detection method: end // KENEL4 INIT: BEGIN @@ -31,7 +33,8 @@ $application =& kApplication::Instance(); $application->Init(); - + $application->ProcessRequest(); + // compatibility constants $g_TablePrefix = TABLE_PREFIX; $pathtoroot = FULL_PATH.'/'; Index: trunk/kernel/units/general/cat_tag_processor.php =================================================================== diff -u -N -r3827 -r4243 --- trunk/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 3827) +++ trunk/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 4243) @@ -63,7 +63,10 @@ $cat_object =& $this->Application->recallObject('c', 'c_List'); $sql = 'SELECT CategoryId, ParentId, Name FROM '.$cat_object->TableName.' WHERE CategoryId = '.$params['cat_id']; $res = $this->Conn->GetRow($sql); - + if ($res === false) { + // in case if category is deleted + return ''; + } $block_params['name'] = $params['block']; $block_params['cat_name'] = $res['Name']; $block_params['cat_id'] = $res['CategoryId']; @@ -100,7 +103,31 @@ $special = crc32($parent_cat_id.$types.$except.$recursive); return $special; - } + } + + function ExportStatus($params) + { + define('DBG_SKIP_REPORTING', 1); + + $export_object =& $this->Application->recallObject('CatItemExportHelper'); + + $event = new kEvent($this->getPrefixSpecial().':OnDummy'); + + $action_method = 'perform'.ucfirst($this->Special); + $field_values = $export_object->$action_method($event); + + // finish code is done from JS now + if ($field_values['start_from'] == $field_values['total_records']) + { + if ($this->Special == 'import') { + $this->Application->StoreVar('PermCache_UpdateRequired', 1); + } + } + + $export_options = $export_object->loadOptions($event); + return $export_options['start_from'] * 100 / $export_options['total_records']; + } + } ?> \ No newline at end of file Index: trunk/kernel/admin_templates/incs/export.js =================================================================== diff -u -N --- trunk/kernel/admin_templates/incs/export.js (revision 0) +++ trunk/kernel/admin_templates/incs/export.js (revision 4243) @@ -0,0 +1,85 @@ +var $http_request = getXMLHTTPObject(); +var $last_responce = new Date(); + +function formatNumber($number, $digits_count) +{ + return parseInt($number) < Math.pow(10, $digits_count - 1) ? str_repeat('0', $digits_count - 1) + $number : $number; +} + +function formatDate($date) +{ + var $hour = formatNumber($date.getHours(), 2); + var $minute = formatNumber($date.getMinutes(), 2); + var $second = formatNumber($date.getSeconds(), 2); + return $hour + ':' + $minute + ':' + $second; +} + +function getSeconds($from_date, $to_date) +{ + var $from_seconds = $from_date.getSeconds() + $from_date.getMinutes() * 60 + $from_date.getHours() * 3600; + var $to_seconds = $to_date.getSeconds() + $to_date.getMinutes() * 60 + $to_date.getHours() * 3600; + return $to_seconds - $from_seconds; +} + +var $aborting = false; +function queryProgress($url, $responce_func) +{ +// alert('queryProgress'); + if ($http_request && $http_request.readyState != 0) { +// alert('aborting'); + $aborting = true; + $http_request.abort(); +// alert('After Abort: readyState: '+$http_request.readyState+' status: '+$http_request.status); + $aborting = false; + } + +// alert('opening'); + $http_request.open('POST', $url, true); + $http_request.setRequestHeader("referer", $url); + $http_request.onreadystatechange = function() { processExportResponce($url, $responce_func); }; +// alert('sending new req'); + $http_request.send('is_xml=1'); + $last_responce = new Date(); +} + +function setProgress($percent) +{ + $percent = parseInt($percent); + document.getElementById('percent_done').style.width = $percent + '%'; + document.getElementById('percent_left').style.width = (100 - $percent) + '%'; + document.getElementById('progress_display').innerHTML = $percent; + document.getElementById('progress_time').innerHTML = '[' + $phrase_LastResponce + ': ' + formatDate($last_responce) + ']'; +} + +function processExportResponce($url, $responce_func) +{ +// alert('processExportResponce ready: '+$http_request.readyState); + if ($aborting) return; + if ($http_request.readyState == 4) { + if ($http_request.status == 200) { +// alert('readyState: '+$http_request.readyState+' status: '+$http_request.status); + var $progress = parseFloat($http_request.responseText); + if ($progress) { + setProgress($progress); + if ($progress < 100) { + // proceed to next import step + //alert('ANOTHER abort'); + //$http_request.abort(); + //alert('After ANOTHER Abort: readyState: '+$http_request.readyState+' status: '+$http_request.status); + setTimeout( function() { +// alert('quering after timeout'); + queryProgress($url, $responce_func); + }, 500) + } + else { + // proceed to finish screen + window.location.href = $finish_template; + } + } + else { +// alert('progress: '+$progress+' ('+$http_request.responseText+')'); + alert($phrase_ResponceError); + } + } + } +} \ No newline at end of file Index: trunk/kernel/admin_templates/incs/style.css =================================================================== diff -u -N -r4052 -r4243 --- trunk/kernel/admin_templates/incs/style.css (.../style.css) (revision 4052) +++ trunk/kernel/admin_templates/incs/style.css (.../style.css) (revision 4243) @@ -502,4 +502,14 @@ .grid_id_cell TD { padding-right: 2px; +} + +.transparent { + filter: alpha(opacity=50); + -moz-opacity: .5; + opacity: .5; +} + +.none_transparent { + } \ No newline at end of file