Index: branches/RC/admin/backup/restore1.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/admin/backup/restore1.php (.../restore1.php) (revision 8929) +++ branches/RC/admin/backup/restore1.php (.../restore1.php) (revision 9398) @@ -1,4 +1,4 @@ -Get("Backup_Path"); - + $limit = 100; $success =0; $objSession->SetVariable("restore_filepath",$filepath); $objSession->SetVariable("restore_success",0); $objSession->SetVariable("restore_todo",""); - + $sec = $objSections->GetSection($section); $objCatToolBar = new clsToolBar(); $ro_perm = $objSession->HasSystemPermission("SYSTEM_ACCESS.READONLY"); if (true) { - + if($en_prev>-1) { $MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');"; @@ -63,15 +63,15 @@ $link="#"; $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),"#","","","","tool_prev_f3.gif"); - } + } if(true) { $MouseOver="if (document.restore1.agree.checked == true) swap('moveright','toolbar/tool_next_f2.gif');"; $MouseOut="if (document.restore1.agree.checked == true) swap('moveright', 'toolbar/tool_next.gif');"; $var="?env=".BuildEnv()."&en=$en_next"; - $link2=$rootURL."admin/backup/restore2.php".$var; + $link2=$rootURL.$admin."/backup/restore2.php".$var; $onClick="document.location= '$link2';"; $onClick="if (document.restore1.agree.checked == true) document.restore1.submit();"; @@ -86,37 +86,37 @@ $SubmitUrl = $ro_perm ? $adminURL.'/backup/restore1.php?'.$envar : $adminURL."/install.php"; //$SubmitUrl = $adminURL."/install.php"; ?> - + - + - > - > + - > + > - - + > - + Index: branches/RC/core/install/upgrades.sql =================================================================== diff -u -r9363 -r9398 --- branches/RC/core/install/upgrades.sql (.../upgrades.sql) (revision 9363) +++ branches/RC/core/install/upgrades.sql (.../upgrades.sql) (revision 9398) @@ -130,4 +130,6 @@ ALTER TABLE Language ADD AdminInterfaceLang TINYINT UNSIGNED NOT NULL AFTER PrimaryLang, - ADD Priority INT NOT NULL AFTER AdminInterfaceLang; \ No newline at end of file + ADD Priority INT NOT NULL AFTER AdminInterfaceLang; + +DELETE FROM PersistantSessionData WHERE VariableName = 'lang_columns_.'; \ No newline at end of file Index: branches/RC/admin/backup/restore2.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/admin/backup/restore2.php (.../restore2.php) (revision 8929) +++ branches/RC/admin/backup/restore2.php (.../restore2.php) (revision 9398) @@ -1,4 +1,4 @@ -GetSection($section); $objCatToolBar = new clsToolBar(); -$formaction = $rootURL."admin/backup/restore3.php?".$envar; +$formaction = $rootURL.$admin."/backup/restore3.php?".$envar; $formaction = "restore3.php?".$envar; -$restoreexit = $rootURL."admin/backup/restore4.php?".$envar; +$restoreexit = $rootURL.$admin."/backup/restore4.php?".$envar; $conn = &GetADODBConnection(); $totalfiles = $objSession->GetVariable("restore_files_num"); $filepath = $objConfig->Get("Backup_Path"); if (true) -{ +{ if($en_prev>-1) { $MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');"; @@ -45,29 +45,29 @@ $MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');"; $MouseOut="swap('moveleft', 'toolbar/tool_prev.gif');"; $var="?env=".BuildEnv(); - $link=$rootURL."admin/backup/restore1.php".$var; - + $link=$rootURL.$admin."/backup/restore1.php".$var; + $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,"","tool_prev.gif"); - } - + } + $MouseOver="if (document.restore2.backupdate.value) swap('moveright','toolbar/tool_next_f2.gif');"; - $MouseOut="if (document.restore2.backupdate.value) swap('moveright', 'toolbar/tool_next.gif');"; + $MouseOut="if (document.restore2.backupdate.value) swap('moveright', 'toolbar/tool_next.gif');"; $var="?env=".BuildEnv(); $onClick="restore_submit('restore2','$formaction');"; $link="#"; $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,$onClick,"tool_next_f3.gif"); } -//$link2=$rootURL."admin/backup/restore3.php".$var; +//$link2=$rootURL.$admin."/backup/restore3.php".$var; //$onClick="document.location= '$link2';"; //$onClick="restore_submit('restore2','$formaction');"; //$MouseOver="swap('img_edit','toolbar/tool_edit_f2.gif');"; //$MouseOut="swap('img_edit', 'toolbar/tool_edit.gif');"; //$objCatToolBar->Add("img_edit","la_ToolTip_Restore","#", $MouseOver,$MouseOut,$onClick, // "tool_edit.gif"); -$link3=$rootURL."admin/backup/restore2.php".$var; +$link3=$rootURL.$admin."/backup/restore2.php".$var; $objCatToolBar->Add("img_del","la_ToolTip_Delete","#", "swap('img_del','toolbar/tool_delete_f2.gif');", @@ -79,30 +79,30 @@ //phpinfo(INFO_VARIABLES); -function getDirList ($dirName) -{ +function getDirList ($dirName) +{ global $objSession; $filedates = array(); - $d = dir($dirName); + $d = dir($dirName); - while($entry = $d->read()) - { - if ($entry != "." && $entry != "..") - { - if (!is_dir($dirName."/".$entry) && eregi("dump",$entry)) - { - $shortversion=chopchop($entry); + while($entry = $d->read()) + { + if ($entry != "." && $entry != "..") + { + if (!is_dir($dirName."/".$entry) && eregi("dump",$entry)) + { + $shortversion=chopchop($entry); $filedate[]=$shortversion; - } - } - } - $d->close(); + } + } + } + $d->close(); rsort($filedate); return $filedate; -} +} function chopchop ($filename) { $p = pathinfo($filename); @@ -137,8 +137,8 @@ echo ""; - } - + } + ?> Index: branches/RC/core/units/languages/import_xml.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/core/units/languages/import_xml.php (.../import_xml.php) (revision 8929) +++ branches/RC/core/units/languages/import_xml.php (.../import_xml.php) (revision 9398) @@ -93,9 +93,9 @@ $this->tables['phrases'] = $this->Application->getUnitOption('phrases', 'TableName'); $this->tables['emailmessages'] = $this->Application->getUnitOption('emailmessages', 'TableName'); } - + $this->lang_object =& $this->Application->recallObject('lang.imp', null, Array('skip_autoload' => true)); - + $sql = 'SELECT EventId, CONCAT(Event,"_",Type) AS EventMix FROM '.TABLE_PREFIX.'Events'; $this->events_hash = $this->Conn->GetCol($sql, 'EventMix'); @@ -198,7 +198,14 @@ if( !getArrayValue($this->current_language,'LanguageId') ) { $this->lang_object->SetDBField('Enabled', STATUS_ACTIVE); - if( $this->lang_object->Create() ) $this->current_language['LanguageId'] = $this->lang_object->GetID(); + + if ($this->lang_object->Create()) { + $this->current_language['LanguageId'] = $this->lang_object->GetID(); + if (defined('IS_INSTALL') && IS_INSTALL) { + // language created during install becomes admin interface language + $this->lang_object->setPrimary(true, true); + } + } } elseif($this->import_mode == LANG_OVERWRITE_EXISTING) { @@ -403,7 +410,7 @@ fclose($fp); return true; } - + /** * Creates new instance of LangXML_Parser class * Index: branches/RC/admin/backup/restore3.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/admin/backup/restore3.php (.../restore3.php) (revision 8929) +++ branches/RC/admin/backup/restore3.php (.../restore3.php) (revision 9398) @@ -9,10 +9,10 @@ checkViewPermission('in-portal:restore'); $pathtolocal = $pathtoroot."kernel/"; -require_once ($pathtoroot."admin/include/elements.php"); +require_once ($pathtoroot.$admin."/include/elements.php"); require_once ($pathtoroot."kernel/admin/include/navmenu.php"); require_once ($pathtolocal."admin/include/navmenu.php"); -require_once($pathtoroot."admin/toolbar.php"); +require_once($pathtoroot.$admin."/toolbar.php"); require_once($pathtoroot.$admin."/install/install_lib.php"); $conn = &GetADODBConnection(); @@ -24,7 +24,7 @@ $filename = "dump".$_POST["backupdate"]."txt"; $filename = $objConfig->Get("Backup_Path")."/".$filename; } -else +else $filename = $_GET["Filename"]; $FileOffset = (int)$_GET["Offset"]; @@ -45,7 +45,7 @@ $MaxLines = 200; $PageTitle = admin_language("la_text_Restore_in_progress"); -$CancelURL = $rootURL ."admin/backup/restore1.php?env=".BuildEnv(); +$CancelURL = $rootURL .$admin."/backup/restore1.php?env=".BuildEnv(); stats($PageTitle,$FileOffset,$TotalSize); //echo "FileOffset: $FileOffset
\n"; @@ -58,8 +58,8 @@ $FileOffset = $TotalSize; $url = $_SERVER['PHP_SELF']."?env=".BuildEnv()."&Offset=$FileOffset&Filename=$filename"; } - else - { + else + { switch($FileOffset) { case -1: @@ -74,7 +74,7 @@ } $application =& kApplication::Instance(); $application->ApplicationDie($error); - } + } } else $url = $adminURL."/backup/restore4.php?env=".BuildEnv(); @@ -86,20 +86,20 @@ function stats($caption,$myprogress,$totalnum) { global $rootURL, $CancelURL; - + if($totalnum>0) { $pct=round(($myprogress/ $totalnum)*100); } else $pct = 100; $o .="
- +
+
+
-
"; echo adodb_date("F j, Y, g:i a",$value)."
"; - - echo "\n"; + + echo "\n"; $o .= int_subsection_title_ret($caption."-".$pct."%"); - $o .= " Index: branches/RC/admin/backup/backup1.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/admin/backup/backup1.php (.../backup1.php) (revision 8929) +++ branches/RC/admin/backup/backup1.php (.../backup1.php) (revision 9398) @@ -9,10 +9,10 @@ checkViewPermission('in-portal:backup'); $pathtolocal = $pathtoroot."kernel/"; -require_once ($pathtoroot."admin/include/elements.php"); +require_once ($pathtoroot.$admin."/include/elements.php"); require_once ($pathtoroot."kernel/admin/include/navmenu.php"); require_once ($pathtolocal."admin/include/navmenu.php"); -require_once($pathtoroot."admin/toolbar.php"); +require_once($pathtoroot.$admin."/toolbar.php"); //Set Section $section = "in-portal:backup"; //Set Environment Variable @@ -30,15 +30,15 @@ $objConfig->Set("Backup_Path",$newpath); $objConfig->Save(); } - + //initializes default $objSession->SetVariable("backup_start",0); $objSession->SetVariable("backup_tnumber","start"); $date = adodb_mktime(); $filepath=$objConfig->Get("Backup_Path"); -$filename="dump".$date.".txt"; +$filename="dump".$date.".txt"; //$filename= $filepath."".$filename; $limit = 100; $success =0; @@ -67,7 +67,7 @@ if (true) { - + if($en_prev>-1) { $MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');"; @@ -85,16 +85,16 @@ $link = "#"; $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),"#","","","","tool_prev_f3.gif"); - } + } if(true) { $MouseOver="swap('moveright','toolbar/tool_next_f2.gif');"; $MouseOut="swap('moveright', 'toolbar/tool_next.gif');"; $var="?env=".BuildEnv()."&en=$en_next"; $script_name = $ro_perm ? 'backup1' : 'backup2'; - $link2 = $rootURL."admin/backup/".$script_name.".php".$var; + $link2 = $rootURL.$admin."/backup/".$script_name.".php".$var; $onClick="document.location= '$link2';"; - + $link="#"; if ($writable) { $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,$onClick,"tool_next.gif"); @@ -103,30 +103,30 @@ $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),"#","","","","tool_next_f3.gif"); } } - + $title = admin_language("la_performing_backup")." - ".admin_language("la_Step")." 1"; int_header($objCatToolBar,NULL,$title); } ?> - +

"; + $o .= "

"; $o .= " "; - $o .=" "; + $o .=" "; $comp_pct = 100-$pct; $o .= " "; $o .= "
 
 
"; Index: branches/RC/admin/backup/restore4.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/admin/backup/restore4.php (.../restore4.php) (revision 8929) +++ branches/RC/admin/backup/restore4.php (.../restore4.php) (revision 9398) @@ -9,10 +9,10 @@ checkViewPermission('in-portal:restore'); $pathtolocal = $pathtoroot."kernel/"; -require_once ($pathtoroot."admin/include/elements.php"); +require_once ($pathtoroot.$admin."/include/elements.php"); require_once ($pathtoroot."kernel/admin/include/navmenu.php"); require_once ($pathtolocal."admin/include/navmenu.php"); -require_once($pathtoroot."admin/toolbar.php"); +require_once($pathtoroot.$admin."/toolbar.php"); $error = $objSession->GetVariable("restore_error"); @@ -28,16 +28,16 @@ $objCatToolBar = new clsToolBar(); if (true) -{ +{ if(true) { $var="?env=".BuildEnv()."&en=$en_prev"; $link=$adminURL."/backup/restore1.php".$var; - + $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,"","tool_prev.gif"); } - + if(true) { $MouseOver=""; @@ -50,13 +50,13 @@ } ?> -"> +"> - > - > + @@ -66,12 +66,12 @@ - +
- +
+
- - + +
MoveNext(); } -$p = strtolower($_GET['module']); +$p = strtolower($_GET['module']); if ($p == 'in-portal')$p = ''; @@ -51,15 +51,15 @@ if ($mod_ver != $newver) { $dir_name = $pathtoroot.$p."/admin/install/upgrades/"; - $dir = @dir($dir_name); - + $dir = @dir($dir_name); + $upgrades_arr = Array(); - + $new_version = ''; while ($file = $dir->read()) { - if ($file != "." && $file != ".." && !is_dir($dir_name.$file)) { + if ($file != "." && $file != ".." && !is_dir($dir_name.$file)) { if (strstr($file, 'inportal_check_v')) { - $upgrades_arr[] = $file; + $upgrades_arr[] = $file; } } } @@ -72,16 +72,16 @@ foreach($upgrades_arr as $file) { $file_tmp = str_replace("inportal_check_v", "", $file); - $file_tmp = str_replace(".php", "", $file_tmp); - + $file_tmp = str_replace(".php", "", $file_tmp); + if (ConvertVersion($file_tmp) > ConvertVersion($mod_ver)) { $filename = $pathtoroot.$mod_name."/admin/install/upgrades/$file"; if(file_exists($filename)) { include($filename); if($result&2)break; - } - } + } + } } } @@ -121,11 +121,11 @@
-'.$error.'
'; - } -?> + } +?>
-"> +"> - > + > - > + > - Index: branches/RC/admin/backup/backup2.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/admin/backup/backup2.php (.../backup2.php) (revision 8929) +++ branches/RC/admin/backup/backup2.php (.../backup2.php) (revision 9398) @@ -9,19 +9,19 @@ checkViewPermission('in-portal:backup'); $pathtolocal = $pathtoroot."kernel/"; -require_once ($pathtoroot."admin/include/elements.php"); +require_once ($pathtoroot.$admin."/include/elements.php"); require_once ($pathtoroot."kernel/admin/include/navmenu.php"); require_once ($pathtolocal."admin/include/navmenu.php"); -require_once ($pathtoroot."admin/toolbar.php"); +require_once ($pathtoroot.$admin."/toolbar.php"); global $tables; unset($tables); //$m = GetModuleArray(); //foreach($m as $key => $value) -//{ -// $mod = $pathtoroot . $value . "admin/include/backup.php"; +//{ +// $mod = $pathtoroot . $value . "admin/include/backup.php"; // require_once($mod); //} @@ -44,7 +44,7 @@ //if(strlen($prefix)) //{ for($x=0;$x\n"; exit(); @@ -140,27 +140,27 @@ echo "\n"; -//extracts the rows of data from tables using limits +//extracts the rows of data from tables using limits function insert_data($table, $start, $limit, $mywhere) { global $out; - + $conn = &GetADODBConnection(); if ($mywhere !="") { $whereclause= " WHERE ".$mywhere." "; } - else + else { $whereclause = ""; } - + $rs = $conn->Execute("SELECT * from $table $whereclause LIMIT $start, $limit"); $prefix = GetTablePrefix(); $rowcount = 0; while($rs && !$rs->EOF) - { + { $temp=$conn->GetInsertSQL($rs,$rs->fields); $temp=ereg_replace("\n","\\n", $temp); $temp=ereg_replace("\r","\\r", $temp); @@ -172,7 +172,7 @@ $rs->MoveNext(); $rowcount++; } - + return $rowcount; } @@ -182,7 +182,7 @@ $schema_create .="# --------------------------------------------------------".$crlf; $conn->Execute("SET SQL_QUOTE_SHOW_CREATE = 0"); $result = $conn->Execute("SHOW CREATE TABLE $table"); - if($result && !$result->EOF) + if($result && !$result->EOF) { $tmpres = $result->fields; // mysql_fetch_array($result); $pos = strpos($tmpres["Create Table"], ' ('); @@ -221,11 +221,11 @@ if(strlen($schema_create)) { $schema_create = str_replace("DROP TABLE IF EXISTS ".GetTablePrefix(),"DROP TABLE ",$schema_create); - $schema_create = str_replace("CREATE TABLE ".GetTablePrefix(),"CREATE TABLE ",$schema_create); + $schema_create = str_replace("CREATE TABLE ".GetTablePrefix(),"CREATE TABLE ",$schema_create); while(strlen($schema_create && substr($schema_create,-1)!=")")) { $schema_create = substr($schema_create,0,-1); - } + } } $schema_create .= "\n# --------------------------------------------------------\n"; return $schema_create; @@ -234,20 +234,20 @@ function stats($caption,$myprogress,$totalnum) { global $rootURL, $CancelURL,$PageTitle; - + if($totalnum>0) { $pct=round(($myprogress/ $totalnum)*100); } else $pct = 100; $o .="
- +
- ".prompt_language("la_Text_backup_access").""; - ?> + ?> +
"; - - echo "\n"; + + echo "\n"; $o .= int_subsection_title_ret($caption."-".$pct."%"); - $o .= "

"; + $o .= "

"; $o .= " "; - $o .=" "; + $o .=" "; $comp_pct = 100-$pct; $o .= " "; $o .= "
 
 
"; Index: branches/RC/admin/backup/backup3.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/admin/backup/backup3.php (.../backup3.php) (revision 8929) +++ branches/RC/admin/backup/backup3.php (.../backup3.php) (revision 9398) @@ -9,10 +9,10 @@ checkViewPermission('in-portal:backup'); $pathtolocal = $pathtoroot."kernel/"; -require_once ($pathtoroot."admin/include/elements.php"); +require_once ($pathtoroot.$admin."/include/elements.php"); require_once ($pathtoroot."kernel/admin/include/navmenu.php"); require_once ($pathtolocal."admin/include/navmenu.php"); -require_once($pathtoroot."admin/toolbar.php"); +require_once($pathtoroot.$admin."/toolbar.php"); $filename= $objSession->GetVariable("backup_filename"); @@ -34,8 +34,8 @@ $objCatToolBar = new clsToolBar(); $var="?env=".BuildEnv(); - $link=$rootURL."admin/backup/backup1.php".$var; - + $link=$rootURL.$admin."/backup/backup1.php".$var; + $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,"","tool_prev.gif"); $MouseOver=""; $MouseOut=""; @@ -44,20 +44,20 @@ $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),"#","","","","tool_next_f3.gif"); $title = admin_language("la_performing_backup")." - ".admin_language("la_Step")." 3"; - + int_header($objCatToolBar,NULL,$title); ?> -"> +"> - > + > - +

-
+
Application->RemoveVar('keywords'); $this->Application->RemoveVar('Search_Keywords'); - $sql = ' SELECT * FROM '.$this->Application->getUnitOption('confs', 'TableName').' - WHERE ModuleName="In-Commerce" - AND AdvancedSearch=1'; + $module_name = $this->Application->findModule('Var', $event->Prefix, 'Name'); + + $sql = 'SELECT * + FROM '.$this->Application->getUnitOption('confs', 'TableName').' + WHERE (ModuleName = '.$this->Conn->qstr($module_name).') AND (AdvancedSearch = 1)'; $search_config = $this->Conn->Query($sql); + $lang = $this->Application->GetVar('m_lang'); $object =& $event->getObject(); $object->SetPage(1); - $product_table = $this->Application->getUnitOption('p', 'TableName'); + $items_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $search_keywords = $this->Application->GetVar('value'); // will not be changed $keywords = $this->Application->GetVar('value'); // will be changed down there @@ -1095,25 +1099,19 @@ $highlight_keywords = Array(); $relevance_parts = Array(); - $condition_patterns = Array( 'any' => '%s LIKE %s', - 'contains' => '%s LIKE %s', - 'notcontains' => '(NOT (%1$s LIKE %2$s) OR %1$s IS NULL)', - 'is' => '%s = %s', - 'isnot' => '(%1$s != %2$s OR %1$s IS NULL)'); - $alias_counter = 0; $custom_fields = $this->Application->getUnitOption($event->Prefix, 'CustomFields'); if ($custom_fields) { $custom_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName'); - $join_clauses[] = ' LEFT JOIN '.$custom_table.' custom_data ON '.$product_table.'.ResourceId = custom_data.ResourceId'; + $join_clauses[] = ' LEFT JOIN '.$custom_table.' custom_data ON '.$items_table.'.ResourceId = custom_data.ResourceId'; } $search_log = ''; $weight_sum = 0; + // processing fields and preparing conditions - foreach($search_config as $record) - { + foreach ($search_config as $record) { $field = $record['FieldName']; $join_clause = ''; $condition_mode = 'WHERE'; @@ -1158,7 +1156,7 @@ $field_name = $alias.'.'.$exploded[1]; $join_clause = str_replace('{ForeignTable}', $alias, $record['JoinClause']); - $join_clause = str_replace('{LocalTable}', $product_table, $join_clause); + $join_clause = str_replace('{LocalTable}', $items_table, $join_clause); if($record['CustomFieldId']) { @@ -1179,142 +1177,33 @@ $field_name = $local_table.'.'.$field_name; } - $condition = ''; - switch($record['FieldType']) - { - case 'select': - $keywords[$field] = unhtmlentities( $keywords[$field] ); - $condition = sprintf($condition_patterns['is'], $field_name, $this->Conn->qstr( $keywords[$field] )); - break; - - case 'text': - $keywords[$field] = unhtmlentities( $keywords[$field] ); - - if(strlen($keywords[$field]) >= $this->Application->ConfigValue('Search_MinKeyword_Length')) - { - $highlight_keywords[] = $keywords[$field]; - if( in_array($verbs[$field], Array('any', 'contains', 'notcontains')) ) - { - $keywords[$field] = '%'.strtr($keywords[$field], Array('%' => '\\%', '_' => '\\_')).'%'; - } - $condition = sprintf( $condition_patterns[$verbs[$field]], - $field_name, - $this->Conn->qstr( $keywords[$field] )); - } - break; - - case 'boolean': - if($keywords[$field] != -1) - { - $property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings'); - switch($field) - { - case 'HotItem': - $hot_limit_var = getArrayValue($property_mappings, 'HotLimit'); - if($hot_limit_var) - { - $sql = 'SELECT Data FROM '.TABLE_PREFIX.'Cache WHERE VarName="'.$hot_limit_var.'"'; - $hot_limit = (int)$this->Conn->GetOne($sql); - $condition = 'IF('.$product_table.'.HotItem = 2, - IF('.$product_table.'.Hits >= '. - $hot_limit. - ', 1, 0), '.$product_table.'.HotItem) = '.$keywords[$field]; - } - break; - case 'PopItem': - $votes2pop_var = getArrayValue($property_mappings, 'VotesToPop'); - $rating2pop_var = getArrayValue($property_mappings, 'RatingToPop'); - if($votes2pop_var && $rating2pop_var) - { - $condition = 'IF('.$product_table.'.PopItem = 2, IF('.$product_table.'.CachedVotesQty >= '. - $this->Application->ConfigValue($votes2pop_var). - ' AND '.$product_table.'.CachedRating >= '. - $this->Application->ConfigValue($rating2pop_var). - ', 1, 0), '.$product_table.'.PopItem) = '.$keywords[$field]; - } - break; - case 'NewItem': - $new_days_var = getArrayValue($property_mappings, 'NewDays'); - if($new_days_var) - { - $condition = 'IF('.$product_table.'.NewItem = 2, - IF('.$product_table.'.CreatedOn >= (UNIX_TIMESTAMP() - '. - $this->Application->ConfigValue($new_days_var). - '*3600*24), 1, 0), '.$product_table.'.NewItem) = '.$keywords[$field]; - } - break; - case 'EditorsPick': - $condition = $product_table.'.EditorsPick = '.$keywords[$field]; - break; - } - } - break; - - case 'range': - $range_conditions = Array(); - if($keywords[$field.'_from'] && !preg_match("/[^0-9]/i", $keywords[$field.'_from'])) - { - $range_conditions[] = $field_name.' >= '.$keywords[$field.'_from']; - } - if($keywords[$field.'_to'] && !preg_match("/[^0-9]/i", $keywords[$field.'_to'])) - { - $range_conditions[] = $field_name.' <= '.$keywords[$field.'_to']; - } - if($range_conditions) - { - $condition = implode(' AND ', $range_conditions); - } - break; - - case 'date': - if($keywords[$field]) - { - if( in_array($keywords[$field], Array('today', 'yesterday')) ) - { - $current_time = getdate(); - $day_begin = adodb_mktime(0, 0, 0, $current_time['mon'], $current_time['mday'], $current_time['year']); - $time_mapping = Array('today' => $day_begin, 'yesterday' => ($day_begin - 86400)); - $min_time = $time_mapping[$keywords[$field]]; - } - else - { - $time_mapping = Array( 'last_week' => 604800, 'last_month' => 2628000, - 'last_3_months' => 7884000, 'last_6_months' => 15768000, - 'last_year' => 31536000 - ); - $min_time = adodb_mktime() - $time_mapping[$keywords[$field]]; - } - $condition = $field_name.' > '.$min_time; - } - break; + $condition = $this->getAdvancedSearchCondition($field_name, $record, $keywords, $verbs, $highlight_keywords); + if ($record['CustomFieldId'] && strlen($condition)) { + // search in primary value of custom field + value in current language + $field_name = $local_table.'.'.'l'.$this->Application->GetDefaultLanguageId().'_cust_'.array_search($field, $custom_fields); + $primary_condition = $this->getAdvancedSearchCondition($field_name, $record, $keywords, $verbs, $highlight_keywords); + $condition = '('.$condition.' OR '.$primary_condition.')'; } - if($condition) - { - if($join_clause) - { + if ($condition) { + if ($join_clause) { $join_clauses[] = $join_clause; } + $relevance_parts[] = 'IF('.$condition.', '.$record['Priority'].', 0)'; - if($glues[$field] == 1) // and - { - if($condition_mode == 'WHERE') - { + if ($glues[$field] == 1) { // and + if ($condition_mode == 'WHERE') { $and_conditions[] = $condition; } - else - { + else { $and_having_conditions[] = $condition; } } - else // or - { - if($condition_mode == 'WHERE') - { + else { // or + if ($condition_mode == 'WHERE') { $or_conditions[] = $condition; } - else - { + else { $or_having_conditions[] = $condition; } } @@ -1325,18 +1214,21 @@ } } - $search_log = implode('
', $search_log); - $search_log = preg_replace('/(.*) '.preg_quote($this->Application->Phrase('lu_and'), '/').'|'.preg_quote($this->Application->Phrase('lu_or'), '/').'$/is', '\\1', $search_log); - $this->saveToSearchLog($search_log, 1); // advanced search + if ($search_log) { + $search_log = implode('
', $search_log); + $search_log = preg_replace('/(.*) '.preg_quote($this->Application->Phrase('lu_and'), '/').'|'.preg_quote($this->Application->Phrase('lu_or'), '/').'$/is', '\\1', $search_log); + $this->saveToSearchLog($search_log, 1); // advanced search + } $this->Application->StoreVar('highlight_keywords', serialize($highlight_keywords)); // making relevance clause if($relevance_parts) { - $rel_keywords = $this->Application->ConfigValue('SearchRel_Keyword_products') / 100; - $rel_pop = $this->Application->ConfigValue('SearchRel_Pop_products') / 100; - $rel_rating = $this->Application->ConfigValue('SearchRel_Rating_products') / 100; + $conf_postfix = $this->Application->getUnitOption($event->Prefix, 'SearchConfigPostfix'); + $rel_keywords = $this->Application->ConfigValue('SearchRel_Keyword_'.$conf_postfix) / 100; + $rel_pop = $this->Application->ConfigValue('SearchRel_Pop_'.$conf_postfix) / 100; + $rel_rating = $this->Application->ConfigValue('SearchRel_Rating_'.$conf_postfix) / 100; $relevance_clause = '('.implode(' + ', $relevance_parts).') / '.$weight_sum.' * '.$rel_keywords; $relevance_clause .= ' + (Hits + 1) / (MAX(Hits) + 1) * '.$rel_pop; $relevance_clause .= ' + (CachedRating + 1) / (MAX(CachedRating) + 1) * '.$rel_rating; @@ -1359,7 +1251,7 @@ { $and_conditions[] = '('.implode(' OR ', $or_conditions).')'; } -// $and_conditions[] = $product_table.'.Status = 1'; +// $and_conditions[] = $items_table.'.Status = 1'; $where_clause = implode(' AND ', $and_conditions); if(!$where_clause) { @@ -1373,29 +1265,163 @@ $this->Application->SetVar('adv_search_error', 1); } } - $where_clause .= ' AND '.$product_table.'.Status = 1'; + $where_clause .= ' AND '.$items_table.'.Status = 1'; // building final search query $search_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search'; $this->Conn->Query('DROP TABLE IF EXISTS '.$search_table); + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); + $pick_field = isset($fields['EditorsPick']) ? $items_table.'.EditorsPick' : '0'; + $sql = ' CREATE TABLE '.$search_table.' SELECT '.$relevance_clause.' AS Relevance, - '.$product_table.'.ProductId AS ItemId, - '.$product_table.'.ResourceId AS ResourceId, + '.$items_table.'.'.$id_field.' AS ItemId, + '.$items_table.'.ResourceId AS ResourceId, 11 AS ItemType, - '.$product_table.'.EditorsPick AS EdPick - FROM '.$product_table.' + '.$pick_field.' AS EdPick + FROM '.$items_table.' '.implode(' ', $join_clauses).' WHERE '.$where_clause.' - GROUP BY '.$product_table.'.ProductId'. + GROUP BY '.$items_table.'.'.$id_field. $having_clause; $res = $this->Conn->Query($sql); } + function getAdvancedSearchCondition($field_name, $record, $keywords, $verbs, &$highlight_keywords) + { + $field = $record['FieldName']; + $condition_patterns = Array ( + 'any' => '%s LIKE %s', + 'contains' => '%s LIKE %s', + 'notcontains' => '(NOT (%1$s LIKE %2$s) OR %1$s IS NULL)', + 'is' => '%s = %s', + 'isnot' => '(%1$s != %2$s OR %1$s IS NULL)' + ); + + $condition = ''; + switch ($record['FieldType']) { + case 'select': + $keywords[$field] = unhtmlentities( $keywords[$field] ); + if ($keywords[$field]) { + $condition = sprintf($condition_patterns['is'], $field_name, $this->Conn->qstr( $keywords[$field] )); + } + break; + + case 'multiselect': + $keywords[$field] = unhtmlentities( $keywords[$field] ); + if ($keywords[$field]) { + $condition = Array (); + $values = explode('|', substr($keywords[$field], 1, -1)); + foreach ($values as $selected_value) { + $condition[] = sprintf($condition_patterns['contains'], $field_name, $this->Conn->qstr('%|'.$selected_value.'|%')); + } + $condition = '('.implode(' OR ', $condition).')'; + } + break; + + case 'text': + $keywords[$field] = unhtmlentities( $keywords[$field] ); + + if (strlen($keywords[$field]) >= $this->Application->ConfigValue('Search_MinKeyword_Length')) { + $highlight_keywords[] = $keywords[$field]; + if (in_array($verbs[$field], Array('any', 'contains', 'notcontains'))) { + $keywords[$field] = '%'.strtr($keywords[$field], Array('%' => '\\%', '_' => '\\_')).'%'; + } + $condition = sprintf($condition_patterns[$verbs[$field]], $field_name, $this->Conn->qstr( $keywords[$field] )); + } + break; + + case 'boolean': + if ($keywords[$field] != -1) { + $property_mappings = $this->Application->getUnitOption($this->Prefix, 'ItemPropertyMappings'); + $items_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); + + switch ($field) { + case 'HotItem': + $hot_limit_var = getArrayValue($property_mappings, 'HotLimit'); + if ($hot_limit_var) { + $sql = 'SELECT Data + FROM '.TABLE_PREFIX.'Cache + WHERE VarName = "'.$hot_limit_var.'"'; + $hot_limit = (int)$this->Conn->GetOne($sql); + + $condition = 'IF('.$items_table.'.HotItem = 2, + IF('.$items_table.'.Hits >= '. + $hot_limit. + ', 1, 0), '.$items_table.'.HotItem) = '.$keywords[$field]; + } + break; + + case 'PopItem': + $votes2pop_var = getArrayValue($property_mappings, 'VotesToPop'); + $rating2pop_var = getArrayValue($property_mappings, 'RatingToPop'); + if ($votes2pop_var && $rating2pop_var) { + $condition = 'IF('.$items_table.'.PopItem = 2, IF('.$items_table.'.CachedVotesQty >= '. + $this->Application->ConfigValue($votes2pop_var). + ' AND '.$items_table.'.CachedRating >= '. + $this->Application->ConfigValue($rating2pop_var). + ', 1, 0), '.$items_table.'.PopItem) = '.$keywords[$field]; + } + break; + + case 'NewItem': + $new_days_var = getArrayValue($property_mappings, 'NewDays'); + if ($new_days_var) { + $condition = 'IF('.$items_table.'.NewItem = 2, + IF('.$items_table.'.CreatedOn >= (UNIX_TIMESTAMP() - '. + $this->Application->ConfigValue($new_days_var). + '*3600*24), 1, 0), '.$items_table.'.NewItem) = '.$keywords[$field]; + } + break; + + case 'EditorsPick': + $condition = $items_table.'.EditorsPick = '.$keywords[$field]; + break; + } + } + break; + + case 'range': + $range_conditions = Array(); + if ($keywords[$field.'_from'] && !preg_match("/[^0-9]/i", $keywords[$field.'_from'])) { + $range_conditions[] = $field_name.' >= '.$keywords[$field.'_from']; + } + if ($keywords[$field.'_to'] && !preg_match("/[^0-9]/i", $keywords[$field.'_to'])) { + $range_conditions[] = $field_name.' <= '.$keywords[$field.'_to']; + } + if ($range_conditions) { + $condition = implode(' AND ', $range_conditions); + } + break; + + case 'date': + if ($keywords[$field]) { + if (in_array($keywords[$field], Array('today', 'yesterday'))) { + $current_time = getdate(); + $day_begin = adodb_mktime(0, 0, 0, $current_time['mon'], $current_time['mday'], $current_time['year']); + $time_mapping = Array('today' => $day_begin, 'yesterday' => ($day_begin - 86400)); + $min_time = $time_mapping[$keywords[$field]]; + } + else { + $time_mapping = Array ( + 'last_week' => 604800, 'last_month' => 2628000, 'last_3_months' => 7884000, + 'last_6_months' => 15768000, 'last_year' => 31536000, + ); + $min_time = adodb_mktime() - $time_mapping[$keywords[$field]]; + } + $condition = $field_name.' > '.$min_time; + } + break; + } + + return $condition; + } + function getHuman($type, $search_data) { $type = ucfirst(strtolower($type)); @@ -1430,7 +1456,7 @@ $ret = $this->Application->Phrase($values[$value]); break; - case 'text': + default: $ret = $value; break; Index: branches/RC/admin/install.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/admin/install.php (.../install.php) (revision 8929) +++ branches/RC/admin/install.php (.../install.php) (revision 9398) @@ -8,13 +8,15 @@ $general_error = ''; // new path detection without K4 init: begin -define('FULL_PATH', realpath(dirname(__FILE__).'/..') ); -define('BASE_PATH', rtrim(preg_replace('#/admin$#', '', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']))), '/')); -$rootURL = 'http://'.$_SERVER['HTTP_HOST'].rtrim(BASE_PATH, '/').'/admin/'; +define('FULL_PATH', realpath(dirname(__FILE__).'/..')); +define('ADMIN_DIRECTORY', preg_replace('/^'.preg_quote(FULL_PATH, '/').'/', '', realpath(dirname(__FILE__)))); + +define('BASE_PATH', rtrim(preg_replace('#'.ADMIN_DIRECTORY.'$#', '', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']))), '/')); +$rootURL = 'http://'.$_SERVER['HTTP_HOST'].rtrim(BASE_PATH, '/').ADMIN_DIRECTORY.'/'; // new path detection without K4 init: end $pathtoroot = FULL_PATH.'/'; -$admin = 'admin'; +$admin = trim(ADMIN_DIRECTORY, '/'); ini_set('include_path', '.'); @@ -36,17 +38,14 @@ $install_type = GetVar('install_type', true); $force_finish = isset($_REQUEST['ff']) ? true : false; -$ini_file = $pathtoroot."config.php"; -if(file_exists($ini_file)) -{ +$ini_file = FULL_PATH.'/config.php'; +if (file_exists($ini_file)) { $write_access = is_writable($ini_file); - $ini_vars = inst_parse_portal_ini($ini_file,TRUE); + $ini_vars = inst_parse_portal_ini($ini_file, true); - foreach($ini_vars as $secname => $section) - { - foreach($section as $key => $value) - { - $key = "g_".str_replace('-', '', $key); + foreach ($ini_vars as $secname => $section) { + foreach ($section as $key => $value) { + $key = 'g_'.str_replace('-', '', $key); global $$key; $$key = $value; } @@ -58,12 +57,12 @@ $write_access = is_writable($pathtoroot); if($write_access) { - set_ini_value("Database", "DBType", ""); - set_ini_value("Database", "DBHost", ""); - set_ini_value("Database", "DBUser", ""); - set_ini_value("Database", "DBUserPassword", ""); - set_ini_value("Database", "DBName", ""); - set_ini_value("Module Versions", "In-Portal", ""); + set_ini_value('Database', 'DBType', ''); + set_ini_value('Database', 'DBHost', ''); + set_ini_value('Database', 'DBUser', ''); + set_ini_value('Database', 'DBUserPassword', ''); + set_ini_value('Database', 'DBName', ''); + set_ini_value('Module Versions', 'In-Portal', ''); save_values(); } @@ -250,21 +249,21 @@ //die(); } - if(!is_writable($pathtoroot."admin/backupdata/")) + if(!is_writable($pathtoroot.$admin."/backupdata/")) { if ($general_error != '') { $general_error .= '

'; } - $general_error .= "In-portal's Backup directory must be writable (".$pathtoroot."admin/backupdata/)."; + $general_error .= "In-portal's Backup directory must be writable (".$pathtoroot.$admin."/backupdata/)."; //die(); } - if(!is_writable($pathtoroot."admin/export/")) + if(!is_writable($pathtoroot.$admin."/export/")) { if ($general_error != '') { $general_error .= '

'; } - $general_error .= "In-portal's Export directory must be writable (".$pathtoroot."admin/export/)."; + $general_error .= "In-portal's Export directory must be writable (".$pathtoroot.$admin."/export/)."; //die(); } @@ -749,7 +748,7 @@ else { $filepath = stripslashes($_POST['backupdir']); - $backupfile = $filepath.$path_char.str_replace('(.*)', $_POST['backupdate'], BACKUP_NAME); + $backupfile = $filepath.'/'.str_replace('(.*)', $_POST['backupdate'], BACKUP_NAME); if(file_exists($backupfile) && is_readable($backupfile)) { @@ -780,7 +779,7 @@ } if (!$show_warning) { - $filename = $pathtoroot.$admin.$path_char.'install'.$path_char.'inportal_remove.sql'; + $filename = $pathtoroot.$admin.'/install/inportal_remove.sql'; RunSchemaFile($ado,$filename); $state="restore_run"; } @@ -1587,7 +1586,7 @@ $ado->Execute($sql); $sql = "UPDATE ".$g_TablePrefix."ConfigurationValues SET VariableValue = '$g_Domain' WHERE VariableName='Server_Name'"; $ado->Execute($sql); - $sql = "UPDATE ".$g_TablePrefix."ConfigurationValues SET VariableValue = '".$_SERVER['DOCUMENT_ROOT'].$sitepath."admin/backupdata' WHERE VariableName='Backup_Path'"; + $sql = "UPDATE ".$g_TablePrefix."ConfigurationValues SET VariableValue = '".$_SERVER['DOCUMENT_ROOT'].$sitepath.$admin."/backupdata' WHERE VariableName='Backup_Path'"; $ado->Execute($sql); $Modules = a48d819089308a9aeb447e7248b2587f(); @@ -1701,7 +1700,7 @@ SET LastAccessed = 0 WHERE PortalUserId IN (0,-2)'; $ado->Execute($sql); - + echo ""; } Index: branches/RC/admin/modules/upgrade_lic.php =================================================================== diff -u -r8929 -r9398 --- branches/RC/admin/modules/upgrade_lic.php (.../upgrade_lic.php) (revision 8929) +++ branches/RC/admin/modules/upgrade_lic.php (.../upgrade_lic.php) (revision 9398) @@ -1,4 +1,4 @@ -Get("Backup_Path"); - + $limit = 100; $success =0; $objSession->SetVariable("restore_filepath",$filepath); $objSession->SetVariable("restore_success",0); $objSession->SetVariable("restore_todo",""); - + $sec = $objSections->GetSection($section); $objCatToolBar = new clsToolBar(); $ro_perm = $objSession->HasSystemPermission("SYSTEM_ACCESS.READONLY"); if (true) { - + $MouseOver=""; $MouseOut=""; $onClick=""; $link="#"; $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),"#","","","","tool_prev_f3.gif"); - + if(true) { $MouseOver="swap('moveright','toolbar/tool_next_f2.gif');"; $MouseOut="swap('moveright', 'toolbar/tool_next.gif');"; $var="?env=".BuildEnv()."&en=$en_next"; - $link2=$rootURL."admin/install.php".$var; + $link2=$rootURL.$admin."/install.php".$var; $onClick="document.location= '$link2';"; $onClick="document.restore1.submit();"; $link="#"; $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,$onClick,"tool_next.gif"); } - + $title = admin_language("la_tab_upgrade_license"); - + int_header($objCatToolBar,NULL,$title); } $SubmitUrl = $adminURL."/install.php"; //$SubmitUrl = $adminURL."/install.php"; ?> - + - + - > - > + - > + > - Index: branches/RC/core/kernel/startup.php =================================================================== diff -u -r9389 -r9398 --- branches/RC/core/kernel/startup.php (.../startup.php) (revision 9389) +++ branches/RC/core/kernel/startup.php (.../startup.php) (revision 9398) @@ -20,7 +20,7 @@ $vars = parse_portal_ini(FULL_PATH.'/config.php'); $admin_directory = isset($vars['AdminDirectory']) ? $vars['AdminDirectory'] : '/admin'; - define('ADMIN_DIRECTORY', $admin_directory); + safeDefine('ADMIN_DIRECTORY', $admin_directory); # New path detection method: begin if (defined('REL_PATH')) { @@ -79,7 +79,7 @@ ini_set('memory_limit', '50M'); define('MODULES_PATH', FULL_PATH); - define('EXPORT_PATH', defined('WRITEABLE') ? WRITEABLE.'/export' : FULL_PATH.'/admin/export'); + define('EXPORT_PATH', defined('WRITEABLE') ? WRITEABLE.'/export' : FULL_PATH.ADMIN_DIRECTORY.'/export'); define('GW_CLASS_PATH', MODULES_PATH.'/in-commerce/units/gateways/gw_classes'); // Payment Gateway Classes Path define('SYNC_CLASS_PATH', FULL_PATH.'/sync'); // path for 3rd party user syncronization scripts
- +
+
+