Attached Files |
site_domains_core.patch [^] (57,116 bytes) 2010-02-03 06:21
[Show Content]
Index: admin_templates/site_domains/site_domain_edit.tpl
===================================================================
--- admin_templates/site_domains/site_domain_edit.tpl (revision 0)
+++ admin_templates/site_domains/site_domain_edit.tpl (revision 0)
@@ -0,0 +1,111 @@
+<inp2:adm_SetPopupSize width="750" height="560"/>
+
+<inp2:m_include t="incs/header"/>
+<inp2:m_RenderElement name="combined_header" section="in-portal:site_domains" prefix="site-domain" title_preset="site_domain_edit"/>
+
+<!-- ToolBar -->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
+ submit_event('site-domain', '<inp2:site-domain_SaveEvent/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
+ cancel_edit('site-domain', 'OnCancelEdit','<inp2:site-domain_SaveEvent/>','<inp2:m_Phrase label="la_FormCancelConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarButton('reset_edit', '<inp2:m_phrase label="la_ToolTip_Reset" escape="1"/>', function() {
+ reset_form('site-domain', 'OnReset', '<inp2:m_Phrase label="la_FormResetConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_PrevId/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_NextId/>');
+ }
+ ) );
+
+ a_toolbar.Render();
+
+ <inp2:m_if check="site-domain_IsSingle">
+ a_toolbar.HideButton('prev');
+ a_toolbar.HideButton('next');
+ a_toolbar.HideButton('sep1');
+ <inp2:m_else/>
+ <inp2:m_if check="site-domain_IsLast">
+ a_toolbar.DisableButton('next');
+ </inp2:m_if>
+ <inp2:m_if check="site-domain_IsFirst">
+ a_toolbar.DisableButton('prev');
+ </inp2:m_if>
+ </inp2:m_if>
+ </script>
+ </td>
+ </tr>
+</tbody>
+</table>
+
+<inp2:site-domain_SaveWarning name="grid_save_warning"/>
+<inp2:site-domain_ErrorWarning name="form_error_warning"/>
+
+<inp2:m_DefineElement name="inp_edit_regexp_box" class="" format="" is_last="" maxlength="" onblur="" onchange="" size="" onkeyup="" hint_label="" style="width: 400px">
+ <inp2:m_if check="{$prefix}_FieldVisible" field="$field">
+ <tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
+ <inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" hint_label="$hint_label" is_last="$is_last"/>
+ <td class="control-cell">
+ <input type="hidden" id="<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>" name="<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>" value="<inp2:{$prefix}_Field field='{$field}UsesRegExp' db='db'/>">
+ <input tabindex="<inp2:m_get param='tab_index'/>" type="checkbox" id="_cb_<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>" <inp2:{$prefix}_Field field="{$field}UsesRegExp" checked="checked" db="db"/> onchange="update_checkbox(this, document.getElementById('<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>'));"/>
+
+ <input style="<inp2:m_Param name='style'/>" type="text" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' format='$format'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" maxlength="<inp2:m_param name='maxlength'/>" class="<inp2:m_param name='class'/>" onblur="<inp2:m_Param name='onblur'/>" onkeyup="<inp2:m_Param name='onkeyup'/>" onchange="<inp2:m_Param name='onchange'/>">
+ </td>
+ <inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
+ </tr>
+ </inp2:m_if>
+</inp2:m_DefineElement>
+
+<div id="scroll_container">
+ <table class="edit-form">
+ <inp2:m_RenderElement name="inp_id_label" prefix="site-domain" field="DomainId" title="la_fld_Id"/>
+ <inp2:m_RenderElement name="inp_edit_regexp_box" prefix="site-domain" field="DomainName" title="la_fld_DomainName"/>
+ <inp2:m_RenderElement name="inp_edit_regexp_box" prefix="site-domain" field="SSLUrl" title="la_fld_SSLUrl" hint_label="la_hint_SSLUrl"/>
+ <inp2:m_RenderElement name="inp_edit_box" prefix="site-domain" field="AdminEmail" title="la_fld_AdminEmail"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="Country" title="la_fld_Country" has_empty="1"/>
+
+ <inp2:m_if check="m_ModuleEnabled" module="In-Commerce">
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="BillingCountry" title="la_fld_BillingCountry" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="ShippingCountry" title="la_fld_ShippingCountry" has_empty="1"/>
+ </inp2:m_if>
+
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryLanguageId" title="la_fld_Language" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="Languages" title="la_fld_Languages" optprefix="lang" option_key_field="LanguageId" option_value_field="PackName"/>
+
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryThemeId" title="la_fld_Theme" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="Themes" title="la_fld_Themes" optprefix="theme" option_key_field="ThemeId" option_value_field="Name"/>
+
+ <inp2:m_if check="m_ModuleEnabled" module="In-Commerce">
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryCurrencyId" title="la_fld_Currency" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="Currencies" title="la_fld_Currencies" optprefix="curr" option_key_field="CurrencyId" option_value_field="Translation"/>
+
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryPaymentTypeId" title="la_fld_PaymentType" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="PaymentTypes" title="la_fld_PaymentTypes" optprefix="pt" option_key_field="PaymentTypeId" option_value_field="Name"/>
+ </inp2:m_if>
+
+ <inp2:m_RenderElement name="inp_edit_textarea" prefix="site-domain" field="DomainIPRange" title="la_fld_DomainIPRange" hint_label="la_hint_DomainIPRange" allow_html="0"/>
+ <inp2:m_RenderElement name="inp_edit_checkbox" prefix="site-domain" field="RedirectOnIPMatch" title="la_fld_RedirectOnIPMatch"/>
+ <inp2:m_RenderElement name="inp_edit_box" prefix="site-domain" field="Priority" title="la_fld_Priority" style="width: 50px;"/>
+
+ <inp2:m_RenderElement name="inp_edit_filler"/>
+ </table>
+</div>
+
+<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Index: admin_templates/site_domains/site_domain_list.tpl
===================================================================
--- admin_templates/site_domains/site_domain_list.tpl (revision 0)
+++ admin_templates/site_domains/site_domain_list.tpl (revision 0)
@@ -0,0 +1,48 @@
+<inp2:m_include t="incs/header"/>
+<inp2:m_RenderElement name="combined_header" section="in-portal:site_domains" prefix="site-domain" title_preset="site_domain_list" pagination="1"/>
+
+<!-- ToolBar -->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ //do not rename - this function is used in default grid for double click!
+ function edit()
+ {
+ std_edit_item('site-domain', 'site_domains/site_domain_edit');
+ }
+
+ var a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('new_item', '<inp2:m_phrase label="la_ToolTip_NewSiteDomain" escape="1"/>::<inp2:m_phrase label="la_ToolTip_Add" escape="1"/>',
+ function() {
+ std_precreate_item('site-domain', 'site_domains/site_domain_edit');
+ } ) );
+
+ a_toolbar.AddButton( new ToolBarButton('edit', '<inp2:m_phrase label="la_ToolTip_Edit" escape="1"/>::<inp2:m_phrase label="la_ShortToolTip_Edit" escape="1"/>', edit) );
+ a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>',
+ function() {
+ std_delete_items('site-domain')
+ } ) );
+
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
+ show_viewmenu(a_toolbar,'view');
+ }
+ ) );
+
+ a_toolbar.Render();
+ </script>
+ </td>
+ <inp2:m_RenderElement name="search_main_toolbar" prefix="site-domain" grid="Default"/>
+ </tr>
+</tbody>
+</table>
+
+<inp2:m_RenderElement name="grid" PrefixSpecial="site-domain" IdField="DomainId" grid="Default"/>
+<script type="text/javascript">
+ Grids['site-domain'].SetDependantToolbarButtons( new Array('edit','delete') );
+</script>
+<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Index: install/english.lang
===================================================================
--- install/english.lang (revision 13140)
+++ install/english.lang (working copy)
@@ -13,6 +13,7 @@
<PHRASE Label="la_Auto" Module="Core" Type="1">QXV0bw==</PHRASE>
<PHRASE Label="la_Automatic" Module="Core" Type="1">QXV0b21hdGlj</PHRASE>
<PHRASE Label="la_AvailableColumns" Module="Core" Type="1">QXZhaWxhYmxlIENvbHVtbnM=</PHRASE>
+ <PHRASE Label="la_AvailableItems" Module="Core" Type="1">QXZhaWxhYmxlIEl0ZW1z</PHRASE>
<PHRASE Label="la_Background" Module="Core" Type="1">QmFja2dyb3VuZA==</PHRASE>
<PHRASE Label="la_Borders" Module="Core" Type="1">Qm9yZGVycw==</PHRASE>
<PHRASE Label="la_btn_BrowseMode" Module="Core" Type="1">QnJvd3NlIE1vZGU=</PHRASE>
@@ -56,8 +57,10 @@
<PHRASE Label="la_col_CategoryName" Module="Core" Type="1">U2VjdGlvbiBOYW1l</PHRASE>
<PHRASE Label="la_col_Changes" Module="Core" Type="1">Q2hhbmdlcw==</PHRASE>
<PHRASE Label="la_col_Charset" Module="Core" Type="1">Q2hhcnNldA==</PHRASE>
+ <PHRASE Label="la_col_Country" Module="Core" Type="1">Q291bnRyeQ==</PHRASE>
<PHRASE Label="la_col_CreatedOn" Module="Core" Type="1">Q3JlYXRlZCBPbg==</PHRASE>
<PHRASE Label="la_col_Description" Module="Core" Type="1">RGVzY3JpcHRpb24=</PHRASE>
+ <PHRASE Label="la_col_DomainName" Module="Core" Type="1">RG9tYWluIE5hbWU=</PHRASE>
<PHRASE Label="la_col_Duration" Module="Core" Type="1">RHVyYXRpb24=</PHRASE>
<PHRASE Label="la_col_Effective" Module="Core" Type="1">RWZmZWN0aXZl</PHRASE>
<PHRASE Label="la_col_Email" Module="Core" Type="1">RW1haWw=</PHRASE>
@@ -161,6 +164,7 @@
<PHRASE Label="la_col_SessionStart" Module="Core" Type="1">U2Vzc2lvbiBTdGFydA==</PHRASE>
<PHRASE Label="la_col_SkinName" Module="Core" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_col_SortBy" Module="Core" Type="1">U29ydCBieQ==</PHRASE>
+ <PHRASE Label="la_col_SSLUrl" Module="Core" Type="1">U1NMIFVybA==</PHRASE>
<PHRASE Label="la_col_Status" Module="Core" Type="1">U3RhdHVz</PHRASE>
<PHRASE Label="la_col_StopWord" Module="Core" Type="1">U3RvcCBXb3Jk</PHRASE>
<PHRASE Label="la_col_Subject" Module="Core" Type="1">U3ViamVjdA==</PHRASE>
@@ -170,6 +174,7 @@
<PHRASE Label="la_col_TargetId" Module="Core" Type="1">SXRlbQ==</PHRASE>
<PHRASE Label="la_col_TargetType" Module="Core" Type="1">SXRlbSBUeXBl</PHRASE>
<PHRASE Label="la_col_TemplateType" Module="Core" Type="1">VGVtcGxhdGU=</PHRASE>
+ <PHRASE Label="la_col_Theme" Module="Core" Type="1">VGhlbWU=</PHRASE>
<PHRASE Label="la_col_ThesaurusTerm" Module="Core" Type="1">VGhlc2F1cnVzIFRlcm0=</PHRASE>
<PHRASE Label="la_col_ThesaurusType" Module="Core" Type="1">VGhlc2F1cnVzIFR5cGU=</PHRASE>
<PHRASE Label="la_col_Title" Module="Core" Type="1">VGl0bGU=</PHRASE>
@@ -556,6 +561,7 @@
<PHRASE Label="la_fld_Action" Module="Core" Type="1">QWN0aW9u</PHRASE>
<PHRASE Label="la_fld_AddressLine1" Module="Core" Type="1">QWRkcmVzcyBMaW5lIDE=</PHRASE>
<PHRASE Label="la_fld_AddressLine2" Module="Core" Type="1">QWRkcmVzcyBMaW5lIDI=</PHRASE>
+ <PHRASE Label="la_fld_AdminEmail" Module="Core" Type="1">TWVzc2FnZXMgZnJvbSBTaXRlIEFkbWluIGFyZSBmcm9t</PHRASE>
<PHRASE Label="la_fld_AdminInterfaceLang" Module="Core" Type="1">QWRtaW4gUHJpbWFyeQ==</PHRASE>
<PHRASE Label="la_fld_AdvancedCSS" Module="Core" Type="1">QWR2YW5jZWQgQ1NT</PHRASE>
<PHRASE Label="la_fld_AdvancedSearch" Module="Core" Type="1">QWR2YW5jZWQgU2VhcmNo</PHRASE>
@@ -602,6 +608,8 @@
<PHRASE Label="la_fld_Display" Module="Core" Type="1">RGlzcGxheQ==</PHRASE>
<PHRASE Label="la_fld_DisplayInGrid" Module="Core" Type="1">RGlzcGxheSBpbiBHcmlk</PHRASE>
<PHRASE Label="la_fld_DisplayName" Module="Core" Type="1">RmllbGQgTGFiZWw=</PHRASE>
+ <PHRASE Label="la_fld_DomainIPRange" Module="Core" Type="1">UmFuZ2Ugb2YgSVBz</PHRASE>
+ <PHRASE Label="la_fld_DomainName" Module="Core" Type="1">RG9tYWluIE5hbWU=</PHRASE>
<PHRASE Label="la_fld_DoNotEncode" Module="Core" Type="1">QXMgUGxhaW4gVGV4dA==</PHRASE>
<PHRASE Label="la_fld_Duration" Module="Core" Type="1">RHVyYXRpb24=</PHRASE>
<PHRASE Label="la_fld_EditorsPick" Module="Core" Type="1">RWRpdG9ycyBQaWNr</PHRASE>
@@ -679,6 +687,7 @@
<PHRASE Label="la_fld_Language" Module="Core" Type="1">TGFuZ3VhZ2U=</PHRASE>
<PHRASE Label="la_fld_LanguageFile" Module="Core" Type="1">TGFuZ3VhZ2UgRmlsZQ==</PHRASE>
<PHRASE Label="la_fld_LanguageId" Module="Core" Type="1">TGFuZ3VhZ2UgSUQ=</PHRASE>
+ <PHRASE Label="la_fld_Languages" Module="Core" Type="1">TGFuZ3VhZ2Vz</PHRASE>
<PHRASE Label="la_fld_LastName" Module="Core" Type="1">TGFzdCBOYW1l</PHRASE>
<PHRASE Label="la_fld_LastRunOn" Module="Core" Type="1">TGFzdCBSdW4gT24=</PHRASE>
<PHRASE Label="la_fld_LastRunStatus" Module="Core" Type="1">TGFzdCBSdW4gU3RhdHVz</PHRASE>
@@ -743,6 +752,7 @@
<PHRASE Label="la_fld_PrimaryTranslation" Module="Core" Type="1">UHJpbWFyeSBMYW5ndWFnZSBQaHJhc2U=</PHRASE>
<PHRASE Label="la_fld_Priority" Module="Core" Type="1">T3JkZXI=</PHRASE>
<PHRASE Label="la_fld_Rating" Module="Core" Type="1">UmF0aW5n</PHRASE>
+ <PHRASE Label="la_fld_RedirectOnIPMatch" Module="Core" Type="1">Rm9yY2UgUmVkaXJlY3QgKHdoZW4gdXNlcidzIElQIG1hdGNoZXMp</PHRASE>
<PHRASE Label="la_fld_RelatedSearchKeyword" Module="Core" Type="1">S2V5d29yZA==</PHRASE>
<PHRASE Label="la_fld_RelationshipType" Module="Core" Type="1">VHlwZQ==</PHRASE>
<PHRASE Label="la_fld_RemoteUrl" Module="Core" Type="1">UmVtb3RlIFVSTA==</PHRASE>
@@ -765,6 +775,7 @@
<PHRASE Label="la_fld_SkinName" Module="Core" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_fld_SkipFirstRow" Module="Core" Type="1">U2tpcCBGaXJzdCBSb3c=</PHRASE>
<PHRASE Label="la_fld_SortValues" Module="Core" Type="1">U29ydCBWYWx1ZXM=</PHRASE>
+ <PHRASE Label="la_fld_SSLUrl" Module="Core" Type="1">U1NMIEZ1bGwgVVJM</PHRASE>
<PHRASE Label="la_fld_State" Module="Core" Type="1">U3RhdGU=</PHRASE>
<PHRASE Label="la_fld_Status" Module="Core" Type="1">U3RhdHVz</PHRASE>
<PHRASE Label="la_fld_StopWord" Module="Core" Type="1">U3RvcCBXb3Jk</PHRASE>
@@ -780,6 +791,8 @@
<PHRASE Label="la_fld_TextAlign" Module="Core" Type="1">VGV4dCBBbGlnbg==</PHRASE>
<PHRASE Label="la_fld_TextDecoration" Module="Core" Type="1">VGV4dCBEZWNvcmF0aW9u</PHRASE>
<PHRASE Label="LA_FLD_TEXTVERSION" Module="Core" Type="1">VGV4dCBWZXJzaW9u</PHRASE>
+ <PHRASE Label="la_fld_Theme" Module="Core" Type="1">VGhlbWU=</PHRASE>
+ <PHRASE Label="la_fld_Themes" Module="Core" Type="1">VGhlbWVz</PHRASE>
<PHRASE Label="la_fld_ThesaurusTerm" Module="Core" Type="1">VGhlc2F1cnVzIFRlcm0=</PHRASE>
<PHRASE Label="la_fld_ThesaurusType" Module="Core" Type="1">VGhlc2F1cnVzIFR5cGU=</PHRASE>
<PHRASE Label="la_fld_ThousandSep" Module="Core" Type="1">VGhvdXNhbmRzIFNlcGFyYXRvcg==</PHRASE>
@@ -814,7 +827,9 @@
<PHRASE Label="la_Hide" Module="Core" Type="1">SGlkZQ==</PHRASE>
<PHRASE Label="la_hint_AllFiles" Module="Core" Type="1">QWxsIEZpbGVz</PHRASE>
<PHRASE Label="la_hint_CSVFiles" Module="Core" Type="1">Q1NWIEZpbGVz</PHRASE>
+ <PHRASE Label="la_hint_DomainIPRange" Module="Core" Type="1">U2luZ2xlIElQIG9yIHJhbmdlIHJlY29yZCBwZXIgbGluZSAoZm9ybWF0czogMS4yLjMuNCBvciAxLjIuMyBvciAxLjIuMy4zMi0xLjIuMy41NCBvciAxLjIuMy4zMi8yNyBvciAxLjIuMy4zMi8yNTUuMjU1LjI1NS4yMjQp</PHRASE>
<PHRASE Label="la_hint_ImageFiles" Module="Core" Type="1">SW1hZ2UgRmlsZXM=</PHRASE>
+ <PHRASE Label="la_hint_SSLUrl" Module="Core" Type="1">aHR0cHM6Ly93d3cuZG9tYWluLmNvbS9wYXRo</PHRASE>
<PHRASE Label="la_Hot" Module="Core" Type="1">SG90</PHRASE>
<PHRASE Label="la_Html" Module="Core" Type="1">SFRNTA==</PHRASE>
<PHRASE Label="la_IDField" Module="Core" Type="1">SUQgRmllbGQ=</PHRASE>
@@ -1120,6 +1135,7 @@
<PHRASE Label="la_section_UsersSearch" Module="Core" Type="1">U2VhcmNoIFVzZXJz</PHRASE>
<PHRASE Label="la_section_Values" Module="Core" Type="1">VmFsdWVz</PHRASE>
<PHRASE Label="la_SelectColumns" Module="Core" Type="1">U2VsZWN0IENvbHVtbnM=</PHRASE>
+ <PHRASE Label="la_SelectedItems" Module="Core" Type="1">U2VsZWN0ZWQgSXRlbXM=</PHRASE>
<PHRASE Label="la_selecting_categories" Module="Core" Type="1">U2VsZWN0aW5nIFNlY3Rpb25z</PHRASE>
<PHRASE Label="la_SeparatedCategoryPath" Module="Core" Type="1">T25lIGZpZWxkIGZvciBlYWNoIHNlY3Rpb24gbGV2ZWw=</PHRASE>
<PHRASE Label="la_ShortToolTip_Clone" Module="Core" Type="1">Q2xvbmU=</PHRASE>
@@ -1344,6 +1360,7 @@
<PHRASE Label="la_title_addingCustom" Module="Core" Type="1">QWRkaW5nIEN1c3RvbSBGaWVsZA==</PHRASE>
<PHRASE Label="la_title_AddingFile" Module="Core" Type="1">QWRkaW5nIEZpbGU=</PHRASE>
<PHRASE Label="la_title_AddingMailingList" Module="Core" Type="1">QWRkaW5nIE1haWxpbmcgTGlzdA==</PHRASE>
+ <PHRASE Label="la_title_AddingSiteDomain" Module="Core" Type="1">QWRkaW5nIFNpdGUgRG9tYWlu</PHRASE>
<PHRASE Label="la_title_AddingSkin" Module="Core" Type="1">QWRkaW5nIFNraW4=</PHRASE>
<PHRASE Label="la_title_AddingSpellingDictionary" Module="Core" Type="1">QWRkaW5nIFNwZWxsaW5nIERpY3Rpb25hcnk=</PHRASE>
<PHRASE Label="la_title_AddingStopWord" Module="Core" Type="1">QWRkaW5nIFN0b3AgV29yZA==</PHRASE>
@@ -1388,6 +1405,7 @@
<PHRASE Label="la_title_EditingEmailEvent" Module="Core" Type="1">RWRpdGluZyBFbWFpbCBFdmVudA==</PHRASE>
<PHRASE Label="la_title_EditingFile" Module="Core" Type="1">RWRpdGluZyBGaWxl</PHRASE>
<PHRASE Label="la_title_EditingMembership" Module="Core" Type="1">RWRpdGluZyBNZW1iZXJzaGlw</PHRASE>
+ <PHRASE Label="la_title_EditingSiteDomain" Module="Core" Type="1">RWRpdGluZyBTaXRlIERvbWFpbg==</PHRASE>
<PHRASE Label="la_title_EditingSkin" Module="Core" Type="1">RWRpdGluZyBTa2lu</PHRASE>
<PHRASE Label="la_title_EditingSpellingDictionary" Module="Core" Type="1">RWRpdGluZyBTcGVsbGluZyBEaWN0aW9uYXJ5</PHRASE>
<PHRASE Label="la_title_EditingStopWord" Module="Core" Type="1">RWRpdGluZyBTdG9wIFdvcmQ=</PHRASE>
@@ -1460,6 +1478,7 @@
<PHRASE Label="LA_TITLE_SENDEMAIL" Module="Core" Type="1">U2VuZCBFLW1haWw=</PHRASE>
<PHRASE Label="LA_TITLE_SENDINGPREPAREDEMAILS" Module="Core" Type="1">U2VuZGluZyBQcmVwYXJlZCBFLW1haWxz</PHRASE>
<PHRASE Label="la_Title_SendMailComplete" Module="Core" Type="1">TWFpbCBoYXMgYmVlbiBzZW50IFN1Y2Nlc3NmdWxseQ==</PHRASE>
+ <PHRASE Label="la_title_SiteDomains" Module="Core" Type="1">U2l0ZSBEb21haW5z</PHRASE>
<PHRASE Label="la_title_SpellingDictionary" Module="Core" Type="1">U3BlbGxpbmcgRGljdGlvbmFyeQ==</PHRASE>
<PHRASE Label="la_title_StopWords" Module="Core" Type="1">U3RvcCBXb3Jkcw==</PHRASE>
<PHRASE Label="la_title_Structure" Module="Core" Type="1">U3RydWN0dXJlICYgRGF0YQ==</PHRASE>
@@ -1515,6 +1534,7 @@
<PHRASE Label="la_ToolTip_NewPhrase" Module="Core" Type="1">TmV3IFBocmFzZQ==</PHRASE>
<PHRASE Label="la_ToolTip_NewReview" Module="Core" Type="1">TmV3IENvbW1lbnQ=</PHRASE>
<PHRASE Label="la_ToolTip_NewSearchConfig" Module="Core" Type="1">TmV3IFNlYXJjaCBGaWVsZA==</PHRASE>
+ <PHRASE Label="la_ToolTip_NewSiteDomain" Module="Core" Type="1">TmV3IFNpdGUgRG9tYWlu</PHRASE>
<PHRASE Label="la_ToolTip_NewStopWord" Module="Core" Type="1">TmV3IFN0b3AgV29yZA==</PHRASE>
<PHRASE Label="la_ToolTip_newstylesheet" Module="Core" Type="1">TmV3IFN0eWxlc2hlZXQ=</PHRASE>
<PHRASE Label="la_ToolTip_NewTerm" Module="Core" Type="1">TmV3IFRlcm0=</PHRASE>
Index: install/install_schema.sql
===================================================================
--- install/install_schema.sql (revision 13151)
+++ install/install_schema.sql (working copy)
@@ -1095,4 +1095,46 @@
KEY SessionKey (SessionKey),
KEY `Timestamp` (`Timestamp`),
KEY MainPrefix (MainPrefix)
-);
\ No newline at end of file
+);
+
+CREATE TABLE SiteDomains (
+ DomainId int(11) NOT NULL AUTO_INCREMENT,
+ DomainName varchar(255) NOT NULL DEFAULT '',
+ DomainNameUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ SSLUrl varchar(255) NOT NULL DEFAULT '',
+ SSLUrlUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ AdminEmail varchar(255) NOT NULL DEFAULT '',
+ Country varchar(3) NOT NULL DEFAULT '',
+ BillingCountry varchar(3) NOT NULL DEFAULT '',
+ ShippingCountry varchar(3) NOT NULL DEFAULT '',
+ PrimaryLanguageId int(11) NOT NULL DEFAULT '0',
+ Languages varchar(255) NOT NULL DEFAULT '',
+ PrimaryThemeId int(11) NOT NULL DEFAULT '0',
+ Themes varchar(255) NOT NULL DEFAULT '',
+ PrimaryCurrencyId int(11) NOT NULL DEFAULT '0',
+ Currencies varchar(255) NOT NULL DEFAULT '',
+ PrimaryPaymentTypeId int(11) NOT NULL DEFAULT '0',
+ PaymentTypes varchar(255) NOT NULL DEFAULT '',
+ DomainIPRange text NOT NULL,
+ RedirectOnIPMatch tinyint(4) NOT NULL DEFAULT '0',
+ Priority int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (DomainId),
+ KEY DomainName (DomainName),
+ KEY DomainNameUsesRegExp (DomainNameUsesRegExp),
+ KEY SSLUrl (SSLUrl),
+ KEY SSLUrlUsesRegExp (SSLUrlUsesRegExp),
+ KEY AdminEmail (AdminEmail),
+ KEY Country (Country),
+ KEY BillingCountry (BillingCountry),
+ KEY ShippingCountry (ShippingCountry),
+ KEY PrimaryLanguageId (PrimaryLanguageId),
+ KEY Languages (Languages),
+ KEY PrimaryThemeId (PrimaryThemeId),
+ KEY Themes (Themes),
+ KEY PrimaryCurrencyId (PrimaryCurrencyId),
+ KEY Currencies (Currencies),
+ KEY PrimaryPaymentTypeId (PrimaryPaymentTypeId),
+ KEY PaymentTypes (PaymentTypes),
+ KEY RedirectOnIPMatch (RedirectOnIPMatch),
+ KEY Priority (Priority)
+);
Index: install/remove_schema.sql
===================================================================
--- install/remove_schema.sql (revision 13140)
+++ install/remove_schema.sql (working copy)
@@ -68,3 +68,4 @@
DROP TABLE FormSubmissions;
DROP TABLE Forms;
DROP TABLE Semaphores;
+DROP TABLE SiteDomains;
Index: install/upgrades.sql
===================================================================
--- install/upgrades.sql (revision 13151)
+++ install/upgrades.sql (working copy)
@@ -1650,3 +1650,45 @@
DELETE FROM Phrase WHERE Phrase LIKE 'la_event_%';
DELETE FROM PersistantSessionData WHERE VariableName = 'phrases_columns_.';
+
+CREATE TABLE SiteDomains (
+ DomainId int(11) NOT NULL AUTO_INCREMENT,
+ DomainName varchar(255) NOT NULL DEFAULT '',
+ DomainNameUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ SSLUrl varchar(255) NOT NULL DEFAULT '',
+ SSLUrlUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ AdminEmail varchar(255) NOT NULL DEFAULT '',
+ Country varchar(3) NOT NULL DEFAULT '',
+ BillingCountry varchar(3) NOT NULL DEFAULT '',
+ ShippingCountry varchar(3) NOT NULL DEFAULT '',
+ PrimaryLanguageId int(11) NOT NULL DEFAULT '0',
+ Languages varchar(255) NOT NULL DEFAULT '',
+ PrimaryThemeId int(11) NOT NULL DEFAULT '0',
+ Themes varchar(255) NOT NULL DEFAULT '',
+ PrimaryCurrencyId int(11) NOT NULL DEFAULT '0',
+ Currencies varchar(255) NOT NULL DEFAULT '',
+ PrimaryPaymentTypeId int(11) NOT NULL DEFAULT '0',
+ PaymentTypes varchar(255) NOT NULL DEFAULT '',
+ DomainIPRange text NOT NULL,
+ RedirectOnIPMatch tinyint(4) NOT NULL DEFAULT '0',
+ Priority int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (DomainId),
+ KEY DomainName (DomainName),
+ KEY DomainNameUsesRegExp (DomainNameUsesRegExp),
+ KEY SSLUrl (SSLUrl),
+ KEY SSLUrlUsesRegExp (SSLUrlUsesRegExp),
+ KEY AdminEmail (AdminEmail),
+ KEY Country (Country),
+ KEY BillingCountry (BillingCountry),
+ KEY ShippingCountry (ShippingCountry),
+ KEY PrimaryLanguageId (PrimaryLanguageId),
+ KEY Languages (Languages),
+ KEY PrimaryThemeId (PrimaryThemeId),
+ KEY Themes (Themes),
+ KEY PrimaryCurrencyId (PrimaryCurrencyId),
+ KEY Currencies (Currencies),
+ KEY PrimaryPaymentTypeId (PrimaryPaymentTypeId),
+ KEY PaymentTypes (PaymentTypes),
+ KEY RedirectOnIPMatch (RedirectOnIPMatch),
+ KEY Priority (Priority)
+);
Index: kernel/application.php
===================================================================
--- kernel/application.php (revision 13128)
+++ kernel/application.php (working copy)
@@ -624,16 +624,56 @@
function GetPrimaryCurrency()
{
- if ($this->isModuleEnabled('In-Commerce')) {
- $table = $this->getUnitOption('curr', 'TableName');
- return $this->Conn->GetOne('SELECT ISO FROM '.$table.' WHERE IsPrimary = 1');
+ static $currency_iso = '';
+
+ if ($currency_iso) {
+ return $currency_iso;
}
+
+ if ($this->prefixRegistred('curr')) {
+ $currency_id = $this->siteDomainField('PrimaryCurrencyId');
+
+ $sql = 'SELECT ISO
+ FROM ' . $this->getUnitOption('curr', 'TableName') . '
+ WHERE ' . ($currency_id > 0 ? 'CurrencyId = ' . $currency_id : 'IsPrimary = 1');
+ $currency_iso = $this->Conn->GetOne($sql);
+ }
else {
- return 'USD';
+ $currency_iso = 'USD';
}
+
+ return $currency_iso;
}
/**
+ * Returns site domain field. When none of site domains are found false is returned.
+ *
+ * @param string $field
+ * @param bool $formatted
+ * @param string $format
+ */
+ function siteDomainField($field, $formatted = false, $format = null)
+ {
+ static $site_domain = null;
+
+ if ($this->isAdmin) {
+ // don't apply any filtering in administrative console
+ return false;
+ }
+
+ if (!isset($site_domain)) {
+ $site_domain =& $this->recallObject('site-domain.current');
+ /* @var $site_domain kDBItem */
+ }
+
+ if ($site_domain->isLoaded()) {
+ return $formatted ? $site_domain->GetField($field, $format) : $site_domain->GetDBField($field);
+ }
+
+ return false;
+ }
+
+ /**
* Registers default classes such as ItemController, GridController and LoginController
*
* Called automatically while initializing Application
@@ -1400,18 +1440,13 @@
$ssl = isset($params['__SSL__']) ? $params['__SSL__'] : null;
if ($ssl !== null) {
$session =& $this->recallObject('Session');
- $cookie_url = trim($session->CookieDomain.$session->CookiePath, '/.');
- if ($ssl) {
- $target_url = defined('ADMIN') && ADMIN ? $this->ConfigValue('AdminSSL_URL') : false;
- if (!$target_url) {
- $target_url = $this->ConfigValue('SSL_URL');
- }
- }
- else {
- $target_url = 'http://'.DOMAIN.$this->ConfigValue('Site_Path');
- }
+ /* @var $session Session */
- if (!preg_match('#'.preg_quote($cookie_url).'#', $target_url)) {
+ $target_url = rtrim($this->BaseURL('', $ssl, false), '/');
+ $cookie_url = trim($session->CookieDomain . $session->CookiePath, '/.');
+
+ if (!preg_match('#' . preg_quote($cookie_url) . '#', $target_url)) {
+ // when SSL<->NON-SSL redirect to different domain pass SID in url
$session->SetMode(smGET_ONLY);
}
}
@@ -1895,24 +1930,33 @@
return $ret;
}
- function BaseURL($prefix='', $ssl=null)
+ function BaseURL($prefix = '', $ssl = null, $add_port = true)
{
if ($ssl === null) {
- return PROTOCOL.SERVER_NAME.(defined('PORT')?':'.PORT : '').rtrim(BASE_PATH, '/').$prefix.'/';
+ // stay on same encryption level
+ return PROTOCOL . SERVER_NAME . ($add_port && defined('PORT') ? ':' . PORT : '') . rtrim(BASE_PATH, '/') . $prefix . '/';
}
- else {
- if ($ssl) {
- $base_url = defined('ADMIN') && ADMIN ? $this->ConfigValue('AdminSSL_URL') : false;
- if (!$base_url) {
- $base_url = $this->ConfigValue('SSL_URL');
- }
- return rtrim($base_url, '/').$prefix.'/';
+ if ($ssl) {
+ // going from http:// to https://
+ $base_url = $this->isAdmin ? $this->ConfigValue('AdminSSL_URL') : false;
+
+ if (!$base_url) {
+ $ssl_url = $this->siteDomainField('SSLUrl');
+ $base_url = $ssl_url !== false ? $ssl_url : $this->ConfigValue('SSL_URL');
}
- else {
- return 'http://'.DOMAIN.(defined('PORT')?':'.PORT : '').rtrim( $this->ConfigValue('Site_Path'), '/').$prefix.'/';
- }
+
+ return rtrim($base_url, '/') . $prefix . '/';
}
+
+ // going from https:// to http://
+ $domain = $this->siteDomainField('DomainName');
+
+ if ($domain === false) {
+ $domain = DOMAIN;
+ }
+
+ return 'http://' . $domain . ($add_port && defined('PORT') ? ':' . PORT : '') . rtrim($this->ConfigValue('Site_Path'), '/') . $prefix . '/';
}
function Redirect($t='', $params=null, $prefix='', $index_file=null)
@@ -2129,6 +2173,14 @@
*/
function ConfigValue($name)
{
+ if ($name == 'Smtp_AdminMailFrom') {
+ $res = $this->siteDomainField('AdminEmail');
+
+ if ($res) {
+ return $res;
+ }
+ }
+
$res = array_key_exists($name, $this->ConfigHash) ? $this->ConfigHash[$name] : false;
if ($res !== false) {
return $res;
Index: kernel/globals.php
===================================================================
--- kernel/globals.php (revision 13128)
+++ kernel/globals.php (working copy)
@@ -560,17 +560,26 @@
return $ip_match;
}
- function netMatch($network, $ip) {
+ function netMatch($network, $ip)
+ {
$network = trim($network);
$ip = trim($ip);
if ($network == $ip) {
- // comparing 2 ip addresses directly
+ // comparing two ip addresses directly
return true;
}
$d = strpos($network, '-');
- if ($d === false) {
+ if ($d !== false) {
+ // ip address range specified
+ $from = ip2long(trim(substr($network, 0, $d)));
+ $to = ip2long(trim(substr($network, $d + 1)));
+
+ $ip = ip2long($ip);
+ return ($ip >= $from && $ip <= $to);
+ }
+ elseif (strpos($network, '/') !== false) {
// sigle subnet specified
$ip_arr = explode('/', $network);
@@ -586,14 +595,8 @@
return ($ip_long & $mask) == ($network_long & $mask);
}
- else {
- // ip address range specified
- $from = ip2long(trim(substr($network, 0, $d)));
- $to = ip2long(trim(substr($network, $d + 1)));
- $ip = ip2long($ip);
- return ($ip >= $from && $ip <= $to);
- }
+ return false;
}
function request_headers()
Index: kernel/processors/main_processor.php
===================================================================
--- kernel/processors/main_processor.php (revision 13128)
+++ kernel/processors/main_processor.php (working copy)
@@ -825,10 +825,14 @@
if (!$ssl) {
// not in admin or admin ssl url is empty
- $ssl = $this->Application->ConfigValue('SSL_URL');
+ $ssl_url = $this->Application->siteDomainField('SSLUrl');
+ $ssl = $ssl_url !== false ? $ssl_url : $this->Application->ConfigValue('SSL_URL');
}
- if (!$ssl) return; //SSL URL is not set - no way to require SSL
+ if (!$ssl) {
+ // SSL URL is not set - no way to require SSL
+ return;
+ }
$require = false;
Index: units/admin/admin_tag_processor.php
===================================================================
--- units/admin/admin_tag_processor.php (revision 13128)
+++ units/admin/admin_tag_processor.php (working copy)
@@ -147,7 +147,6 @@
return '';
}
-
if (array_key_exists('parent', $params) && $params['parent']) {
do {
$section = $section_data['parent'];
@@ -175,13 +174,15 @@
break;
case 'label':
- $res = $section_data['label'];
- if ($section != 'in-portal:root') {
+ if ($section && ($section != 'in-portal:root')) {
// don't translate label for top section, because it's already translated
$no_editing = array_key_exists('no_editing', $params) ? $params['no_editing'] : false;
- $res = $this->Application->Phrase($res, !$no_editing);
+ $res = $this->Application->Phrase($section_data['label'], !$no_editing);
}
+ else {
+ $res = '';
+ }
break;
default:
Index: units/helpers/helpers_config.php
===================================================================
--- units/helpers/helpers_config.php (revision 13128)
+++ units/helpers/helpers_config.php (working copy)
@@ -58,5 +58,6 @@
Array ('class' => 'kXMLHelper', 'pseudo' => 'kXMLHelper', 'file' => 'xml_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
Array ('class' => 'kCatDBItemExportHelper', 'pseudo' => 'CatItemExportHelper', 'file' => 'cat_dbitem_export_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
Array ('class' => 'EmailMessageHelper', 'pseudo' => 'EmailMessageHelper', 'file' => 'email_message_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
+ Array ('class' => 'SiteHelper', 'pseudo' => 'SiteHelper', 'file' => 'site_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
),
);
\ No newline at end of file
Index: units/helpers/mod_rewrite_helper.php
===================================================================
--- units/helpers/mod_rewrite_helper.php (revision 13128)
+++ units/helpers/mod_rewrite_helper.php (working copy)
@@ -45,6 +45,20 @@
var $_templateAliases = null;
/**
+ * Domain-based primary language id
+ *
+ * @var int
+ */
+ var $primaryLanguageId = false;
+
+ /**
+ * Domain-based primary theme id
+ *
+ * @var int
+ */
+ var $primaryThemeId = false;
+
+ /**
* Constructor of kModRewriteHelper class
*
* @return kModRewriteHelper
@@ -54,6 +68,12 @@
parent::kHelper();
$this->HTTPQuery =& $this->Application->recallObject('HTTPQuery');
+
+ // domain based primary language
+ $this->primaryLanguageId = $this->Application->siteDomainField('PrimaryLanguageId');
+
+ // domain based primary theme
+ $this->primaryThemeId = $this->Application->siteDomainField('PrimaryThemeId');
}
function processRewriteURL()
@@ -329,8 +349,12 @@
}
// add language
- $default_language_id = $this->Application->GetDefaultLanguageId();
- if ($processed_params['m_lang'] && ($processed_params['m_lang'] != $default_language_id)) {
+ if (!$this->primaryLanguageId) {
+ // when domain-based language not found -> use site-wide language
+ $this->primaryLanguageId = $this->Application->GetDefaultLanguageId();
+ }
+
+ if ($processed_params['m_lang'] && ($processed_params['m_lang'] != $this->primaryLanguageId)) {
$language_name = $this->Application->getCache('language_names', $processed_params['m_lang']);
if ($language_name === false) {
$sql = 'SELECT PackName
@@ -345,8 +369,12 @@
}
// add theme
- $default_theme_id = $this->Application->GetDefaultThemeId(true);
- if ($processed_params['m_theme'] && ($processed_params['m_theme'] != $default_theme_id)) {
+ if (!$this->primaryThemeId) {
+ // when domain-based language not found -> use site-wide language
+ $this->primaryThemeId = $this->Application->GetDefaultThemeId(true);
+ }
+
+ if ($processed_params['m_theme'] && ($processed_params['m_theme'] != $this->primaryThemeId)) {
$theme_name = $this->Application->getCache('theme_names', $processed_params['m_theme']);
if ($theme_name === false) {
$sql = 'SELECT Name
@@ -454,6 +482,10 @@
// language was found by pack name
array_shift($url_parts);
}
+ elseif ($this->primaryLanguageId) {
+ // use domain-based primary language instead of site-wide primary language
+ $vars['m_lang'] = $this->primaryLanguageId;
+ }
return true;
}
@@ -498,6 +530,10 @@
// theme was found by name
array_shift($url_parts);
}
+ elseif ($this->primaryThemeId) {
+ // use domain-based primary theme instead of site-wide primary theme
+ $vars['m_theme'] = $this->primaryThemeId;
+ }
return true;
}
@@ -976,17 +1012,31 @@
}
/**
- * Sets default parsed values before actual url parsing
+ * Sets default parsed values before actual url parsing (only, for empty url)
*
* @param Array $vars
*/
function _setDefaultValues(&$vars)
{
- $defaults = Array ('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's', 't' => 'index');
+ $defaults = Array (
+ 'm_cat_id' => 0, // no category
+ 'm_cat_page' => 1, // first category page
+ 'm_opener' => 's', // stay on same page
+ 't' => 'index' // main site page
+ );
+ if ($this->primaryLanguageId) {
+ // domain-based primary language
+ $defaults['m_lang'] = $this->primaryLanguageId;
+ }
+
+ if ($this->primaryThemeId) {
+ // domain-based primary theme
+ $defaults['m_theme'] = $this->primaryThemeId;
+ }
+
foreach ($defaults as $default_key => $default_value) {
- // bug: null is never returned
- if ($this->HTTPQuery->Get($default_key) == null) {
+ if ($this->HTTPQuery->Get($default_key) === false) {
$vars[$default_key] = $default_value;
}
}
Index: units/helpers/site_helper.php
===================================================================
--- units/helpers/site_helper.php (revision 0)
+++ units/helpers/site_helper.php (revision 0)
@@ -0,0 +1,44 @@
+<?php
+
+ class SiteHelper extends kHelper {
+
+ /**
+ * Returns default country
+ *
+ * @return string
+ */
+ function getDefaultCountry($country_prefix = '', $iso_format = true)
+ {
+ $country = $this->Application->siteDomainField($country_prefix . 'Country');
+
+ if ($iso_format && !$country) {
+ $country = 'USA';
+ }
+
+ if (!$iso_format && strlen($country)) {
+ return $this->getCountryId($country);
+ }
+
+ return $country;
+ }
+
+ /**
+ * Returns country id based on it's ISO code
+ *
+ * @param string $iso_code
+ * @return int
+ */
+ function getCountryId($iso_code)
+ {
+ static $cache = null;
+
+ if (!isset($cache)) {
+ $sql = 'SELECT DestId, DestAbbr
+ FROM ' . TABLE_PREFIX . 'StdDestinations
+ WHERE DestType = 1';
+ $cache = $this->Conn->GetCol($sql, 'DestAbbr');
+ }
+
+ return $cache[$iso_code];
+ }
+ }
Index: units/languages/languages_event_handler.php
===================================================================
--- units/languages/languages_event_handler.php (revision 13151)
+++ units/languages/languages_event_handler.php (working copy)
@@ -160,12 +160,28 @@
*/
function SetCustomQuery(&$event)
{
- if ($event->Special == 'enabled') {
- $object =& $event->getObject();
- /* @var $object kDBList */
+ $object =& $event->getObject();
+ /* @var $object kDBList */
- $object->addFilter('enabled_filter', '%1$s.Enabled = 1');
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available'))) {
+ $object->addFilter('enabled_filter', '%1$s.Enabled = ' . STATUS_ACTIVE);
}
+
+ // site domain language picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'Languages');
+ }
+
+ // apply domain-based language filtering
+ $languages = $this->Application->siteDomainField('Languages');
+
+ if (strlen($languages)) {
+ $languages = explode('|', substr($languages, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.LanguageId IN (' . implode(',', $languages) . ')');
+ }
}
/**
Index: units/site_domains/site_domain_eh.php
===================================================================
--- units/site_domains/site_domain_eh.php (revision 0)
+++ units/site_domains/site_domain_eh.php (revision 0)
@@ -0,0 +1,205 @@
+<?php
+
+ class SiteDomainEventHandler extends kDBEventHandler {
+
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+
+ $permissions = Array (
+ 'OnItemBuild' => Array ('self' => true),
+ );
+
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Returns ID of site domain, that matches current url
+ *
+ * @param kEvent $event
+ */
+ function getPassedID(&$event)
+ {
+ if ($event->Special == 'current') {
+ if ($this->Application->isAdmin) {
+ $event->setEventParam('raise_warnings', 0);
+ }
+ else {
+ if (PROTOCOL == 'https://') {
+ return $this->querySiteDomain('SSLUrl', rtrim($this->Application->BaseURL(), '/'));
+ }
+
+ return $this->querySiteDomain('DomainName', $_SERVER['HTTP_HOST']);
+ }
+ }
+
+ return parent::getPassedID($event);
+ }
+
+ function querySiteDomain($field, $value)
+ {
+ $site_domains = $this->getSiteDomains();
+ $name_fields = Array ('DomainName', 'SSLUrl');
+
+ // 1. try to match visited domain to any of existing
+ foreach ($site_domains as $id => $site_domain) {
+ if (in_array($field, $name_fields) && $site_domain[$field . 'UsesRegExp']) {
+ if (preg_match('/^' . $site_domain[$field] . '$/', $value)) {
+ return $id;
+ }
+ }
+ elseif ($site_domain[$field] == $value) {
+ return $id;
+ }
+
+ }
+
+ // 2. try to match domain settings based on visitor's IP address
+ foreach ($site_domains as $id => $site_domain) {
+ if (ipMatch($site_domain['DomainIPRange'], "\n")) {
+ if ($site_domain['RedirectOnIPMatch']) {
+ $this->Application->Redirect('external:http://' . $site_domain['DomainName'] . $_SERVER['REQUEST_URI']);
+ }
+
+ return $id;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Load item if id is available
+ *
+ * @param kEvent $event
+ */
+ function LoadItem(&$event)
+ {
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $id = (int)$this->getPassedID($event);
+
+ if ($object->isLoaded() && ($object->GetID() == $id)) {
+ // object is already loaded by same id
+ return ;
+ }
+
+ $object->setID($id);
+ $site_domains = $this->getSiteDomains();
+
+ if (array_key_exists($id, $site_domains)) {
+ $object->Loaded = true;
+ $object->SetDBFieldsFromHash($site_domains[$id]);
+
+ $actions =& $this->Application->recallObject('kActions');
+ $actions->Set($event->Prefix_Special.'_id', $object->GetID() );
+ }
+ else {
+ $object->Loaded = false;
+ }
+ }
+
+ function getSiteDomains()
+ {
+ static $cache = null;
+
+ if (!isset($cache)) {
+ $sql = 'SELECT Data
+ FROM ' . TABLE_PREFIX . 'Cache
+ WHERE VarName = "domains_parsed"';
+ $cache = $this->Conn->GetOne($sql);
+
+ if ($cache) {
+ $cache = unserialize($cache);
+ }
+ else {
+ $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+
+ $sql = 'SELECT *
+ FROM ' . $table_name . '
+ ORDER BY Priority DESC';
+ $cache = $this->Conn->Query($sql, $id_field);
+
+ $fields_hash = Array (
+ 'VarName' => 'domains_parsed',
+ 'Data' => serialize($cache),
+ 'Cached' => adodb_mktime(),
+ );
+
+ $this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'Cache');
+ }
+ }
+
+ return $cache;
+ }
+
+ /**
+ * Removes In-Commerce related fields, when it's not installed
+ *
+ * @param kEvent $event
+ */
+ function OnAfterConfigRead(&$event)
+ {
+ parent::OnAfterConfigRead($event);
+
+ if (!$this->Application->isModuleEnabled('In-Commerce')) {
+ $remove_fields = Array (
+ 'BillingCountry', 'ShippingCountry',
+ 'PrimaryCurrencyId', 'Currencies',
+ 'PrimaryPaymentTypeId', 'PaymentTypes'
+ );
+
+ // remove field definitions
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+
+ foreach ($remove_fields as $remove_field) {
+ unset($fields[$remove_field]);
+ }
+
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+
+ // remove grid columns
+ $grids = $this->Application->getUnitOption($event->Prefix, 'Grids');
+
+ foreach ($grids as $grid_name => $grid_info) {
+ foreach ($remove_fields as $remove_field) {
+ if (array_key_exists($remove_field, $grid_info['Fields'])) {
+ unset($grids[$grid_name]['Fields'][$remove_field]);
+ }
+ }
+ }
+
+ $this->Application->setUnitOption($event->Prefix, 'Grids', $grids);
+ }
+ }
+
+ /**
+ * Delete cached information about site domains
+ *
+ * @param kEvent $event
+ */
+ function OnSave(&$event)
+ {
+ parent::OnSave($event);
+
+ if ($event->status == erSUCCESS) {
+ $this->_deleteCache();
+ }
+ }
+
+ /**
+ * Deletes cached information about site domains
+ */
+ function _deleteCache()
+ {
+ $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Cache
+ WHERE VarName = "domains_parsed"';
+ $this->Conn->Query($sql);
+ }
+ }
\ No newline at end of file
Index: units/site_domains/site_domains_config.php
===================================================================
--- units/site_domains/site_domains_config.php (revision 0)
+++ units/site_domains/site_domains_config.php (revision 0)
@@ -0,0 +1,180 @@
+<?php
+ $config = Array (
+ 'Prefix' => 'site-domain',
+ 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
+ 'EventHandlerClass' => Array ('class' => 'SiteDomainEventHandler', 'file' => 'site_domain_eh.php', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+
+ 'AutoLoad' => true,
+
+ 'QueryString' => Array (
+ 1 => 'id',
+ 2 => 'Page',
+ 3 => 'event',
+ 4 => 'mode',
+ ),
+
+ 'IDField' => 'DomainId',
+
+ 'TableName' => TABLE_PREFIX . 'SiteDomains',
+
+ 'TitleField' => 'DomainName',
+
+ 'TitlePresets' => Array (
+ 'default' => Array (
+ 'new_status_labels' => Array ('site-domain' => '!la_title_AddingSiteDomain!'),
+ 'edit_status_labels' => Array ('site-domain' => '!la_title_EditingSiteDomain!'),
+ ),
+
+ 'site_domain_list' => Array (
+ 'prefixes' => Array ('site-domain_List'), 'format' => "!la_title_SiteDomains!",
+ 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'view', 'dbl-click'),
+ ),
+
+ 'site_domain_edit' => Array (
+ 'prefixes' => Array ('site-domain'), 'format' => "#site-domain_status# '#site-domain_titlefield#'",
+ 'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
+ ),
+ ),
+
+ 'PermSection' => Array('main' => 'in-portal:site_domains'),
+
+ 'Sections' => Array (
+ 'in-portal:site_domains' => Array (
+ 'parent' => 'in-portal:website_setting_folder',
+ 'icon' => 'site_domain',
+ 'label' => 'la_title_SiteDomains',
+ 'url' => Array('t' => 'site_domains/site_domain_list', 'pass' => 'm'),
+ 'permissions' => Array('view', 'add', 'edit', 'delete'),
+ 'priority' => 7,
+ 'type' => stTREE,
+ ),
+ ),
+
+ 'ListSQLs' => Array (
+ '' => ' SELECT %1$s.* %2$s FROM %1$s',
+ ),
+
+ 'ListSortings' => Array (
+ '' => Array (
+ 'Sorting' => Array ('Priority' => 'desc', 'DomainName' => 'asc'),
+ )
+ ),
+
+ 'Fields' => Array (
+ 'DomainId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'DomainName' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'required' => 1, 'default' => ''),
+ 'DomainNameUsesRegExp' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'SSLUrl' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
+ 'SSLUrlUsesRegExp' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'AdminEmail' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
+ 'Country' => Array (
+ 'type' => 'string', 'max_len' => 3,
+ 'formatter' => 'kOptionsFormatter',
+ 'options_sql' => ' SELECT %1$s
+ FROM ' . TABLE_PREFIX . 'StdDestinations
+ LEFT JOIN ' . TABLE_PREFIX . 'Phrase p ON p.Phrase = ' . TABLE_PREFIX . 'StdDestinations.DestName
+ WHERE DestType = 1
+ ORDER BY l%2$s_Translation',
+ 'option_key_field' => 'DestAbbr', 'option_title_field' => 'l%2$s_Translation',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'BillingCountry' => Array (
+ 'type' => 'string', 'max_len' => 3,
+ 'formatter' => 'kOptionsFormatter',
+ 'options_sql' => ' SELECT %1$s
+ FROM ' . TABLE_PREFIX . 'StdDestinations
+ LEFT JOIN ' . TABLE_PREFIX . 'Phrase p ON p.Phrase = ' . TABLE_PREFIX . 'StdDestinations.DestName
+ WHERE DestType = 1
+ ORDER BY l%2$s_Translation',
+ 'option_key_field' => 'DestAbbr', 'option_title_field' => 'l%2$s_Translation',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'ShippingCountry' => Array (
+ 'type' => 'string', 'max_len' => 3,
+ 'formatter' => 'kOptionsFormatter',
+ 'options_sql' => ' SELECT %1$s
+ FROM ' . TABLE_PREFIX . 'StdDestinations
+ LEFT JOIN ' . TABLE_PREFIX . 'Phrase p ON p.Phrase = ' . TABLE_PREFIX . 'StdDestinations.DestName
+ WHERE DestType = 1
+ ORDER BY l%2$s_Translation',
+ 'option_key_field' => 'DestAbbr', 'option_title_field' => 'l%2$s_Translation',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryLanguageId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language WHERE Enabled = 1 ORDER BY PackName ASC', 'option_key_field' => 'LanguageId', 'option_title_field' => 'PackName',
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Languages' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language WHERE Enabled = 1 ORDER BY PackName ASC', 'option_key_field' => 'LanguageId', 'option_title_field' => 'PackName',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryThemeId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Theme WHERE Enabled = 1 ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Themes' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Theme WHERE Enabled = 1 ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryCurrencyId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Currencies WHERE Status = 1 ORDER BY ISO', 'option_key_field' => 'CurrencyId', 'option_title_field' => 'Name', 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Currencies' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Currencies WHERE Status = 1 ORDER BY ISO', 'option_key_field' => 'CurrencyId', 'option_title_field' => 'Name', 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryPaymentTypeId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PaymentTypes WHERE Status = 1 ORDER BY Name ASC', 'option_key_field' => 'PaymentTypeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'PaymentTypes' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PaymentTypes WHERE Status = 1 ORDER BY Name ASC', 'option_key_field' => 'PaymentTypeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'DomainIPRange' => Array ('type' => 'string', 'not_null' => 1, 'default' => NULL),
+ 'RedirectOnIPMatch' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Priority' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ ),
+
+ 'Grids' => Array (
+ 'Default' => Array (
+ 'Icons' => Array ('default' => 'icon16_item.png'),
+ 'Fields' => Array (
+ 'DomainId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
+ 'DomainName' => Array ('title' => 'la_col_DomainName', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
+ 'SSLUrl' => Array ('title' => 'la_col_SSLUrl', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
+ 'Country' => Array ('title' => 'la_col_Country', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'BillingCountry' => Array ('title' => 'la_col_BillingCountry', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'ShippingCountry' => Array ('title' => 'la_col_ShippingCountry', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryLanguageId' => Array ('title' => 'la_col_Language', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryThemeId' => Array ('title' => 'la_col_Theme', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryCurrencyId' => Array ('title' => 'la_col_Currency', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryPaymentTypeId' => Array ('title' => 'la_col_PaymentType', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'Priority' => Array ('title' => 'la_col_Priority', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
+ ),
+ ),
+ ),
+ );
\ No newline at end of file
Index: units/themes/themes_eh.php
===================================================================
--- units/themes/themes_eh.php (revision 13128)
+++ units/themes/themes_eh.php (working copy)
@@ -153,13 +153,28 @@
{
parent::SetCustomQuery($event);
- if ($event->Special == 'enabled' || !$this->Application->isAdminUser) {
+ $object =& $event->getObject();
+ /* @var $object kDBList */
+
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser) {
// "enabled" special or Front-End
+ $object->addFilter('enabled_filter', '%1$s.Enabled = ' . STATUS_ACTIVE);
+ }
- $object =& $event->getObject();
- /* @var $object kDBList */
+ // site domain theme picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
- $object->addFilter('enabled_filter', '%1$s.Enabled = 1');
+ $edit_picker_helper->applyFilter($event, 'Themes');
}
+
+ // apply domain-based theme filtering
+ $themes = $this->Application->siteDomainField('Themes');
+
+ if (strlen($themes)) {
+ $themes = explode('|', substr($themes, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.ThemeId IN (' . implode(',', $themes) . ')');
+ }
}
}
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 13128)
+++ units/users/users_event_handler.php (working copy)
@@ -1581,7 +1581,15 @@
parent::OnAfterConfigRead($event);
// 1. arrange user registration countries
- $first_country = $this->Application->ConfigValue('User_Default_Registration_Country');
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $first_country = $site_helper->getDefaultCountry('', false);
+
+ if ($first_country === false) {
+ $first_country = $this->Application->ConfigValue('User_Default_Registration_Country');
+ }
+
if ($first_country) {
// update user country dropdown sql
$fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
@@ -1625,7 +1633,6 @@
$this->Application->setUnitOption($event->Prefix, 'EditTabPresets', $edit_tab_presets);
}
}
-
}
/**
site_domains_modules.patch [^] (12,703 bytes) 2010-02-03 06:21
[Show Content]
Index: install/english.lang
===================================================================
--- install/english.lang (revision 13137)
+++ install/english.lang (working copy)
@@ -90,6 +90,7 @@
<PHRASE Label="la_col_Amount" Module="In-Commerce" Type="1">QW1vdW50</PHRASE>
<PHRASE Label="la_col_Availability" Module="In-Commerce" Type="1">QXZhaWwu</PHRASE>
<PHRASE Label="la_col_BaseFee" Module="In-Commerce" Type="1">QmFzZSBGZWU=</PHRASE>
+ <PHRASE Label="la_col_BillingCountry" Module="In-Commerce" Type="1">QmlsbGluZyBDb3VudHJ5</PHRASE>
<PHRASE Label="la_col_BuiltIn" Module="In-Commerce" Type="1">QnVpbHQtSW4=</PHRASE>
<PHRASE Label="la_col_CODallowed" Module="In-Commerce" Type="1">Q09EIEFsbG93ZWQ=</PHRASE>
<PHRASE Label="la_col_Code" Module="In-Commerce" Type="1">Q29kZQ==</PHRASE>
@@ -103,6 +104,7 @@
<PHRASE Label="la_col_CouponCode" Module="In-Commerce" Type="1">Q291cG9uIENvZGU=</PHRASE>
<PHRASE Label="la_col_CouponItemType" Module="In-Commerce" Type="1">Q291cG9uIEl0ZW0gVHlwZQ==</PHRASE>
<PHRASE Label="la_col_CreditCardNumber" Module="In-Commerce" Type="1">Q3JlZGl0IENhcmQgTnVtYmVy</PHRASE>
+ <PHRASE Label="la_col_Currency" Module="In-Commerce" Type="1">Q3VycmVuY3k=</PHRASE>
<PHRASE Label="la_col_CurrencyName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_col_CurrencySymbol" Module="In-Commerce" Type="1">U3ltYm9s</PHRASE>
<PHRASE Label="la_col_CurrencySymbolPosition" Module="In-Commerce" Type="1">U3ltYm9sIFBvc2l0aW9u</PHRASE>
@@ -180,6 +182,7 @@
<PHRASE Label="la_col_ReturnedOn" Module="In-Commerce" Type="1">UmV0LiBEYXRl</PHRASE>
<PHRASE Label="la_col_ReturnType" Module="In-Commerce" Type="1">UmV0LiBUeXBl</PHRASE>
<PHRASE Label="la_col_Shipping" Module="In-Commerce" Type="1">U2hpcHBpbmc=</PHRASE>
+ <PHRASE Label="la_col_ShippingCountry" Module="In-Commerce" Type="1">U2hpcHBpbmcgQ291bnRyeQ==</PHRASE>
<PHRASE Label="la_col_ShippingFromLocation" Module="In-Commerce" Type="1">RnJvbSBMb2NhdGlvbg==</PHRASE>
<PHRASE Label="la_col_ShippingName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_col_ShippingQuoteEngineName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
@@ -311,6 +314,8 @@
<PHRASE Label="la_fld_CostType" Module="In-Commerce" Type="1">Q29zdCBUeXBl</PHRASE>
<PHRASE Label="la_fld_CouponCode" Module="In-Commerce" Type="1">Q291cG9uIENvZGU=</PHRASE>
<PHRASE Label="la_fld_CreditCardNumber" Module="In-Commerce" Type="1">Q3JlZGl0IENhcmQgTnVtYmVy</PHRASE>
+ <PHRASE Label="la_fld_Currencies" Module="In-Commerce" Type="1">Q3VycmVuY2llcw==</PHRASE>
+ <PHRASE Label="la_fld_Currency" Module="In-Commerce" Type="1">Q3VycmVuY3k=</PHRASE>
<PHRASE Label="la_fld_CurrencyName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_fld_CurrencySymbol" Module="In-Commerce" Type="1">U3ltYm9s</PHRASE>
<PHRASE Label="la_fld_CurrencySymbolPosition" Module="In-Commerce" Type="1">U3ltYm9sIFBvc2l0aW9u</PHRASE>
@@ -381,6 +386,7 @@
<PHRASE Label="la_fld_PaymentType" Module="In-Commerce" Type="1">UGF5bWVudCBUeXBl</PHRASE>
<PHRASE Label="la_fld_PaymentTypeCurrencies" Module="In-Commerce" Type="1">QXZhaWxhYmxlIEN1cnJlbmNpZXM=</PHRASE>
<PHRASE Label="la_fld_PaymentTypeId" Module="In-Commerce" Type="1">UGF5bWVudCBUeXBlIElk</PHRASE>
+ <PHRASE Label="la_fld_PaymentTypes" Module="In-Commerce" Type="1">UGF5bWVudCBUeXBlcw==</PHRASE>
<PHRASE Label="la_fld_PercentSurcharge" Module="In-Commerce" Type="1">UGVyY2VudCBTdXJjaGFyZ2U=</PHRASE>
<PHRASE Label="la_fld_Period" Module="In-Commerce" Type="1">UGVyaW9k</PHRASE>
<PHRASE Label="la_fld_PlacedOrdersEdit" Module="In-Commerce" Type="1">QWxsb3cgUGxhY2VkIE9yZGVycyBFZGl0aW5n</PHRASE>
Index: units/addresses/addresses_event_handler.php
===================================================================
--- units/addresses/addresses_event_handler.php (revision 13128)
+++ units/addresses/addresses_event_handler.php (working copy)
@@ -318,4 +318,21 @@
return ;
}
}
+
+ /**
+ * Sets default country for new addresses to Latvia
+ *
+ * @param kEvent $event
+ */
+ function OnAfterConfigRead(&$event)
+ {
+ parent::OnAfterConfigRead($event);
+
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $fields['Country']['default'] = $site_helper->getDefaultCountry('Shipping');
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ }
}
\ No newline at end of file
Index: units/currencies/currencies_event_handler.php
===================================================================
--- units/currencies/currencies_event_handler.php (revision 13147)
+++ units/currencies/currencies_event_handler.php (working copy)
@@ -95,6 +95,23 @@
if (!$this->Application->isAdminUser) {
$object->addFilter('status_filter', $object->TableName.'.Status = 1');
}
+
+ // site domain currency picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'Currencies');
+ $object->addFilter('status_filter', '%1$s.Status = ' . STATUS_ACTIVE);
+ }
+
+ // apply domain-based currency filtering
+ $currencies = $this->Application->siteDomainField('Currencies');
+
+ if (strlen($currencies)) {
+ $currencies = explode('|', substr($currencies, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.CurrencyId IN (' . implode(',', $currencies) . ')');
+ }
}
/**
Index: units/currencies/currency_rates.php
===================================================================
--- units/currencies/currency_rates.php (revision 13128)
+++ units/currencies/currency_rates.php (working copy)
@@ -17,7 +17,6 @@
var $RateSource;
var $ExchangeRates = Array();
- var $PrimaryCurrency;
function kCurrencyRates()
{
@@ -30,7 +29,7 @@
// written :) just check that it's correct
$conn =& $this->Application->GetADODBConnection();
$table = $this->Application->getUnitOption('curr', 'TableName');
- $primary = $this->GetPrimaryCurrency();
+ $primary = $this->Application->GetPrimaryCurrency();
$sql = 'SELECT "'.$primary.'" AS TARGET, ISO AS ID, RateToPrimary As RATE, 1 AS UNITS FROM '.$table.' WHERE 1';
$rates = $conn->Query($sql);
foreach ($rates as $a_rate) {
@@ -40,8 +39,8 @@
function GetRate($source_cur, $target_cur, $units = 1)
{
- $source_cur = ($source_cur == 'PRIMARY') ? $this->GetPrimaryCurrency() : $source_cur;
- $target_cur = ($target_cur == 'PRIMARY') ? $this->GetPrimaryCurrency() : $target_cur;
+ $source_cur = ($source_cur == 'PRIMARY') ? $this->Application->GetPrimaryCurrency() : $source_cur;
+ $target_cur = ($target_cur == 'PRIMARY') ? $this->Application->GetPrimaryCurrency() : $target_cur;
if($source_cur == $target_cur)
{
return 1;
@@ -76,18 +75,6 @@
$this->ExchangeRates[$target_cur]['UNITS'] = $units;
}
- function GetPrimaryCurrency()
- {
- if(!$this->PrimaryCurrency)
- {
- $conn =& $this->Application->GetADODBConnection();
- $table = $this->Application->getUnitOption('curr', 'TableName');
- $sql = 'SELECT ISO FROM '.$table.' WHERE IsPrimary = 1';
- $this->PrimaryCurrency = $conn->GetOne($sql);
- }
- return $this->PrimaryCurrency;
- }
-
function StoreRates($currencies=null)
{
$curr_object =& $this->Application->recallObject('curr', null, Array ('skip_autoload' => true));
@@ -127,7 +114,6 @@
function GetRatesData()
{
- $this->GetPrimaryCurrency();
$xml_parser = xml_parser_create();
$curl_helper =& $this->Application->recallObject('CurlHelper');
@@ -179,7 +165,6 @@
function GetRatesData()
{
- $this->GetPrimaryCurrency();
$xml_parser = xml_parser_create();
$curl_helper =& $this->Application->recallObject('CurlHelper');
@@ -225,7 +210,6 @@
$curl_helper =& $this->Application->recallObject('CurlHelper');
/* @var $curl_helper kCurlHelper */
- $this->GetPrimaryCurrency();
for($i = 0; $i < 10; $i++)
{
$time = adodb_mktime() - $i * 3600 * 24;
Index: units/orders/orders_event_handler.php
===================================================================
--- units/orders/orders_event_handler.php (revision 13128)
+++ units/orders/orders_event_handler.php (working copy)
@@ -536,17 +536,22 @@
function OnProceedToBilling(&$event)
{
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
- if($items_info)
- {
- list($id,$field_values) = each($items_info);
+ if ($items_info) {
+ list($id, $field_values) = each($items_info);
$object =& $event->getObject();
$payment_type_id = $object->GetDBField('PaymentType');
- if(!$payment_type_id)
- {
- $default_type = $this->Conn->GetOne('SELECT PaymentTypeId FROM '.TABLE_PREFIX.'PaymentTypes WHERE IsPrimary = 1');
- if($default_type)
- {
+ if (!$payment_type_id) {
+ $default_type = $this->Application->siteDomainField('PrimaryPaymentTypeId');
+
+ if (!$default_type) {
+ $sql = 'SELECT PaymentTypeId
+ FROM ' . TABLE_PREFIX . 'PaymentTypes
+ WHERE IsPrimary = 1';
+ $default_type = $this->Conn->GetOne($sql);
+ }
+
+ if ($default_type) {
$field_values['PaymentType'] = $default_type;
$items_info[$id] = $field_values;
$this->Application->SetVar( $event->getPrefixSpecial(true), $items_info );
@@ -3821,15 +3826,34 @@
$fields['Number']['format'] = str_replace('%06d', '%0'.$order_number.'d', $fields['Number']['format']);
$fields['SubNumber']['format'] = str_replace('%03d', '%0'.$order_sub_number.'d', $fields['SubNumber']['format']);
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $fields['BillingCountry']['default'] = $site_helper->getDefaultCountry('Billing');
+ $fields['ShippingCountry']['default'] = $site_helper->getDefaultCountry('Shipping');
+
if (!$this->Application->isAdminUser) {
$user_groups = explode(',', $this->Application->RecallVar('UserGroups'));
$default_group = $this->Application->ConfigValue('User_LoggedInGroup');
if (!in_array($default_group, $user_groups)){
$user_groups[]=$default_group;
}
- $fields['PaymentType']['options_sql'] .= ' AND ';
- $fields['PaymentType']['options_sql'] .= ' (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%")';
+ $sql = $fields['PaymentType']['options_sql'];
+
+ // limit payment types by domain
+ $payment_types = $this->Application->siteDomainField('PaymentTypes');
+
+ if (strlen($payment_types)) {
+ $payment_types = explode('|', substr($payment_types, 1, -1));
+ $sql .= ' AND PaymentTypeId IN (' . implode(',', $payment_types) . ')';
+ }
+
+ // limit payment types by user group
+ $sql .= ' AND (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%")';
+
+ $fields['PaymentType']['options_sql'] = $sql;
+
}
$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
Index: units/payment_type/payment_type_event_handler.php
===================================================================
--- units/payment_type/payment_type_event_handler.php (revision 13128)
+++ units/payment_type/payment_type_event_handler.php (working copy)
@@ -218,4 +218,38 @@
return parent::getPassedID($event);
}
+ /**
+ * Apply system filter to themes list
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ parent::SetCustomQuery($event);
+
+ $object =& $event->getObject();
+ /* @var $object kDBList */
+
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser) {
+ // "enabled" special or Front-End
+ $object->addFilter('enabled_filter', '%1$s.Status = ' . STATUS_ACTIVE);
+ }
+
+ // site domain payment type picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'PaymentTypes');
+ }
+
+ // apply domain-based payment type filtering
+ $payment_types = $this->Application->siteDomainField('PaymentTypes');
+
+ if (strlen($payment_types)) {
+ $payment_types = explode('|', substr($payment_types, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.PaymentTypeId IN (' . implode(',', $payment_types) . ')');
+ }
+ }
+
}
\ No newline at end of file
site_domains_application_only_v2.patch [^] (5,086 bytes) 2010-03-09 12:50
[Show Content]
Index: application.php
===================================================================
RCS file: /www/cvs/kernel4_dev/kernel4/application.php,v
retrieving revision 1.186.2.43.8.1
diff -u -r1.186.2.43.8.1 application.php
--- application.php 7 Mar 2010 19:08:12 -0000 1.186.2.43.8.1
+++ application.php 9 Mar 2010 18:47:21 -0000
@@ -222,6 +222,13 @@
var $isAdmin = false;
/**
+ * Instance of site domain object
+ *
+ * @var kDBItem
+ */
+ var $siteDomain = null;
+
+ /**
* Returns kApplication instance anywhere in the script.
*
* This method should be used to get single kApplication object instance anywhere in the
@@ -625,13 +632,51 @@
function GetPrimaryCurrency()
{
- if ($this->isModuleEnabled('In-Commerce')) {
- $table = $this->getUnitOption('curr', 'TableName');
- return $this->Conn->GetOne('SELECT ISO FROM '.$table.' WHERE IsPrimary = 1');
+ static $currency_iso = '';
+
+ if ($currency_iso) {
+ return $currency_iso;
+ }
+
+ if ($this->prefixRegistred('curr')) {
+ $currency_id = $this->siteDomainField('PrimaryCurrencyId');
+
+ $sql = 'SELECT ISO
+ FROM ' . $this->getUnitOption('curr', 'TableName') . '
+ WHERE ' . ($currency_id > 0 ? 'CurrencyId = ' . $currency_id : 'IsPrimary = 1');
+ $currency_iso = $this->Conn->GetOne($sql);
}
else {
- return 'USD';
+ $currency_iso = 'USD';
+ }
+
+ return $currency_iso;
+ }
+
+ /**
+ * Returns site domain field. When none of site domains are found false is returned.
+ *
+ * @param string $field
+ * @param bool $formatted
+ * @param string $format
+ */
+ function siteDomainField($field, $formatted = false, $format = null)
+ {
+ if ($this->isAdmin) {
+ // don't apply any filtering in administrative console
+ return false;
+ }
+
+ if (!$this->siteDomain) {
+ $this->siteDomain =& $this->recallObject('site-domain.current');
+ /* @var $site_domain kDBItem */
+ }
+
+ if ($this->siteDomain->isLoaded()) {
+ return $formatted ? $this->siteDomain->GetField($field, $format) : $this->siteDomain->GetDBField($field);
}
+
+ return false;
}
/**
@@ -1400,18 +1445,13 @@
$ssl = isset($params['__SSL__']) ? $params['__SSL__'] : null;
if ($ssl !== null) {
$session =& $this->recallObject('Session');
- $cookie_url = trim($session->CookieDomain.$session->CookiePath, '/.');
- if ($ssl) {
- $target_url = defined('ADMIN') && ADMIN ? $this->ConfigValue('AdminSSL_URL') : false;
- if (!$target_url) {
- $target_url = $this->ConfigValue('SSL_URL');
- }
- }
- else {
- $target_url = 'http://'.DOMAIN.$this->ConfigValue('Site_Path');
- }
+ /* @var $session Session */
+
+ $target_url = rtrim($this->BaseURL('', $ssl, false), '/');
+ $cookie_url = trim($session->CookieDomain . $session->CookiePath, '/.');
- if (!preg_match('#'.preg_quote($cookie_url).'#', $target_url)) {
+ if (!preg_match('#' . preg_quote($cookie_url) . '#', $target_url)) {
+ // when SSL<->NON-SSL redirect to different domain pass SID in url
$session->SetMode(smGET_ONLY);
}
}
@@ -1894,24 +1934,33 @@
return $ret;
}
- function BaseURL($prefix='', $ssl=null)
+ function BaseURL($prefix = '', $ssl = null, $add_port = true)
{
if ($ssl === null) {
- return PROTOCOL.SERVER_NAME.(defined('PORT')?':'.PORT : '').rtrim(BASE_PATH, '/').$prefix.'/';
+ // stay on same encryption level
+ return PROTOCOL . SERVER_NAME . ($add_port && defined('PORT') ? ':' . PORT : '') . rtrim(BASE_PATH, '/') . $prefix . '/';
}
- else {
- if ($ssl) {
- $base_url = defined('ADMIN') && ADMIN ? $this->ConfigValue('AdminSSL_URL') : false;
- if (!$base_url) {
- $base_url = $this->ConfigValue('SSL_URL');
- }
- return rtrim($base_url, '/').$prefix.'/';
- }
- else {
- return 'http://'.DOMAIN.(defined('PORT')?':'.PORT : '').rtrim( $this->ConfigValue('Site_Path'), '/').$prefix.'/';
+ if ($ssl) {
+ // going from http:// to https://
+ $base_url = $this->isAdmin ? $this->ConfigValue('AdminSSL_URL') : false;
+
+ if (!$base_url) {
+ $ssl_url = $this->siteDomainField('SSLUrl');
+ $base_url = $ssl_url !== false ? $ssl_url : $this->ConfigValue('SSL_URL');
}
+
+ return rtrim($base_url, '/') . $prefix . '/';
+ }
+
+ // going from https:// to http://
+ $domain = $this->siteDomainField('DomainName');
+
+ if ($domain === false) {
+ $domain = DOMAIN;
}
+
+ return 'http://' . $domain . ($add_port && defined('PORT') ? ':' . PORT : '') . rtrim($this->ConfigValue('Site_Path'), '/') . $prefix . '/';
}
function Redirect($t='', $params=null, $prefix='', $index_file=null)
@@ -2128,6 +2177,14 @@
*/
function ConfigValue($name)
{
+ if ($name == 'Smtp_AdminMailFrom') {
+ $res = $this->siteDomainField('AdminEmail');
+
+ if ($res) {
+ return $res;
+ }
+ }
+
$res = array_key_exists($name, $this->ConfigHash) ? $this->ConfigHash[$name] : false;
if ($res !== false) {
return $res;
site_domains_lang_theme_v2.patch [^] (1,075 bytes) 2010-03-09 13:00
[Show Content]
Index: languages/languages_item.php
===================================================================
--- languages/languages_item.php (revision 13168)
+++ languages/languages_item.php (working copy)
@@ -60,8 +60,14 @@
{
$default = false;
if ($id == 'default') {
- $id = 1;
- $id_field_name = 'PrimaryLang';
+ // domain based primary language
+ $id = $this->Application->siteDomainField('PrimaryLanguageId');
+
+ if (!$id) {
+ $id = 1;
+ $id_field_name = 'PrimaryLang';
+ }
+
$default = true;
}
Index: themes/theme_item.php
===================================================================
--- themes/theme_item.php (revision 13168)
+++ themes/theme_item.php (working copy)
@@ -20,8 +20,14 @@
{
$default = false;
if ($id == 'default') {
- $id = 1;
- $id_field_name = 'PrimaryTheme';
+ // domain based primary theme
+ $id = $this->Application->siteDomainField('PrimaryThemeId');
+
+ if (!$id) {
+ $id = 1;
+ $id_field_name = 'PrimaryTheme';
+ }
+
$default = true;
}
site_domains_core_v2.patch [^] (56,354 bytes) 2010-05-01 11:24
[Show Content]
Index: admin_templates/site_domains/site_domain_edit.tpl
===================================================================
--- admin_templates/site_domains/site_domain_edit.tpl (revision 0)
+++ admin_templates/site_domains/site_domain_edit.tpl (revision 0)
@@ -0,0 +1,95 @@
+<inp2:adm_SetPopupSize width="750" height="560"/>
+
+<inp2:m_include t="incs/header"/>
+<inp2:m_RenderElement name="combined_header" section="in-portal:site_domains" prefix="site-domain" title_preset="site_domain_edit" tab_preset="Default"/>
+
+<!-- ToolBar -->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
+ submit_event('site-domain', '<inp2:site-domain_SaveEvent/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
+ cancel_edit('site-domain', 'OnCancelEdit','<inp2:site-domain_SaveEvent/>','<inp2:m_Phrase label="la_FormCancelConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarButton('reset_edit', '<inp2:m_phrase label="la_ToolTip_Reset" escape="1"/>', function() {
+ reset_form('site-domain', 'OnReset', '<inp2:m_Phrase label="la_FormResetConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_PrevId/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_NextId/>');
+ }
+ ) );
+
+ a_toolbar.Render();
+
+ <inp2:m_if check="site-domain_IsSingle">
+ a_toolbar.HideButton('prev');
+ a_toolbar.HideButton('next');
+ a_toolbar.HideButton('sep1');
+ <inp2:m_else/>
+ <inp2:m_if check="site-domain_IsLast">
+ a_toolbar.DisableButton('next');
+ </inp2:m_if>
+ <inp2:m_if check="site-domain_IsFirst">
+ a_toolbar.DisableButton('prev');
+ </inp2:m_if>
+ </inp2:m_if>
+ </script>
+ </td>
+ </tr>
+</tbody>
+</table>
+
+<inp2:site-domain_SaveWarning name="grid_save_warning"/>
+<inp2:site-domain_ErrorWarning name="form_error_warning"/>
+
+<inp2:m_DefineElement name="inp_edit_regexp_box" class="" format="" is_last="" maxlength="" onblur="" onchange="" size="" onkeyup="" hint_label="" style="width: 400px">
+ <inp2:m_if check="{$prefix}_FieldVisible" field="$field">
+ <tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
+ <inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" hint_label="$hint_label" is_last="$is_last"/>
+ <td class="control-cell">
+ <input type="hidden" id="<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>" name="<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>" value="<inp2:{$prefix}_Field field='{$field}UsesRegExp' db='db'/>">
+ <input tabindex="<inp2:m_get param='tab_index'/>" title="<inp2:m_Phrase name='la_hint_UsingRegularExpression' html_escape='1'/>" type="checkbox" id="_cb_<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>" <inp2:{$prefix}_Field field="{$field}UsesRegExp" checked="checked" db="db"/> onchange="update_checkbox(this, document.getElementById('<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>'));"/>
+
+ <input style="<inp2:m_Param name='style'/>" type="text" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' format='$format'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" maxlength="<inp2:m_param name='maxlength'/>" class="<inp2:m_param name='class'/>" onblur="<inp2:m_Param name='onblur'/>" onkeyup="<inp2:m_Param name='onkeyup'/>" onchange="<inp2:m_Param name='onchange'/>">
+ </td>
+ <inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
+ </tr>
+ </inp2:m_if>
+</inp2:m_DefineElement>
+
+<div id="scroll_container">
+ <table class="edit-form">
+ <inp2:m_RenderElement name="inp_id_label" prefix="site-domain" field="DomainId" title="la_fld_Id"/>
+ <inp2:m_RenderElement name="inp_edit_regexp_box" prefix="site-domain" field="DomainName" title="la_fld_DomainName"/>
+ <inp2:m_RenderElement name="inp_edit_regexp_box" prefix="site-domain" field="SSLUrl" title="la_fld_SSLUrl" hint_label="la_hint_SSLUrl"/>
+ <inp2:m_RenderElement name="inp_edit_box" prefix="site-domain" field="AdminEmail" title="la_fld_AdminEmail"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="Country" title="la_fld_Country" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryLanguageId" title="la_fld_Language" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="Languages" title="la_fld_Languages" optprefix="lang" option_key_field="LanguageId" option_value_field="PackName"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryThemeId" title="la_fld_Theme" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="Themes" title="la_fld_Themes" optprefix="theme" option_key_field="ThemeId" option_value_field="Name"/>
+ <inp2:m_RenderElement name="inp_edit_textarea" prefix="site-domain" field="DomainIPRange" title="la_fld_DomainIPRange" hint_label="la_hint_DomainIPRange" allow_html="0"/>
+ <inp2:m_RenderElement name="inp_edit_checkbox" prefix="site-domain" field="RedirectOnIPMatch" title="la_fld_RedirectOnIPMatch"/>
+ <inp2:m_RenderElement name="inp_edit_box" prefix="site-domain" field="Priority" title="la_fld_Priority" style="width: 50px;"/>
+
+ <inp2:m_RenderElement name="inp_edit_filler"/>
+ </table>
+</div>
+
+<inp2:m_include t="incs/footer"/>
Index: admin_templates/site_domains/site_domain_list.tpl
===================================================================
--- admin_templates/site_domains/site_domain_list.tpl (revision 0)
+++ admin_templates/site_domains/site_domain_list.tpl (revision 0)
@@ -0,0 +1,48 @@
+<inp2:m_include t="incs/header"/>
+<inp2:m_RenderElement name="combined_header" section="in-portal:site_domains" prefix="site-domain" title_preset="site_domain_list" pagination="1"/>
+
+<!-- ToolBar -->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ //do not rename - this function is used in default grid for double click!
+ function edit()
+ {
+ std_edit_item('site-domain', 'site_domains/site_domain_edit');
+ }
+
+ var a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('new_item', '<inp2:m_phrase label="la_ToolTip_NewSiteDomain" escape="1"/>::<inp2:m_phrase label="la_ToolTip_Add" escape="1"/>',
+ function() {
+ std_precreate_item('site-domain', 'site_domains/site_domain_edit');
+ } ) );
+
+ a_toolbar.AddButton( new ToolBarButton('edit', '<inp2:m_phrase label="la_ToolTip_Edit" escape="1"/>::<inp2:m_phrase label="la_ShortToolTip_Edit" escape="1"/>', edit) );
+ a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>',
+ function() {
+ std_delete_items('site-domain')
+ } ) );
+
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
+ show_viewmenu(a_toolbar,'view');
+ }
+ ) );
+
+ a_toolbar.Render();
+ </script>
+ </td>
+ <inp2:m_RenderElement name="search_main_toolbar" prefix="site-domain" grid="Default"/>
+ </tr>
+</tbody>
+</table>
+
+<inp2:m_RenderElement name="grid" PrefixSpecial="site-domain" IdField="DomainId" grid="Default"/>
+<script type="text/javascript">
+ Grids['site-domain'].SetDependantToolbarButtons( new Array('edit','delete') );
+</script>
+<inp2:m_include t="incs/footer"/>
Index: install/english.lang
===================================================================
--- install/english.lang (revision 13470)
+++ install/english.lang (working copy)
@@ -13,6 +13,7 @@
<PHRASE Label="la_Auto" Module="Core" Type="1">QXV0bw==</PHRASE>
<PHRASE Label="la_Automatic" Module="Core" Type="1">QXV0b21hdGlj</PHRASE>
<PHRASE Label="la_AvailableColumns" Module="Core" Type="1">QXZhaWxhYmxlIENvbHVtbnM=</PHRASE>
+ <PHRASE Label="la_AvailableItems" Module="Core" Type="1">QXZhaWxhYmxlIEl0ZW1z</PHRASE>
<PHRASE Label="la_Background" Module="Core" Type="1">QmFja2dyb3VuZA==</PHRASE>
<PHRASE Label="la_Borders" Module="Core" Type="1">Qm9yZGVycw==</PHRASE>
<PHRASE Label="la_btn_BrowseMode" Module="Core" Type="1">QnJvd3NlIE1vZGU=</PHRASE>
@@ -60,8 +61,10 @@
<PHRASE Label="la_col_CategoryName" Module="Core" Type="1">U2VjdGlvbiBOYW1l</PHRASE>
<PHRASE Label="la_col_Changes" Module="Core" Type="1">Q2hhbmdlcw==</PHRASE>
<PHRASE Label="la_col_Charset" Module="Core" Type="1">Q2hhcnNldA==</PHRASE>
+ <PHRASE Label="la_col_Country" Module="Core" Type="1">Q291bnRyeQ==</PHRASE>
<PHRASE Label="la_col_CreatedOn" Module="Core" Type="1">Q3JlYXRlZCBPbg==</PHRASE>
<PHRASE Label="la_col_Description" Module="Core" Type="1">RGVzY3JpcHRpb24=</PHRASE>
+ <PHRASE Label="la_col_DomainName" Module="Core" Type="1">RG9tYWluIE5hbWU=</PHRASE>
<PHRASE Label="la_col_Duration" Module="Core" Type="1">RHVyYXRpb24=</PHRASE>
<PHRASE Label="la_col_Effective" Module="Core" Type="1">RWZmZWN0aXZl</PHRASE>
<PHRASE Label="la_col_Email" Module="Core" Type="1">RW1haWw=</PHRASE>
@@ -179,6 +182,7 @@
<PHRASE Label="la_col_ShortIsoCode" Module="Core" Type="1">U2hvcnQgSVNPIENvZGU=</PHRASE>
<PHRASE Label="la_col_SkinName" Module="Core" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_col_SortBy" Module="Core" Type="1">U29ydCBieQ==</PHRASE>
+ <PHRASE Label="la_col_SSLUrl" Module="Core" Type="1">U1NMIFVybA==</PHRASE>
<PHRASE Label="la_col_StateCountry" Module="Core" Type="1">U3RhdGUgQ291bnRyeQ==</PHRASE>
<PHRASE Label="la_col_Status" Module="Core" Type="1">U3RhdHVz</PHRASE>
<PHRASE Label="la_col_StopWord" Module="Core" Type="1">U3RvcCBXb3Jk</PHRASE>
@@ -189,6 +193,7 @@
<PHRASE Label="la_col_TargetId" Module="Core" Type="1">SXRlbQ==</PHRASE>
<PHRASE Label="la_col_TargetType" Module="Core" Type="1">SXRlbSBUeXBl</PHRASE>
<PHRASE Label="la_col_TemplateType" Module="Core" Type="1">VGVtcGxhdGU=</PHRASE>
+ <PHRASE Label="la_col_Theme" Module="Core" Type="1">VGhlbWU=</PHRASE>
<PHRASE Label="la_col_ThesaurusTerm" Module="Core" Type="1">VGhlc2F1cnVzIFRlcm0=</PHRASE>
<PHRASE Label="la_col_ThesaurusType" Module="Core" Type="1">VGhlc2F1cnVzIFR5cGU=</PHRASE>
<PHRASE Label="la_col_Title" Module="Core" Type="1">VGl0bGU=</PHRASE>
@@ -343,6 +348,7 @@
<PHRASE Label="la_fld_Action" Module="Core" Type="1">QWN0aW9u</PHRASE>
<PHRASE Label="la_fld_AddressLine1" Module="Core" Type="1">QWRkcmVzcyBMaW5lIDE=</PHRASE>
<PHRASE Label="la_fld_AddressLine2" Module="Core" Type="1">QWRkcmVzcyBMaW5lIDI=</PHRASE>
+ <PHRASE Label="la_fld_AdminEmail" Module="Core" Type="1">TWVzc2FnZXMgZnJvbSBTaXRlIEFkbWluIGFyZSBmcm9t</PHRASE>
<PHRASE Label="la_fld_AdminInterfaceLang" Module="Core" Type="1">QWRtaW4gUHJpbWFyeQ==</PHRASE>
<PHRASE Label="la_fld_AdvancedCSS" Module="Core" Type="1">QWR2YW5jZWQgQ1NT</PHRASE>
<PHRASE Label="la_fld_AdvancedSearch" Module="Core" Type="1">QWR2YW5jZWQgU2VhcmNo</PHRASE>
@@ -394,6 +400,8 @@
<PHRASE Label="la_fld_Display" Module="Core" Type="1">RGlzcGxheQ==</PHRASE>
<PHRASE Label="la_fld_DisplayInGrid" Module="Core" Type="1">RGlzcGxheSBpbiBHcmlk</PHRASE>
<PHRASE Label="la_fld_DisplayName" Module="Core" Type="1">RmllbGQgTGFiZWw=</PHRASE>
+ <PHRASE Label="la_fld_DomainIPRange" Module="Core" Type="1">UmFuZ2Ugb2YgSVBz</PHRASE>
+ <PHRASE Label="la_fld_DomainName" Module="Core" Type="1">RG9tYWluIE5hbWU=</PHRASE>
<PHRASE Label="la_fld_DoNotEncode" Module="Core" Type="1">QXMgUGxhaW4gVGV4dA==</PHRASE>
<PHRASE Label="la_fld_Duration" Module="Core" Type="1">RHVyYXRpb24=</PHRASE>
<PHRASE Label="la_fld_EditorsPick" Module="Core" Type="1">RWRpdG9ycyBQaWNr</PHRASE>
@@ -477,6 +485,7 @@
<PHRASE Label="la_fld_Language" Module="Core" Type="1">TGFuZ3VhZ2U=</PHRASE>
<PHRASE Label="la_fld_LanguageFile" Module="Core" Type="1">TGFuZ3VhZ2UgRmlsZQ==</PHRASE>
<PHRASE Label="la_fld_LanguageId" Module="Core" Type="1">TGFuZ3VhZ2UgSUQ=</PHRASE>
+ <PHRASE Label="la_fld_Languages" Module="Core" Type="1">TGFuZ3VhZ2Vz</PHRASE>
<PHRASE Label="la_fld_LastName" Module="Core" Type="1">TGFzdCBOYW1l</PHRASE>
<PHRASE Label="la_fld_LastRunOn" Module="Core" Type="1">TGFzdCBSdW4gT24=</PHRASE>
<PHRASE Label="la_fld_LastRunStatus" Module="Core" Type="1">TGFzdCBSdW4gU3RhdHVz</PHRASE>
@@ -545,6 +554,7 @@
<PHRASE Label="la_fld_PrimaryTranslation" Module="Core" Type="1">UHJpbWFyeSBMYW5ndWFnZSBQaHJhc2U=</PHRASE>
<PHRASE Label="la_fld_Priority" Module="Core" Type="1">T3JkZXI=</PHRASE>
<PHRASE Label="la_fld_Rating" Module="Core" Type="1">UmF0aW5n</PHRASE>
+ <PHRASE Label="la_fld_RedirectOnIPMatch" Module="Core" Type="1">Rm9yY2UgUmVkaXJlY3QgKHdoZW4gdXNlcidzIElQIG1hdGNoZXMp</PHRASE>
<PHRASE Label="la_fld_ReferrerURL" Module="Core" Type="1">UmVmZXJyZXIgVVJM</PHRASE>
<PHRASE Label="la_fld_RelatedSearchKeyword" Module="Core" Type="1">S2V5d29yZA==</PHRASE>
<PHRASE Label="la_fld_RelationshipType" Module="Core" Type="1">VHlwZQ==</PHRASE>
@@ -579,6 +589,7 @@
<PHRASE Label="la_fld_SkinName" Module="Core" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_fld_SkipFirstRow" Module="Core" Type="1">U2tpcCBGaXJzdCBSb3c=</PHRASE>
<PHRASE Label="la_fld_SortValues" Module="Core" Type="1">U29ydCBWYWx1ZXM=</PHRASE>
+ <PHRASE Label="la_fld_SSLUrl" Module="Core" Type="1">U1NMIEZ1bGwgVVJM</PHRASE>
<PHRASE Label="la_fld_State" Module="Core" Type="1">U3RhdGU=</PHRASE>
<PHRASE Label="la_fld_StateCountry" Module="Core" Type="1">U3RhdGUgQ291bnRyeQ==</PHRASE>
<PHRASE Label="la_fld_Status" Module="Core" Type="1">U3RhdHVz</PHRASE>
@@ -595,6 +606,8 @@
<PHRASE Label="la_fld_TextAlign" Module="Core" Type="1">VGV4dCBBbGlnbg==</PHRASE>
<PHRASE Label="la_fld_TextDecoration" Module="Core" Type="1">VGV4dCBEZWNvcmF0aW9u</PHRASE>
<PHRASE Label="LA_FLD_TEXTVERSION" Module="Core" Type="1">VGV4dCBWZXJzaW9u</PHRASE>
+ <PHRASE Label="la_fld_Theme" Module="Core" Type="1">VGhlbWU=</PHRASE>
+ <PHRASE Label="la_fld_Themes" Module="Core" Type="1">VGhlbWVz</PHRASE>
<PHRASE Label="la_fld_ThesaurusTerm" Module="Core" Type="1">VGhlc2F1cnVzIFRlcm0=</PHRASE>
<PHRASE Label="la_fld_ThesaurusType" Module="Core" Type="1">VGhlc2F1cnVzIFR5cGU=</PHRASE>
<PHRASE Label="la_fld_ThousandSep" Module="Core" Type="1">VGhvdXNhbmRzIFNlcGFyYXRvcg==</PHRASE>
@@ -631,12 +644,15 @@
<PHRASE Label="la_Hide" Module="Core" Type="1">SGlkZQ==</PHRASE>
<PHRASE Label="la_hint_AllFiles" Module="Core" Type="1">QWxsIEZpbGVz</PHRASE>
<PHRASE Label="la_hint_CSVFiles" Module="Core" Type="1">Q1NWIEZpbGVz</PHRASE>
+ <PHRASE Label="la_hint_DomainIPRange" Module="Core" Type="1">U2luZ2xlIElQIG9yIHJhbmdlIHJlY29yZCBwZXIgbGluZSAoZm9ybWF0czogMS4yLjMuNCBvciAxLjIuMyBvciAxLjIuMy4zMi0xLjIuMy41NCBvciAxLjIuMy4zMi8yNyBvciAxLjIuMy4zMi8yNTUuMjU1LjI1NS4yMjQp</PHRASE>
<PHRASE Label="la_hint_ExportEmailEvents" Module="Core" Type="1">U2luZ2xlIEVtYWlsIEV2ZW50IHBlciBsaW5lIChmb3JtYXRzOiBVU0VSLkFERCwgT1JERVIuU1VCTUlUKQ==</PHRASE>
<PHRASE Label="la_hint_ExportPhrases" Module="Core" Type="1">U2luZ2xlIFBocmFzZSBMYWJlbCBwZXIgbGluZSAoZm9ybWF0czogbGFfU2FtcGxlTGFiZWwsIGx1X0Zyb250RW5kTGFiZWwp</PHRASE>
<PHRASE Label="la_hint_ForceModRewriteUrlEnding" Module="Core" Type="1">VXNlciB3aWxsIGJlIGF1dG9tYXRpY2FsbHkgcmVkaXJlY3RlZCB0byB0aGUgc2VsZWN0ZWQgVXJsIEVuZGluZyBpbiBjYXNlIHdoZW4gY3VycmVudCBwYWdlIHVybCBoYXMgYSBkaWZmZXJlbnQgZW5kaW5n</PHRASE>
<PHRASE Label="la_hint_ImageFiles" Module="Core" Type="1">SW1hZ2UgRmlsZXM=</PHRASE>
<PHRASE Label="la_hint_PopPort" Module="Core" Type="1">UE9QMyBTZXJ2ZXIgUG9ydC4gRm9yIGV4LiAiMTEwIiBmb3IgcmVndWxhciBjb25uZWN0aW9uLCAiOTk1IiBmb3Igc2VjdXJlIGNvbm5lY3Rpb24u</PHRASE>
<PHRASE Label="la_hint_PopServer" Module="Core" Type="1">UE9QMyBTZXJ2ZXIgQWRkcmVzcy4gRm9yIGV4LiB1c2UgInNzbDovL3BvcC5nbWFpbC5jb20iIGZvciBHbWFpbCwgInBvcC5tYWlsLnlhaG9vLmNvbSIgZm9yIFlhaG9vLg==</PHRASE>
+ <PHRASE Label="la_hint_SSLUrl" Module="Core" Type="1">aHR0cHM6Ly93d3cuZG9tYWluLmNvbS9wYXRo</PHRASE>
+ <PHRASE Label="la_hint_UsingRegularExpression" Module="Core" Type="1">VXNpbmcgUmVndWxhciBFeHByZXNzaW9u</PHRASE>
<PHRASE Label="la_Hot" Module="Core" Type="1">SG90</PHRASE>
<PHRASE Label="la_Html" Module="Core" Type="1">SFRNTA==</PHRASE>
<PHRASE Label="la_IDField" Module="Core" Type="1">SUQgRmllbGQ=</PHRASE>
@@ -954,6 +970,7 @@
<PHRASE Label="la_section_UsersSearch" Module="Core" Type="1">U2VhcmNoIFVzZXJz</PHRASE>
<PHRASE Label="la_section_Values" Module="Core" Type="1">VmFsdWVz</PHRASE>
<PHRASE Label="la_SelectColumns" Module="Core" Type="1">U2VsZWN0IENvbHVtbnM=</PHRASE>
+ <PHRASE Label="la_SelectedItems" Module="Core" Type="1">U2VsZWN0ZWQgSXRlbXM=</PHRASE>
<PHRASE Label="la_selecting_categories" Module="Core" Type="1">U2VsZWN0aW5nIFNlY3Rpb25z</PHRASE>
<PHRASE Label="la_SeparatedCategoryPath" Module="Core" Type="1">T25lIGZpZWxkIGZvciBlYWNoIHNlY3Rpb24gbGV2ZWw=</PHRASE>
<PHRASE Label="la_ShortToolTip_Clone" Module="Core" Type="1">Q2xvbmU=</PHRASE>
@@ -1116,6 +1133,7 @@
<PHRASE Label="la_title_addingCustom" Module="Core" Type="1">QWRkaW5nIEN1c3RvbSBGaWVsZA==</PHRASE>
<PHRASE Label="la_title_AddingFile" Module="Core" Type="1">QWRkaW5nIEZpbGU=</PHRASE>
<PHRASE Label="la_title_AddingMailingList" Module="Core" Type="1">QWRkaW5nIE1haWxpbmcgTGlzdA==</PHRASE>
+ <PHRASE Label="la_title_AddingSiteDomain" Module="Core" Type="1">QWRkaW5nIFNpdGUgRG9tYWlu</PHRASE>
<PHRASE Label="la_title_AddingSkin" Module="Core" Type="1">QWRkaW5nIFNraW4=</PHRASE>
<PHRASE Label="la_title_AddingSpellingDictionary" Module="Core" Type="1">QWRkaW5nIFNwZWxsaW5nIERpY3Rpb25hcnk=</PHRASE>
<PHRASE Label="la_title_AddingStopWord" Module="Core" Type="1">QWRkaW5nIFN0b3AgV29yZA==</PHRASE>
@@ -1163,6 +1181,7 @@
<PHRASE Label="la_title_EditingEmailEvent" Module="Core" Type="1">RWRpdGluZyBFbWFpbCBFdmVudA==</PHRASE>
<PHRASE Label="la_title_EditingFile" Module="Core" Type="1">RWRpdGluZyBGaWxl</PHRASE>
<PHRASE Label="la_title_EditingMembership" Module="Core" Type="1">RWRpdGluZyBNZW1iZXJzaGlw</PHRASE>
+ <PHRASE Label="la_title_EditingSiteDomain" Module="Core" Type="1">RWRpdGluZyBTaXRlIERvbWFpbg==</PHRASE>
<PHRASE Label="la_title_EditingSkin" Module="Core" Type="1">RWRpdGluZyBTa2lu</PHRASE>
<PHRASE Label="la_title_EditingSpellingDictionary" Module="Core" Type="1">RWRpdGluZyBTcGVsbGluZyBEaWN0aW9uYXJ5</PHRASE>
<PHRASE Label="la_title_EditingStopWord" Module="Core" Type="1">RWRpdGluZyBTdG9wIFdvcmQ=</PHRASE>
@@ -1239,6 +1258,7 @@
<PHRASE Label="LA_TITLE_SENDEMAIL" Module="Core" Type="1">U2VuZCBFLW1haWw=</PHRASE>
<PHRASE Label="LA_TITLE_SENDINGPREPAREDEMAILS" Module="Core" Type="1">U2VuZGluZyBQcmVwYXJlZCBFLW1haWxz</PHRASE>
<PHRASE Label="la_Title_SendMailComplete" Module="Core" Type="1">TWFpbCBoYXMgYmVlbiBzZW50IFN1Y2Nlc3NmdWxseQ==</PHRASE>
+ <PHRASE Label="la_title_SiteDomains" Module="Core" Type="1">U2l0ZSBEb21haW5z</PHRASE>
<PHRASE Label="la_title_SpellingDictionary" Module="Core" Type="1">U3BlbGxpbmcgRGljdGlvbmFyeQ==</PHRASE>
<PHRASE Label="la_title_StopWords" Module="Core" Type="1">U3RvcCBXb3Jkcw==</PHRASE>
<PHRASE Label="la_title_Structure" Module="Core" Type="1">U3RydWN0dXJlICYgRGF0YQ==</PHRASE>
@@ -1296,6 +1316,7 @@
<PHRASE Label="la_ToolTip_NewPhrase" Module="Core" Type="1">TmV3IFBocmFzZQ==</PHRASE>
<PHRASE Label="la_ToolTip_NewReview" Module="Core" Type="1">TmV3IENvbW1lbnQ=</PHRASE>
<PHRASE Label="la_ToolTip_NewSearchConfig" Module="Core" Type="1">TmV3IFNlYXJjaCBGaWVsZA==</PHRASE>
+ <PHRASE Label="la_ToolTip_NewSiteDomain" Module="Core" Type="1">TmV3IFNpdGUgRG9tYWlu</PHRASE>
<PHRASE Label="la_ToolTip_NewStopWord" Module="Core" Type="1">TmV3IFN0b3AgV29yZA==</PHRASE>
<PHRASE Label="la_ToolTip_newstylesheet" Module="Core" Type="1">TmV3IFN0eWxlc2hlZXQ=</PHRASE>
<PHRASE Label="la_ToolTip_NewTerm" Module="Core" Type="1">TmV3IFRlcm0=</PHRASE>
Index: install/install_schema.sql
===================================================================
--- install/install_schema.sql (revision 13470)
+++ install/install_schema.sql (working copy)
@@ -1194,4 +1194,34 @@
KEY Prefixes (Prefixes),
KEY Cached (Cached),
KEY LifeTime (LifeTime)
+);
+
+CREATE TABLE SiteDomains (
+ DomainId int(11) NOT NULL AUTO_INCREMENT,
+ DomainName varchar(255) NOT NULL DEFAULT '',
+ DomainNameUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ SSLUrl varchar(255) NOT NULL DEFAULT '',
+ SSLUrlUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ AdminEmail varchar(255) NOT NULL DEFAULT '',
+ Country varchar(3) NOT NULL DEFAULT '',
+ PrimaryLanguageId int(11) NOT NULL DEFAULT '0',
+ Languages varchar(255) NOT NULL DEFAULT '',
+ PrimaryThemeId int(11) NOT NULL DEFAULT '0',
+ Themes varchar(255) NOT NULL DEFAULT '',
+ DomainIPRange text,
+ RedirectOnIPMatch tinyint(4) NOT NULL DEFAULT '0',
+ Priority int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (DomainId),
+ KEY DomainName (DomainName),
+ KEY DomainNameUsesRegExp (DomainNameUsesRegExp),
+ KEY SSLUrl (SSLUrl),
+ KEY SSLUrlUsesRegExp (SSLUrlUsesRegExp),
+ KEY AdminEmail (AdminEmail),
+ KEY Country (Country),
+ KEY PrimaryLanguageId (PrimaryLanguageId),
+ KEY Languages (Languages),
+ KEY PrimaryThemeId (PrimaryThemeId),
+ KEY Themes (Themes),
+ KEY RedirectOnIPMatch (RedirectOnIPMatch),
+ KEY Priority (Priority)
);
\ No newline at end of file
Index: install/remove_schema.sql
===================================================================
--- install/remove_schema.sql (revision 13470)
+++ install/remove_schema.sql (working copy)
@@ -70,3 +70,4 @@
DROP TABLE Forms;
DROP TABLE Semaphores;
DROP TABLE CachedUrls;
+DROP TABLE SiteDomains;
\ No newline at end of file
Index: install/upgrades.sql
===================================================================
--- install/upgrades.sql (revision 13470)
+++ install/upgrades.sql (working copy)
@@ -1810,3 +1810,33 @@
UPDATE Phrase
SET l<%PRIMARY_LANGUAGE%>_Translation = 'Enable SEO-friendly URLs mode (MOD-REWRITE)'
WHERE Phrase = 'la_config_use_modrewrite' AND l<%PRIMARY_LANGUAGE%>_Translation = 'Use MOD REWRITE';
+
+CREATE TABLE SiteDomains (
+ DomainId int(11) NOT NULL AUTO_INCREMENT,
+ DomainName varchar(255) NOT NULL DEFAULT '',
+ DomainNameUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ SSLUrl varchar(255) NOT NULL DEFAULT '',
+ SSLUrlUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ AdminEmail varchar(255) NOT NULL DEFAULT '',
+ Country varchar(3) NOT NULL DEFAULT '',
+ PrimaryLanguageId int(11) NOT NULL DEFAULT '0',
+ Languages varchar(255) NOT NULL DEFAULT '',
+ PrimaryThemeId int(11) NOT NULL DEFAULT '0',
+ Themes varchar(255) NOT NULL DEFAULT '',
+ DomainIPRange text,
+ RedirectOnIPMatch tinyint(4) NOT NULL DEFAULT '0',
+ Priority int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (DomainId),
+ KEY DomainName (DomainName),
+ KEY DomainNameUsesRegExp (DomainNameUsesRegExp),
+ KEY SSLUrl (SSLUrl),
+ KEY SSLUrlUsesRegExp (SSLUrlUsesRegExp),
+ KEY AdminEmail (AdminEmail),
+ KEY Country (Country),
+ KEY PrimaryLanguageId (PrimaryLanguageId),
+ KEY Languages (Languages),
+ KEY PrimaryThemeId (PrimaryThemeId),
+ KEY Themes (Themes),
+ KEY RedirectOnIPMatch (RedirectOnIPMatch),
+ KEY Priority (Priority)
+);
\ No newline at end of file
Index: kernel/application.php
===================================================================
--- kernel/application.php (revision 13473)
+++ kernel/application.php (working copy)
@@ -220,6 +220,13 @@
*/
var $isAdmin = false;
+ /**
+ * Instance of site domain object
+ *
+ * @var kDBItem
+ */
+ var $siteDomain = null;
+
/**
* Returns kApplication instance anywhere in the script.
*
@@ -599,30 +606,63 @@
return $theme_id;
}
+ /**
+ * Returns site primary currency ISO code
+ *
+ * @return string
+ */
function GetPrimaryCurrency()
{
- $cache_key = 'primary_currency[%CurrSerial%]';
- $primary_currency = $this->getCache($cache_key);
+ $cache_key = 'primary_currency[%CurrSerial%][%SiteDomainSerial%]:' . $this->siteDomainField('DomainId');
+ $currency_iso = $this->getCache($cache_key);
- if ($primary_currency === false) {
- if ($this->isModuleEnabled('In-Commerce')) {
+ if ($currency_iso === false) {
+ if ($this->prefixRegistred('curr')) {
$this->Conn->nextQueryCachable = true;
+ $currency_id = $this->siteDomainField('PrimaryCurrencyId');
+
$sql = 'SELECT ISO
FROM ' . $this->getUnitOption('curr', 'TableName') . '
- WHERE IsPrimary = 1';
- $primary_currency = $this->Conn->GetOne($sql);
+ WHERE ' . ($currency_id > 0 ? 'CurrencyId = ' . $currency_id : 'IsPrimary = 1');
+ $currency_iso = $this->Conn->GetOne($sql);
}
else {
- $primary_currency = 'USD';
+ $currency_iso = 'USD';
}
- $this->setCache($cache_key, $primary_currency);
+ $this->setCache($cache_key, $currency_iso);
}
- return $primary_currency;
+ return $currency_iso;
}
/**
+ * Returns site domain field. When none of site domains are found false is returned.
+ *
+ * @param string $field
+ * @param bool $formatted
+ * @param string $format
+ */
+ function siteDomainField($field, $formatted = false, $format = null)
+ {
+ if ($this->isAdmin) {
+ // don't apply any filtering in administrative console
+ return false;
+ }
+
+ if (!$this->siteDomain) {
+ $this->siteDomain =& $this->recallObject('site-domain.current');
+ /* @var $site_domain kDBItem */
+ }
+
+ if ($this->siteDomain->isLoaded()) {
+ return $formatted ? $this->siteDomain->GetField($field, $format) : $this->siteDomain->GetDBField($field);
+ }
+
+ return false;
+ }
+
+ /**
* Registers default classes such as ItemController, GridController and LoginController
*
* Called automatically while initializing Application
@@ -1530,21 +1570,16 @@
$ssl = isset($params['__SSL__']) ? $params['__SSL__'] : null;
if ($ssl !== null) {
$session =& $this->recallObject('Session');
- $cookie_url = trim($session->CookieDomain.$session->CookiePath, '/.');
- if ($ssl) {
- $target_url = defined('ADMIN') && ADMIN ? $this->ConfigValue('AdminSSL_URL') : false;
- if (!$target_url) {
- $target_url = $this->ConfigValue('SSL_URL');
- }
- }
- else {
- $target_url = 'http://'.DOMAIN.$this->ConfigValue('Site_Path');
- }
+ /* @var $session Session */
+ $target_url = rtrim($this->BaseURL('', $ssl, false), '/');
+ $cookie_url = trim($session->CookieDomain . $session->CookiePath, '/.');
+
// set session to GET_ONLY, to pass sid only if sid is REAL AND session is set
- if (!preg_match('#'.preg_quote($cookie_url).'#', $target_url) && $session->SessionSet) {
- $session->SetMode(smGET_ONLY);
- }
+ if (!preg_match('#' . preg_quote($cookie_url) . '#', $target_url) && $session->SessionSet) {
+ // when SSL<->NON-SSL redirect to different domain pass SID in url
+ $session->SetMode(smGET_ONLY);
+ }
}
if (isset($params['opener']) && $params['opener'] == 'u') {
@@ -2023,24 +2058,33 @@
return $ret;
}
- function BaseURL($prefix='', $ssl=null)
+ function BaseURL($prefix = '', $ssl = null, $add_port = true)
{
if ($ssl === null) {
- return PROTOCOL.SERVER_NAME.(defined('PORT')?':'.PORT : '').rtrim(BASE_PATH, '/').$prefix.'/';
+ // stay on same encryption level
+ return PROTOCOL . SERVER_NAME . ($add_port && defined('PORT') ? ':' . PORT : '') . rtrim(BASE_PATH, '/') . $prefix . '/';
}
- else {
- if ($ssl) {
- $base_url = defined('ADMIN') && ADMIN ? $this->ConfigValue('AdminSSL_URL') : false;
- if (!$base_url) {
- $base_url = $this->ConfigValue('SSL_URL');
- }
- return rtrim($base_url, '/').$prefix.'/';
+ if ($ssl) {
+ // going from http:// to https://
+ $base_url = $this->isAdmin ? $this->ConfigValue('AdminSSL_URL') : false;
+
+ if (!$base_url) {
+ $ssl_url = $this->siteDomainField('SSLUrl');
+ $base_url = $ssl_url !== false ? $ssl_url : $this->ConfigValue('SSL_URL');
}
- else {
- return 'http://'.DOMAIN.(defined('PORT')?':'.PORT : '').rtrim( $this->ConfigValue('Site_Path'), '/').$prefix.'/';
- }
+
+ return rtrim($base_url, '/') . $prefix . '/';
}
+
+ // going from https:// to http://
+ $domain = $this->siteDomainField('DomainName');
+
+ if ($domain === false) {
+ $domain = DOMAIN;
+ }
+
+ return 'http://' . $domain . ($add_port && defined('PORT') ? ':' . PORT : '') . rtrim($this->ConfigValue('Site_Path'), '/') . $prefix . '/';
}
function Redirect($t='', $params=null, $prefix='', $index_file=null)
@@ -2273,6 +2317,14 @@
*/
function ConfigValue($name)
{
+ if ($name == 'Smtp_AdminMailFrom') {
+ $res = $this->siteDomainField('AdminEmail');
+
+ if ($res) {
+ return $res;
+ }
+ }
+
$res = array_key_exists($name, $this->ConfigHash) ? $this->ConfigHash[$name] : false;
if ($res !== false) {
return $res;
Index: kernel/globals.php
===================================================================
--- kernel/globals.php (revision 13400)
+++ kernel/globals.php (working copy)
@@ -563,17 +563,26 @@
return $ip_match;
}
- function netMatch($network, $ip) {
+ function netMatch($network, $ip)
+ {
$network = trim($network);
$ip = trim($ip);
if ($network == $ip) {
- // comparing 2 ip addresses directly
+ // comparing two ip addresses directly
return true;
}
$d = strpos($network, '-');
- if ($d === false) {
+ if ($d !== false) {
+ // ip address range specified
+ $from = ip2long(trim(substr($network, 0, $d)));
+ $to = ip2long(trim(substr($network, $d + 1)));
+
+ $ip = ip2long($ip);
+ return ($ip >= $from && $ip <= $to);
+ }
+ elseif (strpos($network, '/') !== false) {
// sigle subnet specified
$ip_arr = explode('/', $network);
@@ -589,14 +598,8 @@
return ($ip_long & $mask) == ($network_long & $mask);
}
- else {
- // ip address range specified
- $from = ip2long(trim(substr($network, 0, $d)));
- $to = ip2long(trim(substr($network, $d + 1)));
- $ip = ip2long($ip);
- return ($ip >= $from && $ip <= $to);
- }
+ return false;
}
function request_headers()
Index: kernel/processors/main_processor.php
===================================================================
--- kernel/processors/main_processor.php (revision 13400)
+++ kernel/processors/main_processor.php (working copy)
@@ -833,10 +833,14 @@
if (!$ssl) {
// not in admin or admin ssl url is empty
- $ssl = $this->Application->ConfigValue('SSL_URL');
+ $ssl_url = $this->Application->siteDomainField('SSLUrl');
+ $ssl = $ssl_url !== false ? $ssl_url : $this->Application->ConfigValue('SSL_URL');
}
- if (!$ssl) return; //SSL URL is not set - no way to require SSL
+ if (!$ssl) {
+ // SSL URL is not set - no way to require SSL
+ return;
+ }
$require = false;
Index: units/admin/admin_tag_processor.php
===================================================================
--- units/admin/admin_tag_processor.php (revision 13401)
+++ units/admin/admin_tag_processor.php (working copy)
@@ -147,7 +147,6 @@
return '';
}
-
if (array_key_exists('parent', $params) && $params['parent']) {
do {
$section = $section_data['parent'];
@@ -175,13 +174,15 @@
break;
case 'label':
- $res = $section_data['label'];
- if ($section != 'in-portal:root') {
+ if ($section && ($section != 'in-portal:root')) {
// don't translate label for top section, because it's already translated
$no_editing = array_key_exists('no_editing', $params) ? $params['no_editing'] : false;
- $res = $this->Application->Phrase($res, !$no_editing);
+ $res = $this->Application->Phrase($section_data['label'], !$no_editing);
}
+ else {
+ $res = '';
+ }
break;
default:
Index: units/helpers/helpers_config.php
===================================================================
--- units/helpers/helpers_config.php (revision 13471)
+++ units/helpers/helpers_config.php (working copy)
@@ -65,5 +65,6 @@
Array ('pseudo' => 'POP3Helper', 'class' => 'POP3Helper', 'file' => 'pop3_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
Array ('pseudo' => 'MimeDecodeHelper', 'class' => 'MimeDecodeHelper', 'file' => 'mime_decode_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
Array ('pseudo' => 'UserHelper', 'class' => 'UserHelper', 'file' => 'user_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
+ Array ('pseudo' => 'SiteHelper', 'class' => 'SiteHelper', 'file' => 'site_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
),
);
\ No newline at end of file
Index: units/helpers/mod_rewrite_helper.php
===================================================================
--- units/helpers/mod_rewrite_helper.php (revision 13473)
+++ units/helpers/mod_rewrite_helper.php (working copy)
@@ -44,7 +44,21 @@
*/
var $_templateAliases = null;
+ /**
+ * Domain-based primary language id
+ *
+ * @var int
+ */
+ var $primaryLanguageId = false;
+
/**
+ * Domain-based primary theme id
+ *
+ * @var int
+ */
+ var $primaryThemeId = false;
+
+ /**
* Possible url endings from ModRewriteUrlEnding configuration variable
*
* @var Array
@@ -61,6 +75,12 @@
parent::kHelper();
$this->HTTPQuery =& $this->Application->recallObject('HTTPQuery');
+
+ // domain based primary language
+ $this->primaryLanguageId = $this->Application->siteDomainField('PrimaryLanguageId');
+
+ // domain based primary theme
+ $this->primaryThemeId = $this->Application->siteDomainField('PrimaryThemeId');
}
function processRewriteURL()
@@ -409,8 +429,12 @@
}
// add language
- $default_language_id = $this->Application->GetDefaultLanguageId();
- if ($processed_params['m_lang'] && ($processed_params['m_lang'] != $default_language_id)) {
+ if (!$this->primaryLanguageId) {
+ // when domain-based language not found -> use site-wide language
+ $this->primaryLanguageId = $this->Application->GetDefaultLanguageId();
+ }
+
+ if ($processed_params['m_lang'] && ($processed_params['m_lang'] != $this->primaryLanguageId)) {
$language_name = $this->Application->getCache('language_names[%LangIDSerial:' . $processed_params['m_lang'] . '%]');
if ($language_name === false) {
$sql = 'SELECT PackName
@@ -425,8 +449,12 @@
}
// add theme
- $default_theme_id = $this->Application->GetDefaultThemeId(true);
- if ($processed_params['m_theme'] && ($processed_params['m_theme'] != $default_theme_id)) {
+ if (!$this->primaryThemeId) {
+ // when domain-based theme not found -> use site-wide theme
+ $this->primaryThemeId = $this->Application->GetDefaultThemeId(true);
+ }
+
+ if ($processed_params['m_theme'] && ($processed_params['m_theme'] != $this->primaryThemeId)) {
$theme_name = $this->Application->getCache('theme_names[%ThemeIDSerial:' . $processed_params['m_theme'] . '%]');
if ($theme_name === false) {
$sql = 'SELECT Name
@@ -533,6 +561,10 @@
// language was found by pack name
array_shift($url_parts);
}
+ elseif ($this->primaryLanguageId) {
+ // use domain-based primary language instead of site-wide primary language
+ $vars['m_lang'] = $this->primaryLanguageId;
+ }
return true;
}
@@ -577,6 +609,10 @@
// theme was found by name
array_shift($url_parts);
}
+ elseif ($this->primaryThemeId) {
+ // use domain-based primary theme instead of site-wide primary theme
+ $vars['m_theme'] = $this->primaryThemeId;
+ }
return true;
}
@@ -1076,17 +1112,31 @@
}
/**
- * Sets default parsed values before actual url parsing
+ * Sets default parsed values before actual url parsing (only, for empty url)
*
* @param Array $vars
*/
function _setDefaultValues(&$vars)
{
- $defaults = Array ('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's', 't' => 'index');
+ $defaults = Array (
+ 'm_cat_id' => 0, // no category
+ 'm_cat_page' => 1, // first category page
+ 'm_opener' => 's', // stay on same page
+ 't' => 'index' // main site page
+ );
+ if ($this->primaryLanguageId) {
+ // domain-based primary language
+ $defaults['m_lang'] = $this->primaryLanguageId;
+ }
+
+ if ($this->primaryThemeId) {
+ // domain-based primary theme
+ $defaults['m_theme'] = $this->primaryThemeId;
+ }
+
foreach ($defaults as $default_key => $default_value) {
- // bug: null is never returned
- if ($this->HTTPQuery->Get($default_key) == null) {
+ if ($this->HTTPQuery->Get($default_key) === false) {
$vars[$default_key] = $default_value;
}
}
Index: units/helpers/site_helper.php
===================================================================
--- units/helpers/site_helper.php (revision 0)
+++ units/helpers/site_helper.php (revision 0)
@@ -0,0 +1,44 @@
+<?php
+
+ class SiteHelper extends kHelper {
+
+ /**
+ * Returns default country
+ *
+ * @return string
+ */
+ function getDefaultCountry($country_prefix = '', $iso_format = true)
+ {
+ $country = $this->Application->siteDomainField($country_prefix . 'Country');
+
+ if ($iso_format && !$country) {
+ $country = 'USA';
+ }
+
+ if (!$iso_format && strlen($country)) {
+ return $this->getCountryId($country);
+ }
+
+ return $country;
+ }
+
+ /**
+ * Returns country id based on it's ISO code
+ *
+ * @param string $iso_code
+ * @return int
+ */
+ function getCountryId($iso_code)
+ {
+ static $cache = null;
+
+ if (!isset($cache)) {
+ $sql = 'SELECT CountryStateId, IsoCode
+ FROM ' . $this->Application->getUnitOption('country-state', 'TableName') . '
+ WHERE Type = ' . DESTINATION_TYPE_COUNTRY;
+ $cache = $this->Conn->GetCol($sql, 'IsoCode');
+ }
+
+ return $cache[$iso_code];
+ }
+ }
Index: units/languages/languages_event_handler.php
===================================================================
--- units/languages/languages_event_handler.php (revision 13453)
+++ units/languages/languages_event_handler.php (working copy)
@@ -174,12 +174,28 @@
*/
function SetCustomQuery(&$event)
{
- if ($event->Special == 'enabled') {
- $object =& $event->getObject();
- /* @var $object kDBList */
+ $object =& $event->getObject();
+ /* @var $object kDBList */
- $object->addFilter('enabled_filter', '%1$s.Enabled = 1');
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available'))) {
+ $object->addFilter('enabled_filter', '%1$s.Enabled = ' . STATUS_ACTIVE);
}
+
+ // site domain language picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'Languages');
+ }
+
+ // apply domain-based language filtering
+ $languages = $this->Application->siteDomainField('Languages');
+
+ if (strlen($languages)) {
+ $languages = explode('|', substr($languages, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.LanguageId IN (' . implode(',', $languages) . ')');
+ }
}
/**
Index: units/languages/languages_item.php
===================================================================
--- units/languages/languages_item.php (revision 13400)
+++ units/languages/languages_item.php (working copy)
@@ -60,8 +60,14 @@
{
$default = false;
if ($id == 'default') {
- $id = 1;
- $id_field_name = 'PrimaryLang';
+ // domain based primary language
+ $id = $this->Application->siteDomainField('PrimaryLanguageId');
+
+ if (!$id) {
+ $id = 1;
+ $id_field_name = 'PrimaryLang';
+ }
+
$default = true;
}
Index: units/site_domains/site_domain_eh.php
===================================================================
--- units/site_domains/site_domain_eh.php (revision 0)
+++ units/site_domains/site_domain_eh.php (revision 0)
@@ -0,0 +1,213 @@
+<?php
+
+ class SiteDomainEventHandler extends kDBEventHandler {
+
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+
+ $permissions = Array (
+ 'OnItemBuild' => Array ('self' => true),
+ );
+
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Returns ID of site domain, that matches current url
+ *
+ * @param kEvent $event
+ */
+ function getPassedID(&$event)
+ {
+ if ($event->Special == 'current') {
+ if ($this->Application->isAdmin) {
+ $event->setEventParam('raise_warnings', 0);
+ }
+ else {
+ if (PROTOCOL == 'https://') {
+ return $this->querySiteDomain('SSLUrl', rtrim($this->Application->BaseURL(), '/'));
+ }
+
+ return $this->querySiteDomain('DomainName', $_SERVER['HTTP_HOST']);
+ }
+ }
+
+ return parent::getPassedID($event);
+ }
+
+ function querySiteDomain($field, $value)
+ {
+ $site_domains = $this->getSiteDomains();
+ $name_fields = Array ('DomainName', 'SSLUrl');
+
+ // 1. try to match visited domain to any of existing
+ foreach ($site_domains as $id => $site_domain) {
+ if (in_array($field, $name_fields) && $site_domain[$field . 'UsesRegExp']) {
+ if (preg_match('/^' . $site_domain[$field] . '$/', $value)) {
+ return $id;
+ }
+ }
+ elseif ($site_domain[$field] == $value) {
+ return $id;
+ }
+
+ }
+
+ // 2. try to match domain settings based on visitor's IP address
+ foreach ($site_domains as $id => $site_domain) {
+ if (ipMatch($site_domain['DomainIPRange'], "\n")) {
+ if ($site_domain['RedirectOnIPMatch']) {
+ $this->Application->Redirect('external:http://' . $site_domain['DomainName'] . $_SERVER['REQUEST_URI']);
+ }
+
+ return $id;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Load item if id is available
+ *
+ * @param kEvent $event
+ */
+ function LoadItem(&$event)
+ {
+ if ($this->Application->isAdmin) {
+ // don't load domain data from cache
+ parent::LoadItem($event);
+
+ return ;
+ }
+
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $id = (int)$this->getPassedID($event);
+
+ if ($object->isLoaded() && ($object->GetID() == $id)) {
+ // object is already loaded by same id
+ return ;
+ }
+
+ $site_domains = $this->getSiteDomains();
+ $domain_data = array_key_exists($id, $site_domains) ? $site_domains[$id] : false;
+
+ if ($object->LoadFromHash($domain_data)) {
+ $actions =& $this->Application->recallObject('kActions');
+ $actions->Set($event->Prefix_Special.'_id', $object->GetID() );
+ }
+ else {
+ $object->setID($id);
+ }
+ }
+
+ function getSiteDomains()
+ {
+ static $cache = null;
+
+ if (!isset($cache)) {
+ if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
+ $cache = $this->Application->getCache('master:domains_parsed', false);
+ }
+ else {
+ $cache = $this->Application->getDBCache('domains_parsed');
+ }
+
+ if ($cache) {
+ $cache = unserialize($cache);
+ }
+ else {
+ $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+
+ $sql = 'SELECT *
+ FROM ' . $table_name . '
+ ORDER BY Priority DESC';
+ $cache = $this->Conn->Query($sql, $id_field);
+
+ if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
+ $this->Application->setCache('master:domains_parsed', serialize($cache));
+ }
+ else {
+ $this->Application->setDBCache('domains_parsed', serialize($cache));
+ }
+ }
+ }
+
+ return $cache;
+ }
+
+ /**
+ * Removes In-Commerce related fields, when it's not installed
+ *
+ * @param kEvent $event
+ */
+ function OnAfterConfigRead(&$event)
+ {
+ parent::OnAfterConfigRead($event);
+
+ if (!$this->Application->isModuleEnabled('In-Commerce')) {
+ $remove_fields = Array (
+ 'BillingCountry', 'ShippingCountry',
+ 'PrimaryCurrencyId', 'Currencies',
+ 'PrimaryPaymentTypeId', 'PaymentTypes'
+ );
+
+ // remove field definitions
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+
+ foreach ($remove_fields as $remove_field) {
+ unset($fields[$remove_field]);
+ }
+
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+
+ // remove grid columns
+ $grids = $this->Application->getUnitOption($event->Prefix, 'Grids');
+
+ foreach ($grids as $grid_name => $grid_info) {
+ foreach ($remove_fields as $remove_field) {
+ if (array_key_exists($remove_field, $grid_info['Fields'])) {
+ unset($grids[$grid_name]['Fields'][$remove_field]);
+ }
+ }
+ }
+
+ $this->Application->setUnitOption($event->Prefix, 'Grids', $grids);
+ }
+ }
+
+ /**
+ * Delete cached information about site domains
+ *
+ * @param kEvent $event
+ */
+ function OnSave(&$event)
+ {
+ parent::OnSave($event);
+
+ if ($event->status == erSUCCESS) {
+ $this->_deleteCache();
+ }
+ }
+
+ /**
+ * Deletes cached information about site domains
+ */
+ function _deleteCache()
+ {
+ if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
+ $this->Application->deleteCache('master:domains_parsed');
+ }
+ else {
+ $this->Application->deleteDBCache('domains_parsed');
+ }
+ }
+ }
Index: units/site_domains/site_domains_config.php
===================================================================
--- units/site_domains/site_domains_config.php (revision 0)
+++ units/site_domains/site_domains_config.php (revision 0)
@@ -0,0 +1,139 @@
+<?php
+ $config = Array (
+ 'Prefix' => 'site-domain',
+ 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
+ 'EventHandlerClass' => Array ('class' => 'SiteDomainEventHandler', 'file' => 'site_domain_eh.php', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+
+ 'AutoLoad' => true,
+
+ 'QueryString' => Array (
+ 1 => 'id',
+ 2 => 'Page',
+ 3 => 'event',
+ 4 => 'mode',
+ ),
+
+ 'IDField' => 'DomainId',
+
+ 'TableName' => TABLE_PREFIX . 'SiteDomains',
+
+ 'TitleField' => 'DomainName',
+
+ 'TitlePresets' => Array (
+ 'default' => Array (
+ 'new_status_labels' => Array ('site-domain' => '!la_title_AddingSiteDomain!'),
+ 'edit_status_labels' => Array ('site-domain' => '!la_title_EditingSiteDomain!'),
+ ),
+
+ 'site_domain_list' => Array (
+ 'prefixes' => Array ('site-domain_List'), 'format' => "!la_title_SiteDomains!",
+ 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'view', 'dbl-click'),
+ ),
+
+ 'site_domain_edit' => Array (
+ 'prefixes' => Array ('site-domain'), 'format' => "#site-domain_status# '#site-domain_titlefield#' - !la_title_General!",
+ 'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
+ ),
+ ),
+
+ 'EditTabPresets' => Array (
+ 'Default' => Array (
+ 'general' => Array ('title' => 'la_tab_General', 't' => 'site_domains/site_domain_edit', 'priority' => 1),
+ ),
+ ),
+
+ 'PermSection' => Array('main' => 'in-portal:site_domains'),
+
+ 'Sections' => Array (
+ 'in-portal:site_domains' => Array (
+ 'parent' => 'in-portal:website_setting_folder',
+ 'icon' => 'site_domain',
+ 'label' => 'la_title_SiteDomains',
+ 'url' => Array('t' => 'site_domains/site_domain_list', 'pass' => 'm'),
+ 'permissions' => Array('view', 'add', 'edit', 'delete'),
+ 'priority' => 7,
+ 'type' => stTREE,
+ ),
+ ),
+
+ 'ListSQLs' => Array (
+ '' => ' SELECT %1$s.* %2$s FROM %1$s',
+ ),
+
+ 'ListSortings' => Array (
+ '' => Array (
+ 'Sorting' => Array ('Priority' => 'desc', 'DomainName' => 'asc'),
+ )
+ ),
+
+ 'Fields' => Array (
+ 'DomainId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'DomainName' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'required' => 1, 'default' => ''),
+ 'DomainNameUsesRegExp' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'SSLUrl' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
+ 'SSLUrlUsesRegExp' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'AdminEmail' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
+ 'Country' => Array (
+ 'type' => 'string', 'max_len' => 3,
+ 'formatter' => 'kOptionsFormatter',
+ 'options_sql' => ' SELECT IF(l%2$s_Name = "", l%3$s_Name, l%2$s_Name) AS Name, IsoCode
+ FROM ' . TABLE_PREFIX . 'CountryStates
+ WHERE Type = ' . DESTINATION_TYPE_COUNTRY . '
+ ORDER BY Name',
+ 'option_key_field' => 'IsoCode', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryLanguageId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language WHERE Enabled = 1 ORDER BY PackName ASC', 'option_key_field' => 'LanguageId', 'option_title_field' => 'PackName',
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Languages' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language WHERE Enabled = 1 ORDER BY PackName ASC', 'option_key_field' => 'LanguageId', 'option_title_field' => 'PackName',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryThemeId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Theme WHERE Enabled = 1 ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Themes' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Theme WHERE Enabled = 1 ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'DomainIPRange' => Array ('type' => 'string', 'default' => NULL),
+ 'RedirectOnIPMatch' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Priority' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ ),
+
+ 'Grids' => Array (
+ 'Default' => Array (
+ 'Icons' => Array ('default' => 'icon16_item.png'),
+ 'Fields' => Array (
+ 'DomainId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
+ 'DomainName' => Array ('title' => 'la_col_DomainName', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
+ 'SSLUrl' => Array ('title' => 'la_col_SSLUrl', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
+ 'Country' => Array ('title' => 'la_col_Country', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryLanguageId' => Array ('title' => 'la_col_Language', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryThemeId' => Array ('title' => 'la_col_Theme', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'Priority' => Array ('title' => 'la_col_Priority', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
+ ),
+ ),
+ ),
+ );
Index: units/themes/theme_item.php
===================================================================
--- units/themes/theme_item.php (revision 13400)
+++ units/themes/theme_item.php (working copy)
@@ -20,8 +20,14 @@
{
$default = false;
if ($id == 'default') {
- $id = 1;
- $id_field_name = 'PrimaryTheme';
+ // domain based primary theme
+ $id = $this->Application->siteDomainField('PrimaryThemeId');
+
+ if (!$id) {
+ $id = 1;
+ $id_field_name = 'PrimaryTheme';
+ }
+
$default = true;
}
Index: units/themes/themes_eh.php
===================================================================
--- units/themes/themes_eh.php (revision 13400)
+++ units/themes/themes_eh.php (working copy)
@@ -168,13 +168,28 @@
{
parent::SetCustomQuery($event);
- if ($event->Special == 'enabled' || !$this->Application->isAdminUser) {
+ $object =& $event->getObject();
+ /* @var $object kDBList */
+
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser) {
// "enabled" special or Front-End
+ $object->addFilter('enabled_filter', '%1$s.Enabled = ' . STATUS_ACTIVE);
+ }
- $object =& $event->getObject();
- /* @var $object kDBList */
+ // site domain theme picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
- $object->addFilter('enabled_filter', '%1$s.Enabled = 1');
+ $edit_picker_helper->applyFilter($event, 'Themes');
}
+
+ // apply domain-based theme filtering
+ $themes = $this->Application->siteDomainField('Themes');
+
+ if (strlen($themes)) {
+ $themes = explode('|', substr($themes, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.ThemeId IN (' . implode(',', $themes) . ')');
+ }
}
}
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 13471)
+++ units/users/users_event_handler.php (working copy)
@@ -1370,7 +1370,15 @@
parent::OnAfterConfigRead($event);
// 1. arrange user registration countries
- $first_country = $this->Application->ConfigValue('User_Default_Registration_Country');
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $first_country = $site_helper->getDefaultCountry('', false);
+
+ if ($first_country === false) {
+ $first_country = $this->Application->ConfigValue('User_Default_Registration_Country');
+ }
+
if ($first_country) {
// update user country dropdown sql
$fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
@@ -1414,7 +1422,6 @@
$this->Application->setUnitOption($event->Prefix, 'EditTabPresets', $edit_tab_presets);
}
}
-
}
/**
site_domains_modules_v2.patch [^] (23,623 bytes) 2010-05-01 11:24
[Show Content]
Index: in-commerce/admin_templates/site_domains/site_domain_edit.tpl
===================================================================
--- in-commerce/admin_templates/site_domains/site_domain_edit.tpl (revision 0)
+++ in-commerce/admin_templates/site_domains/site_domain_edit.tpl (revision 0)
@@ -0,0 +1,73 @@
+<inp2:adm_SetPopupSize width="750" height="560"/>
+
+<inp2:m_include t="incs/header"/>
+<inp2:m_RenderElement name="combined_header" section="in-portal:site_domains" prefix="site-domain" title_preset="site_domain_edit_in_commerce" tab_preset="Default"/>
+
+<!-- ToolBar -->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
+ submit_event('site-domain', '<inp2:site-domain_SaveEvent/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
+ cancel_edit('site-domain', 'OnCancelEdit','<inp2:site-domain_SaveEvent/>','<inp2:m_Phrase label="la_FormCancelConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarButton('reset_edit', '<inp2:m_phrase label="la_ToolTip_Reset" escape="1"/>', function() {
+ reset_form('site-domain', 'OnReset', '<inp2:m_Phrase label="la_FormResetConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_PrevId/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_NextId/>');
+ }
+ ) );
+
+ a_toolbar.Render();
+
+ <inp2:m_if check="site-domain_IsSingle">
+ a_toolbar.HideButton('prev');
+ a_toolbar.HideButton('next');
+ a_toolbar.HideButton('sep1');
+ <inp2:m_else/>
+ <inp2:m_if check="site-domain_IsLast">
+ a_toolbar.DisableButton('next');
+ </inp2:m_if>
+ <inp2:m_if check="site-domain_IsFirst">
+ a_toolbar.DisableButton('prev');
+ </inp2:m_if>
+ </inp2:m_if>
+ </script>
+ </td>
+ </tr>
+</tbody>
+</table>
+
+<inp2:site-domain_SaveWarning name="grid_save_warning"/>
+<inp2:site-domain_ErrorWarning name="form_error_warning"/>
+
+<div id="scroll_container">
+ <table class="edit-form">
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="BillingCountry" title="la_fld_BillingCountry" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="ShippingCountry" title="la_fld_ShippingCountry" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryCurrencyId" title="la_fld_Currency" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="Currencies" title="la_fld_Currencies" optprefix="curr" option_key_field="CurrencyId" option_value_field="Translation"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryPaymentTypeId" title="la_fld_PaymentType" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="PaymentTypes" title="la_fld_PaymentTypes" optprefix="pt" option_key_field="PaymentTypeId" option_value_field="Name"/>
+ <inp2:m_RenderElement name="inp_edit_filler"/>
+ </table>
+</div>
+
+<inp2:m_include t="incs/footer"/>
Index: in-commerce/install/english.lang
===================================================================
--- in-commerce/install/english.lang (revision 13400)
+++ in-commerce/install/english.lang (working copy)
@@ -90,6 +90,7 @@
<PHRASE Label="la_col_Amount" Module="In-Commerce" Type="1">QW1vdW50</PHRASE>
<PHRASE Label="la_col_Availability" Module="In-Commerce" Type="1">QXZhaWwu</PHRASE>
<PHRASE Label="la_col_BaseFee" Module="In-Commerce" Type="1">QmFzZSBGZWU=</PHRASE>
+ <PHRASE Label="la_col_BillingCountry" Module="In-Commerce" Type="1">QmlsbGluZyBDb3VudHJ5</PHRASE>
<PHRASE Label="la_col_BuiltIn" Module="In-Commerce" Type="1">QnVpbHQtSW4=</PHRASE>
<PHRASE Label="la_col_CODallowed" Module="In-Commerce" Type="1">Q09EIEFsbG93ZWQ=</PHRASE>
<PHRASE Label="la_col_Code" Module="In-Commerce" Type="1">Q29kZQ==</PHRASE>
@@ -103,6 +104,7 @@
<PHRASE Label="la_col_CouponCode" Module="In-Commerce" Type="1">Q291cG9uIENvZGU=</PHRASE>
<PHRASE Label="la_col_CouponItemType" Module="In-Commerce" Type="1">Q291cG9uIEl0ZW0gVHlwZQ==</PHRASE>
<PHRASE Label="la_col_CreditCardNumber" Module="In-Commerce" Type="1">Q3JlZGl0IENhcmQgTnVtYmVy</PHRASE>
+ <PHRASE Label="la_col_Currency" Module="In-Commerce" Type="1">Q3VycmVuY3k=</PHRASE>
<PHRASE Label="la_col_CurrencyName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_col_CurrencySymbol" Module="In-Commerce" Type="1">U3ltYm9s</PHRASE>
<PHRASE Label="la_col_CurrencySymbolPosition" Module="In-Commerce" Type="1">U3ltYm9sIFBvc2l0aW9u</PHRASE>
@@ -180,6 +182,7 @@
<PHRASE Label="la_col_ReturnedOn" Module="In-Commerce" Type="1">UmV0LiBEYXRl</PHRASE>
<PHRASE Label="la_col_ReturnType" Module="In-Commerce" Type="1">UmV0LiBUeXBl</PHRASE>
<PHRASE Label="la_col_Shipping" Module="In-Commerce" Type="1">U2hpcHBpbmc=</PHRASE>
+ <PHRASE Label="la_col_ShippingCountry" Module="In-Commerce" Type="1">U2hpcHBpbmcgQ291bnRyeQ==</PHRASE>
<PHRASE Label="la_col_ShippingFromLocation" Module="In-Commerce" Type="1">RnJvbSBMb2NhdGlvbg==</PHRASE>
<PHRASE Label="la_col_ShippingName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_col_ShippingQuoteEngineName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
@@ -311,6 +314,8 @@
<PHRASE Label="la_fld_CostType" Module="In-Commerce" Type="1">Q29zdCBUeXBl</PHRASE>
<PHRASE Label="la_fld_CouponCode" Module="In-Commerce" Type="1">Q291cG9uIENvZGU=</PHRASE>
<PHRASE Label="la_fld_CreditCardNumber" Module="In-Commerce" Type="1">Q3JlZGl0IENhcmQgTnVtYmVy</PHRASE>
+ <PHRASE Label="la_fld_Currencies" Module="In-Commerce" Type="1">Q3VycmVuY2llcw==</PHRASE>
+ <PHRASE Label="la_fld_Currency" Module="In-Commerce" Type="1">Q3VycmVuY3k=</PHRASE>
<PHRASE Label="la_fld_CurrencyName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_fld_CurrencySymbol" Module="In-Commerce" Type="1">U3ltYm9s</PHRASE>
<PHRASE Label="la_fld_CurrencySymbolPosition" Module="In-Commerce" Type="1">U3ltYm9sIFBvc2l0aW9u</PHRASE>
@@ -381,6 +386,7 @@
<PHRASE Label="la_fld_PaymentType" Module="In-Commerce" Type="1">UGF5bWVudCBUeXBl</PHRASE>
<PHRASE Label="la_fld_PaymentTypeCurrencies" Module="In-Commerce" Type="1">QXZhaWxhYmxlIEN1cnJlbmNpZXM=</PHRASE>
<PHRASE Label="la_fld_PaymentTypeId" Module="In-Commerce" Type="1">UGF5bWVudCBUeXBlIElk</PHRASE>
+ <PHRASE Label="la_fld_PaymentTypes" Module="In-Commerce" Type="1">UGF5bWVudCBUeXBlcw==</PHRASE>
<PHRASE Label="la_fld_PercentSurcharge" Module="In-Commerce" Type="1">UGVyY2VudCBTdXJjaGFyZ2U=</PHRASE>
<PHRASE Label="la_fld_Period" Module="In-Commerce" Type="1">UGVyaW9k</PHRASE>
<PHRASE Label="la_fld_PlacedOrdersEdit" Module="In-Commerce" Type="1">QWxsb3cgUGxhY2VkIE9yZGVycyBFZGl0aW5n</PHRASE>
Index: in-commerce/install/install_schema.sql
===================================================================
--- in-commerce/install/install_schema.sql (revision 13400)
+++ in-commerce/install/install_schema.sql (working copy)
@@ -711,4 +711,18 @@
ResourceId int(10) unsigned NOT NULL default '0',
KEY ResourceId (ResourceId),
PRIMARY KEY (CustomDataId)
-);
\ No newline at end of file
+);
+
+ALTER TABLE SiteDomains
+ ADD COLUMN BillingCountry varchar(3) NOT NULL DEFAULT '',
+ ADD COLUMN ShippingCountry varchar(3) NOT NULL DEFAULT '',
+ ADD COLUMN PrimaryCurrencyId int(11) NOT NULL DEFAULT '0',
+ ADD COLUMN Currencies varchar(255) NOT NULL DEFAULT '',
+ ADD COLUMN PrimaryPaymentTypeId int(11) NOT NULL DEFAULT '0',
+ ADD COLUMN PaymentTypes varchar(255) NOT NULL DEFAULT '',
+ ADD INDEX (BillingCountry),
+ ADD INDEX (ShippingCountry),
+ ADD INDEX (PrimaryCurrencyId),
+ ADD INDEX (Currencies),
+ ADD INDEX (PrimaryPaymentTypeId),
+ ADD INDEX (PaymentTypes);
Index: in-commerce/install/upgrades.sql
===================================================================
--- in-commerce/install/upgrades.sql (revision 13465)
+++ in-commerce/install/upgrades.sql (working copy)
@@ -126,4 +126,18 @@
UPDATE ConfigurationValues
SET ValueList = '0=lu_none||<SQL+>SELECT l%3$s_Name AS OptionName, CountryStateId AS OptionValue FROM <PREFIX>CountryStates WHERE Type = 1 ORDER BY OptionName</SQL>'
-WHERE ValueList = '0=lu_none||<SQL>SELECT DestName AS OptionName, DestAbbr AS OptionValue FROM <PREFIX>StdDestinations WHERE DestParentId IS NULL Order BY OptionName</SQL>';
\ No newline at end of file
+WHERE ValueList = '0=lu_none||<SQL>SELECT DestName AS OptionName, DestAbbr AS OptionValue FROM <PREFIX>StdDestinations WHERE DestParentId IS NULL Order BY OptionName</SQL>';
+
+ALTER TABLE SiteDomains
+ ADD COLUMN BillingCountry varchar(3) NOT NULL DEFAULT '',
+ ADD COLUMN ShippingCountry varchar(3) NOT NULL DEFAULT '',
+ ADD COLUMN PrimaryCurrencyId int(11) NOT NULL DEFAULT '0',
+ ADD COLUMN Currencies varchar(255) NOT NULL DEFAULT '',
+ ADD COLUMN PrimaryPaymentTypeId int(11) NOT NULL DEFAULT '0',
+ ADD COLUMN PaymentTypes varchar(255) NOT NULL DEFAULT '',
+ ADD INDEX (BillingCountry),
+ ADD INDEX (ShippingCountry),
+ ADD INDEX (PrimaryCurrencyId),
+ ADD INDEX (Currencies),
+ ADD INDEX (PrimaryPaymentTypeId),
+ ADD INDEX (PaymentTypes);
\ No newline at end of file
Index: in-commerce/units/addresses/addresses_event_handler.php
===================================================================
--- in-commerce/units/addresses/addresses_event_handler.php (revision 13465)
+++ in-commerce/units/addresses/addresses_event_handler.php (working copy)
@@ -318,4 +318,21 @@
return ;
}
}
+
+ /**
+ * Sets default country for new addresses to Latvia
+ *
+ * @param kEvent $event
+ */
+ function OnAfterConfigRead(&$event)
+ {
+ parent::OnAfterConfigRead($event);
+
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $fields['Country']['default'] = $site_helper->getDefaultCountry('Shipping');
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ }
}
\ No newline at end of file
Index: in-commerce/units/currencies/currencies_event_handler.php
===================================================================
--- in-commerce/units/currencies/currencies_event_handler.php (revision 13400)
+++ in-commerce/units/currencies/currencies_event_handler.php (working copy)
@@ -95,6 +95,23 @@
if (!$this->Application->isAdminUser) {
$object->addFilter('status_filter', $object->TableName.'.Status = 1');
}
+
+ // site domain currency picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'Currencies');
+ $object->addFilter('status_filter', '%1$s.Status = ' . STATUS_ACTIVE);
+ }
+
+ // apply domain-based currency filtering
+ $currencies = $this->Application->siteDomainField('Currencies');
+
+ if (strlen($currencies)) {
+ $currencies = explode('|', substr($currencies, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.CurrencyId IN (' . implode(',', $currencies) . ')');
+ }
}
/**
Index: in-commerce/units/orders/orders_event_handler.php
===================================================================
--- in-commerce/units/orders/orders_event_handler.php (revision 13465)
+++ in-commerce/units/orders/orders_event_handler.php (working copy)
@@ -538,17 +538,22 @@
function OnProceedToBilling(&$event)
{
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
- if($items_info)
- {
- list($id,$field_values) = each($items_info);
+ if ($items_info) {
+ list($id, $field_values) = each($items_info);
$object =& $event->getObject();
$payment_type_id = $object->GetDBField('PaymentType');
- if(!$payment_type_id)
- {
- $default_type = $this->Conn->GetOne('SELECT PaymentTypeId FROM '.TABLE_PREFIX.'PaymentTypes WHERE IsPrimary = 1');
- if($default_type)
- {
+ if (!$payment_type_id) {
+ $default_type = $this->Application->siteDomainField('PrimaryPaymentTypeId');
+
+ if (!$default_type) {
+ $sql = 'SELECT PaymentTypeId
+ FROM ' . TABLE_PREFIX . 'PaymentTypes
+ WHERE IsPrimary = 1';
+ $default_type = $this->Conn->GetOne($sql);
+ }
+
+ if ($default_type) {
$field_values['PaymentType'] = $default_type;
$items_info[$id] = $field_values;
$this->Application->SetVar( $event->getPrefixSpecial(true), $items_info );
@@ -3824,15 +3829,34 @@
$fields['Number']['format'] = str_replace('%06d', '%0'.$order_number.'d', $fields['Number']['format']);
$fields['SubNumber']['format'] = str_replace('%03d', '%0'.$order_sub_number.'d', $fields['SubNumber']['format']);
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $fields['BillingCountry']['default'] = $site_helper->getDefaultCountry('Billing');
+ $fields['ShippingCountry']['default'] = $site_helper->getDefaultCountry('Shipping');
+
if (!$this->Application->isAdminUser) {
$user_groups = explode(',', $this->Application->RecallVar('UserGroups'));
$default_group = $this->Application->ConfigValue('User_LoggedInGroup');
if (!in_array($default_group, $user_groups)){
$user_groups[]=$default_group;
}
- $fields['PaymentType']['options_sql'] .= ' AND ';
- $fields['PaymentType']['options_sql'] .= ' (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%")';
+ $sql = $fields['PaymentType']['options_sql'];
+
+ // limit payment types by domain
+ $payment_types = $this->Application->siteDomainField('PaymentTypes');
+
+ if (strlen($payment_types)) {
+ $payment_types = explode('|', substr($payment_types, 1, -1));
+ $sql .= ' AND PaymentTypeId IN (' . implode(',', $payment_types) . ')';
+ }
+
+ // limit payment types by user group
+ $sql .= ' AND (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%")';
+
+ $fields['PaymentType']['options_sql'] = $sql;
+
}
$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
Index: in-commerce/units/payment_type/payment_type_event_handler.php
===================================================================
--- in-commerce/units/payment_type/payment_type_event_handler.php (revision 13400)
+++ in-commerce/units/payment_type/payment_type_event_handler.php (working copy)
@@ -218,4 +218,38 @@
return parent::getPassedID($event);
}
+ /**
+ * Apply system filter to themes list
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ parent::SetCustomQuery($event);
+
+ $object =& $event->getObject();
+ /* @var $object kDBList */
+
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser) {
+ // "enabled" special or Front-End
+ $object->addFilter('enabled_filter', '%1$s.Status = ' . STATUS_ACTIVE);
+ }
+
+ // site domain payment type picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'PaymentTypes');
+ }
+
+ // apply domain-based payment type filtering
+ $payment_types = $this->Application->siteDomainField('PaymentTypes');
+
+ if (strlen($payment_types)) {
+ $payment_types = explode('|', substr($payment_types, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.PaymentTypeId IN (' . implode(',', $payment_types) . ')');
+ }
+ }
+
}
\ No newline at end of file
Index: in-commerce/units/sections/section_eh.php
===================================================================
--- in-commerce/units/sections/section_eh.php (revision 0)
+++ in-commerce/units/sections/section_eh.php (revision 0)
@@ -0,0 +1,101 @@
+<?php
+/**
+* @version $Id$
+* @package In-Commerce
+* @copyright Copyright (C) 1997 - 2010 Intechnic. All rights reserved.
+* @license Commercial License
+* This software is protected by copyright law and international treaties.
+* Unauthorized reproduction or unlicensed usage of the code of this program,
+* or any portion of it may result in severe civil and criminal penalties,
+* and will be prosecuted to the maximum extent possible under the law
+* See http://www.in-portal.org/commercial-license for copyright notices and details.
+*/
+
+ defined('FULL_PATH') or die('restricted access!');
+
+ class InCommerceEventHandler extends kEventHandler {
+
+ /**
+ * [HOOK] Creates site domain editing tab
+ *
+ * @param kEvent $event
+ */
+ function OnModifySiteDomainConfig(&$event)
+ {
+ $edit_tab_presets = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'EditTabPresets');
+ $edit_tab_presets['Default']['in-commerce'] = Array (
+ 'title' => 'la_title_In-Commerce', 't' => 'in-commerce/site_domains/site_domain_edit', 'priority' => 2.1
+ );
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'EditTabPresets', $edit_tab_presets);
+
+ $title_presets = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'TitlePresets');
+ $title_presets['site_domain_edit_in_commerce'] = Array (
+ 'prefixes' => Array ('site-domain'), 'format' => "#site-domain_status# '#site-domain_titlefield#' - !la_title_In-Commerce!",
+ 'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
+ );
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'TitlePresets', $title_presets);
+
+ $new_fields = Array (
+ 'BillingCountry' => Array (
+ 'type' => 'string', 'max_len' => 3,
+ 'formatter' => 'kOptionsFormatter',
+ 'options_sql' => ' SELECT IF(l%2$s_Name = "", l%3$s_Name, l%2$s_Name) AS Name, IsoCode
+ FROM ' . TABLE_PREFIX . 'CountryStates
+ WHERE Type = ' . DESTINATION_TYPE_COUNTRY . '
+ ORDER BY Name',
+ 'option_key_field' => 'IsoCode', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'ShippingCountry' => Array (
+ 'type' => 'string', 'max_len' => 3,
+ 'formatter' => 'kOptionsFormatter',
+ 'options_sql' => ' SELECT IF(l%2$s_Name = "", l%3$s_Name, l%2$s_Name) AS Name, IsoCode
+ FROM ' . TABLE_PREFIX . 'CountryStates
+ WHERE Type = ' . DESTINATION_TYPE_COUNTRY . '
+ ORDER BY Name',
+ 'option_key_field' => 'IsoCode', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryCurrencyId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Currencies WHERE Status = 1 ORDER BY ISO', 'option_key_field' => 'CurrencyId', 'option_title_field' => 'Name', 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Currencies' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Currencies WHERE Status = 1 ORDER BY ISO', 'option_key_field' => 'CurrencyId', 'option_title_field' => 'Name', 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryPaymentTypeId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PaymentTypes WHERE Status = 1 ORDER BY Name ASC', 'option_key_field' => 'PaymentTypeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'PaymentTypes' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PaymentTypes WHERE Status = 1 ORDER BY Name ASC', 'option_key_field' => 'PaymentTypeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ );
+
+ $fields = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Fields');
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Fields', array_merge_recursive2($fields, $new_fields));
+
+ $new_columns = Array (
+ 'BillingCountry' => Array ('title' => 'la_col_BillingCountry', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'ShippingCountry' => Array ('title' => 'la_col_ShippingCountry', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryCurrencyId' => Array ('title' => 'la_col_Currency', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryPaymentTypeId' => Array ('title' => 'la_col_PaymentType', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ );
+
+ $grids = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Grids');
+ $grids['Default']['Fields'] = array_merge_recursive2($grids['Default']['Fields'], $new_columns);
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Grids', $grids);
+
+ if (!$this->Application->isAdmin) {
+ // re-configure object, because it's recalled before kUnitConfigReader::AfterConfigRead is called
+ $this->Application->siteDomain->defineFields();
+ }
+ }
+
+ }
\ No newline at end of file
Index: in-commerce/units/sections/sections_config.php
===================================================================
--- in-commerce/units/sections/sections_config.php (revision 0)
+++ in-commerce/units/sections/sections_config.php (revision 0)
@@ -0,0 +1,34 @@
+<?php
+/**
+* @version $Id$
+* @package In-Commerce
+* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
+* @license Commercial License
+* This software is protected by copyright law and international treaties.
+* Unauthorized reproduction or unlicensed usage of the code of this program,
+* or any portion of it may result in severe civil and criminal penalties,
+* and will be prosecuted to the maximum extent possible under the law
+* See http://www.in-portal.org/commercial-license for copyright notices and details.
+*/
+
+ defined('FULL_PATH') or die('restricted access!');
+
+ $config = Array (
+ 'Prefix' => 'in-commerce-sections',
+
+ 'EventHandlerClass' => Array ('class' => 'InCommerceEventHandler', 'file' => 'section_eh.php', 'build_event' => 'OnBuild'), // for OnAfterConfigRead event
+ 'TagProcessorClass' => Array ('class' => 'kTagProcessor', 'file' => '', 'build_event' => 'OnBuild'), // for tree drawing
+
+ 'Hooks' => Array (
+ Array (
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'site-domain',
+ 'HookToSpecial' => '*',
+ 'HookToEvent' => Array ('OnAfterConfigRead'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '*',
+ 'DoEvent' => 'OnModifySiteDomainConfig',
+ ),
+ ),
+ );
\ No newline at end of file
site_domains_core_v3.patch [^] (64,906 bytes) 2010-05-05 09:23
[Show Content]
Index: admin_templates/site_domains/site_domain_edit.tpl
===================================================================
--- admin_templates/site_domains/site_domain_edit.tpl (revision 0)
+++ admin_templates/site_domains/site_domain_edit.tpl (revision 0)
@@ -0,0 +1,123 @@
+<inp2:adm_SetPopupSize width="750" height="560"/>
+
+<inp2:m_include t="incs/header"/>
+<inp2:m_RenderElement name="combined_header" section="in-portal:site_domains" prefix="site-domain" title_preset="site_domain_edit" tab_preset="Default"/>
+
+<!-- ToolBar -->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
+ submit_event('site-domain', '<inp2:site-domain_SaveEvent/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
+ cancel_edit('site-domain', 'OnCancelEdit','<inp2:site-domain_SaveEvent/>','<inp2:m_Phrase label="la_FormCancelConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarButton('reset_edit', '<inp2:m_phrase label="la_ToolTip_Reset" escape="1"/>', function() {
+ reset_form('site-domain', 'OnReset', '<inp2:m_Phrase label="la_FormResetConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_PrevId/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_NextId/>');
+ }
+ ) );
+
+ a_toolbar.Render();
+
+ <inp2:m_if check="site-domain_IsSingle">
+ a_toolbar.HideButton('prev');
+ a_toolbar.HideButton('next');
+ a_toolbar.HideButton('sep1');
+ <inp2:m_else/>
+ <inp2:m_if check="site-domain_IsLast">
+ a_toolbar.DisableButton('next');
+ </inp2:m_if>
+ <inp2:m_if check="site-domain_IsFirst">
+ a_toolbar.DisableButton('prev');
+ </inp2:m_if>
+ </inp2:m_if>
+ </script>
+ </td>
+ </tr>
+</tbody>
+</table>
+
+<inp2:site-domain_SaveWarning name="grid_save_warning"/>
+<inp2:site-domain_ErrorWarning name="form_error_warning"/>
+
+<inp2:m_DefineElement name="inp_edit_regexp_box" class="" format="" is_last="" maxlength="" onblur="" onchange="" size="" onkeyup="" hint_label="" style="width: 400px">
+ <inp2:m_if check="{$prefix}_FieldVisible" field="$field">
+ <tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
+ <inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" hint_label="$hint_label" is_last="$is_last"/>
+ <td class="control-cell">
+ <input type="hidden" id="<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>" name="<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>" value="<inp2:{$prefix}_Field field='{$field}UsesRegExp' db='db'/>">
+ <input tabindex="<inp2:m_get param='tab_index'/>" title="<inp2:m_Phrase name='la_hint_UsingRegularExpression' html_escape='1'/>" type="checkbox" id="_cb_<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>" <inp2:{$prefix}_Field field="{$field}UsesRegExp" checked="checked" db="db"/> onchange="update_checkbox(this, document.getElementById('<inp2:{$prefix}_InputName field='{$field}UsesRegExp'/>'));"/>
+
+ <input style="<inp2:m_Param name='style'/>" type="text" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' format='$format'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" maxlength="<inp2:m_param name='maxlength'/>" class="<inp2:m_param name='class'/>" onblur="<inp2:m_Param name='onblur'/>" onkeyup="<inp2:m_Param name='onkeyup'/>" onchange="<inp2:m_Param name='onchange'/>">
+ </td>
+ <inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
+ </tr>
+ </inp2:m_if>
+</inp2:m_DefineElement>
+
+<div id="scroll_container">
+ <table class="edit-form">
+ <inp2:m_RenderElement name="inp_id_label" prefix="site-domain" field="DomainId" title="la_fld_Id"/>
+ <inp2:m_RenderElement name="inp_edit_regexp_box" prefix="site-domain" field="DomainName" title="la_fld_DomainName"/>
+ <inp2:m_RenderElement name="inp_edit_regexp_box" prefix="site-domain" field="SSLUrl" title="la_fld_SSLUrl" hint_label="la_hint_SSLUrl"/>
+ <inp2:m_RenderElement name="inp_edit_box" prefix="site-domain" field="AdminEmail" title="la_fld_AdminEmail"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="Country" title="la_fld_Country" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryLanguageId" title="la_fld_Language" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="Languages" title="la_fld_Languages" optprefix="lang" option_key_field="LanguageId" option_value_field="PackName"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryThemeId" title="la_fld_Theme" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="Themes" title="la_fld_Themes" optprefix="theme" option_key_field="ThemeId" option_value_field="Name"/>
+
+ <inp2:m_RenderElement name="inp_edit_radio" prefix="site-domain" field="RedirectOnIPMatch" title="la_fld_RedirectOnIPMatch"/>
+ <inp2:m_RenderElement name="inp_edit_textarea" prefix="site-domain" field="DomainIPRange" title="la_fld_DomainIPRange" hint_label="la_hint_DomainIPRange" allow_html="0"/>
+ <inp2:m_RenderElement name="inp_edit_box" prefix="site-domain" field="ExternalUrl" title="la_fld_ExternalUrl"/>
+
+ <inp2:m_RenderElement name="inp_edit_box" prefix="site-domain" field="Priority" title="la_fld_Priority" style="width: 50px;"/>
+
+ <inp2:m_RenderElement name="inp_edit_filler"/>
+ </table>
+</div>
+
+<script type="text/javascript">
+ var $field_mask = jq('<inp2:site-domain_InputName name="#FIELD_NAME#" js_escape="1"/>');
+
+ $(document).ready(
+ function () {
+ var $modes = $("input[name='" + $field_mask.replace('#FIELD_NAME#', 'RedirectOnIPMatch') + "']");
+
+ $modes.click(
+ function ($e) {
+ processRedirectMode( $(this).val() );
+ }
+ );
+
+ processRedirectMode( $modes.filter(':checked').val() );
+ }
+ );
+
+ function processRedirectMode($mode) {
+ $mode = parseInt($mode);
+
+ $('#' + $field_mask.replace('#FIELD_NAME#', 'DomainIPRange')).attr('disabled', $mode > 0 ? '' : 'disabled');
+ $('#' + $field_mask.replace('#FIELD_NAME#', 'ExternalUrl')).attr('disabled', $mode == 2 ? '' : 'disabled');
+ }
+</script>
+
+<inp2:m_include t="incs/footer"/>
Index: admin_templates/site_domains/site_domain_list.tpl
===================================================================
--- admin_templates/site_domains/site_domain_list.tpl (revision 0)
+++ admin_templates/site_domains/site_domain_list.tpl (revision 0)
@@ -0,0 +1,48 @@
+<inp2:m_include t="incs/header"/>
+<inp2:m_RenderElement name="combined_header" section="in-portal:site_domains" prefix="site-domain" title_preset="site_domain_list" pagination="1"/>
+
+<!-- ToolBar -->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ //do not rename - this function is used in default grid for double click!
+ function edit()
+ {
+ std_edit_item('site-domain', 'site_domains/site_domain_edit');
+ }
+
+ var a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('new_item', '<inp2:m_phrase label="la_ToolTip_NewSiteDomain" escape="1"/>::<inp2:m_phrase label="la_ToolTip_Add" escape="1"/>',
+ function() {
+ std_precreate_item('site-domain', 'site_domains/site_domain_edit');
+ } ) );
+
+ a_toolbar.AddButton( new ToolBarButton('edit', '<inp2:m_phrase label="la_ToolTip_Edit" escape="1"/>::<inp2:m_phrase label="la_ShortToolTip_Edit" escape="1"/>', edit) );
+ a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>',
+ function() {
+ std_delete_items('site-domain')
+ } ) );
+
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
+ show_viewmenu(a_toolbar,'view');
+ }
+ ) );
+
+ a_toolbar.Render();
+ </script>
+ </td>
+ <inp2:m_RenderElement name="search_main_toolbar" prefix="site-domain" grid="Default"/>
+ </tr>
+</tbody>
+</table>
+
+<inp2:m_RenderElement name="grid" PrefixSpecial="site-domain" IdField="DomainId" grid="Default"/>
+<script type="text/javascript">
+ Grids['site-domain'].SetDependantToolbarButtons( new Array('edit','delete') );
+</script>
+<inp2:m_include t="incs/footer"/>
Index: install/english.lang
===================================================================
--- install/english.lang (revision 13470)
+++ install/english.lang (working copy)
@@ -13,6 +13,7 @@
<PHRASE Label="la_Auto" Module="Core" Type="1">QXV0bw==</PHRASE>
<PHRASE Label="la_Automatic" Module="Core" Type="1">QXV0b21hdGlj</PHRASE>
<PHRASE Label="la_AvailableColumns" Module="Core" Type="1">QXZhaWxhYmxlIENvbHVtbnM=</PHRASE>
+ <PHRASE Label="la_AvailableItems" Module="Core" Type="1">QXZhaWxhYmxlIEl0ZW1z</PHRASE>
<PHRASE Label="la_Background" Module="Core" Type="1">QmFja2dyb3VuZA==</PHRASE>
<PHRASE Label="la_Borders" Module="Core" Type="1">Qm9yZGVycw==</PHRASE>
<PHRASE Label="la_btn_BrowseMode" Module="Core" Type="1">QnJvd3NlIE1vZGU=</PHRASE>
@@ -60,8 +61,10 @@
<PHRASE Label="la_col_CategoryName" Module="Core" Type="1">U2VjdGlvbiBOYW1l</PHRASE>
<PHRASE Label="la_col_Changes" Module="Core" Type="1">Q2hhbmdlcw==</PHRASE>
<PHRASE Label="la_col_Charset" Module="Core" Type="1">Q2hhcnNldA==</PHRASE>
+ <PHRASE Label="la_col_Country" Module="Core" Type="1">Q291bnRyeQ==</PHRASE>
<PHRASE Label="la_col_CreatedOn" Module="Core" Type="1">Q3JlYXRlZCBPbg==</PHRASE>
<PHRASE Label="la_col_Description" Module="Core" Type="1">RGVzY3JpcHRpb24=</PHRASE>
+ <PHRASE Label="la_col_DomainName" Module="Core" Type="1">RG9tYWluIE5hbWU=</PHRASE>
<PHRASE Label="la_col_Duration" Module="Core" Type="1">RHVyYXRpb24=</PHRASE>
<PHRASE Label="la_col_Effective" Module="Core" Type="1">RWZmZWN0aXZl</PHRASE>
<PHRASE Label="la_col_Email" Module="Core" Type="1">RW1haWw=</PHRASE>
@@ -179,6 +182,7 @@
<PHRASE Label="la_col_ShortIsoCode" Module="Core" Type="1">U2hvcnQgSVNPIENvZGU=</PHRASE>
<PHRASE Label="la_col_SkinName" Module="Core" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_col_SortBy" Module="Core" Type="1">U29ydCBieQ==</PHRASE>
+ <PHRASE Label="la_col_SSLUrl" Module="Core" Type="1">U1NMIFVybA==</PHRASE>
<PHRASE Label="la_col_StateCountry" Module="Core" Type="1">U3RhdGUgQ291bnRyeQ==</PHRASE>
<PHRASE Label="la_col_Status" Module="Core" Type="1">U3RhdHVz</PHRASE>
<PHRASE Label="la_col_StopWord" Module="Core" Type="1">U3RvcCBXb3Jk</PHRASE>
@@ -189,6 +193,7 @@
<PHRASE Label="la_col_TargetId" Module="Core" Type="1">SXRlbQ==</PHRASE>
<PHRASE Label="la_col_TargetType" Module="Core" Type="1">SXRlbSBUeXBl</PHRASE>
<PHRASE Label="la_col_TemplateType" Module="Core" Type="1">VGVtcGxhdGU=</PHRASE>
+ <PHRASE Label="la_col_Theme" Module="Core" Type="1">VGhlbWU=</PHRASE>
<PHRASE Label="la_col_ThesaurusTerm" Module="Core" Type="1">VGhlc2F1cnVzIFRlcm0=</PHRASE>
<PHRASE Label="la_col_ThesaurusType" Module="Core" Type="1">VGhlc2F1cnVzIFR5cGU=</PHRASE>
<PHRASE Label="la_col_Title" Module="Core" Type="1">VGl0bGU=</PHRASE>
@@ -343,6 +348,7 @@
<PHRASE Label="la_fld_Action" Module="Core" Type="1">QWN0aW9u</PHRASE>
<PHRASE Label="la_fld_AddressLine1" Module="Core" Type="1">QWRkcmVzcyBMaW5lIDE=</PHRASE>
<PHRASE Label="la_fld_AddressLine2" Module="Core" Type="1">QWRkcmVzcyBMaW5lIDI=</PHRASE>
+ <PHRASE Label="la_fld_AdminEmail" Module="Core" Type="1">TWVzc2FnZXMgZnJvbSBTaXRlIEFkbWluIGFyZSBmcm9t</PHRASE>
<PHRASE Label="la_fld_AdminInterfaceLang" Module="Core" Type="1">QWRtaW4gUHJpbWFyeQ==</PHRASE>
<PHRASE Label="la_fld_AdvancedCSS" Module="Core" Type="1">QWR2YW5jZWQgQ1NT</PHRASE>
<PHRASE Label="la_fld_AdvancedSearch" Module="Core" Type="1">QWR2YW5jZWQgU2VhcmNo</PHRASE>
@@ -394,6 +400,8 @@
<PHRASE Label="la_fld_Display" Module="Core" Type="1">RGlzcGxheQ==</PHRASE>
<PHRASE Label="la_fld_DisplayInGrid" Module="Core" Type="1">RGlzcGxheSBpbiBHcmlk</PHRASE>
<PHRASE Label="la_fld_DisplayName" Module="Core" Type="1">RmllbGQgTGFiZWw=</PHRASE>
+ <PHRASE Label="la_fld_DomainIPRange" Module="Core" Type="1">UmFuZ2Ugb2YgSVBz</PHRASE>
+ <PHRASE Label="la_fld_DomainName" Module="Core" Type="1">RG9tYWluIE5hbWU=</PHRASE>
<PHRASE Label="la_fld_DoNotEncode" Module="Core" Type="1">QXMgUGxhaW4gVGV4dA==</PHRASE>
<PHRASE Label="la_fld_Duration" Module="Core" Type="1">RHVyYXRpb24=</PHRASE>
<PHRASE Label="la_fld_EditorsPick" Module="Core" Type="1">RWRpdG9ycyBQaWNr</PHRASE>
@@ -477,6 +485,7 @@
<PHRASE Label="la_fld_Language" Module="Core" Type="1">TGFuZ3VhZ2U=</PHRASE>
<PHRASE Label="la_fld_LanguageFile" Module="Core" Type="1">TGFuZ3VhZ2UgRmlsZQ==</PHRASE>
<PHRASE Label="la_fld_LanguageId" Module="Core" Type="1">TGFuZ3VhZ2UgSUQ=</PHRASE>
+ <PHRASE Label="la_fld_Languages" Module="Core" Type="1">TGFuZ3VhZ2Vz</PHRASE>
<PHRASE Label="la_fld_LastName" Module="Core" Type="1">TGFzdCBOYW1l</PHRASE>
<PHRASE Label="la_fld_LastRunOn" Module="Core" Type="1">TGFzdCBSdW4gT24=</PHRASE>
<PHRASE Label="la_fld_LastRunStatus" Module="Core" Type="1">TGFzdCBSdW4gU3RhdHVz</PHRASE>
@@ -545,6 +554,7 @@
<PHRASE Label="la_fld_PrimaryTranslation" Module="Core" Type="1">UHJpbWFyeSBMYW5ndWFnZSBQaHJhc2U=</PHRASE>
<PHRASE Label="la_fld_Priority" Module="Core" Type="1">T3JkZXI=</PHRASE>
<PHRASE Label="la_fld_Rating" Module="Core" Type="1">UmF0aW5n</PHRASE>
+ <PHRASE Label="la_fld_RedirectOnIPMatch" Module="Core" Type="1">Rm9yY2UgUmVkaXJlY3QgKHdoZW4gdXNlcidzIElQIG1hdGNoZXMp</PHRASE>
<PHRASE Label="la_fld_ReferrerURL" Module="Core" Type="1">UmVmZXJyZXIgVVJM</PHRASE>
<PHRASE Label="la_fld_RelatedSearchKeyword" Module="Core" Type="1">S2V5d29yZA==</PHRASE>
<PHRASE Label="la_fld_RelationshipType" Module="Core" Type="1">VHlwZQ==</PHRASE>
@@ -579,6 +589,7 @@
<PHRASE Label="la_fld_SkinName" Module="Core" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_fld_SkipFirstRow" Module="Core" Type="1">U2tpcCBGaXJzdCBSb3c=</PHRASE>
<PHRASE Label="la_fld_SortValues" Module="Core" Type="1">U29ydCBWYWx1ZXM=</PHRASE>
+ <PHRASE Label="la_fld_SSLUrl" Module="Core" Type="1">U1NMIEZ1bGwgVVJM</PHRASE>
<PHRASE Label="la_fld_State" Module="Core" Type="1">U3RhdGU=</PHRASE>
<PHRASE Label="la_fld_StateCountry" Module="Core" Type="1">U3RhdGUgQ291bnRyeQ==</PHRASE>
<PHRASE Label="la_fld_Status" Module="Core" Type="1">U3RhdHVz</PHRASE>
@@ -595,6 +606,8 @@
<PHRASE Label="la_fld_TextAlign" Module="Core" Type="1">VGV4dCBBbGlnbg==</PHRASE>
<PHRASE Label="la_fld_TextDecoration" Module="Core" Type="1">VGV4dCBEZWNvcmF0aW9u</PHRASE>
<PHRASE Label="LA_FLD_TEXTVERSION" Module="Core" Type="1">VGV4dCBWZXJzaW9u</PHRASE>
+ <PHRASE Label="la_fld_Theme" Module="Core" Type="1">VGhlbWU=</PHRASE>
+ <PHRASE Label="la_fld_Themes" Module="Core" Type="1">VGhlbWVz</PHRASE>
<PHRASE Label="la_fld_ThesaurusTerm" Module="Core" Type="1">VGhlc2F1cnVzIFRlcm0=</PHRASE>
<PHRASE Label="la_fld_ThesaurusType" Module="Core" Type="1">VGhlc2F1cnVzIFR5cGU=</PHRASE>
<PHRASE Label="la_fld_ThousandSep" Module="Core" Type="1">VGhvdXNhbmRzIFNlcGFyYXRvcg==</PHRASE>
@@ -631,12 +644,15 @@
<PHRASE Label="la_Hide" Module="Core" Type="1">SGlkZQ==</PHRASE>
<PHRASE Label="la_hint_AllFiles" Module="Core" Type="1">QWxsIEZpbGVz</PHRASE>
<PHRASE Label="la_hint_CSVFiles" Module="Core" Type="1">Q1NWIEZpbGVz</PHRASE>
+ <PHRASE Label="la_hint_DomainIPRange" Module="Core" Type="1">U2luZ2xlIElQIG9yIHJhbmdlIHJlY29yZCBwZXIgbGluZSAoZm9ybWF0czogMS4yLjMuNCBvciAxLjIuMyBvciAxLjIuMy4zMi0xLjIuMy41NCBvciAxLjIuMy4zMi8yNyBvciAxLjIuMy4zMi8yNTUuMjU1LjI1NS4yMjQp</PHRASE>
<PHRASE Label="la_hint_ExportEmailEvents" Module="Core" Type="1">U2luZ2xlIEVtYWlsIEV2ZW50IHBlciBsaW5lIChmb3JtYXRzOiBVU0VSLkFERCwgT1JERVIuU1VCTUlUKQ==</PHRASE>
<PHRASE Label="la_hint_ExportPhrases" Module="Core" Type="1">U2luZ2xlIFBocmFzZSBMYWJlbCBwZXIgbGluZSAoZm9ybWF0czogbGFfU2FtcGxlTGFiZWwsIGx1X0Zyb250RW5kTGFiZWwp</PHRASE>
<PHRASE Label="la_hint_ForceModRewriteUrlEnding" Module="Core" Type="1">VXNlciB3aWxsIGJlIGF1dG9tYXRpY2FsbHkgcmVkaXJlY3RlZCB0byB0aGUgc2VsZWN0ZWQgVXJsIEVuZGluZyBpbiBjYXNlIHdoZW4gY3VycmVudCBwYWdlIHVybCBoYXMgYSBkaWZmZXJlbnQgZW5kaW5n</PHRASE>
<PHRASE Label="la_hint_ImageFiles" Module="Core" Type="1">SW1hZ2UgRmlsZXM=</PHRASE>
<PHRASE Label="la_hint_PopPort" Module="Core" Type="1">UE9QMyBTZXJ2ZXIgUG9ydC4gRm9yIGV4LiAiMTEwIiBmb3IgcmVndWxhciBjb25uZWN0aW9uLCAiOTk1IiBmb3Igc2VjdXJlIGNvbm5lY3Rpb24u</PHRASE>
<PHRASE Label="la_hint_PopServer" Module="Core" Type="1">UE9QMyBTZXJ2ZXIgQWRkcmVzcy4gRm9yIGV4LiB1c2UgInNzbDovL3BvcC5nbWFpbC5jb20iIGZvciBHbWFpbCwgInBvcC5tYWlsLnlhaG9vLmNvbSIgZm9yIFlhaG9vLg==</PHRASE>
+ <PHRASE Label="la_hint_SSLUrl" Module="Core" Type="1">aHR0cHM6Ly93d3cuZG9tYWluLmNvbS9wYXRo</PHRASE>
+ <PHRASE Label="la_hint_UsingRegularExpression" Module="Core" Type="1">VXNpbmcgUmVndWxhciBFeHByZXNzaW9u</PHRASE>
<PHRASE Label="la_Hot" Module="Core" Type="1">SG90</PHRASE>
<PHRASE Label="la_Html" Module="Core" Type="1">SFRNTA==</PHRASE>
<PHRASE Label="la_IDField" Module="Core" Type="1">SUQgRmllbGQ=</PHRASE>
@@ -710,6 +726,7 @@
<PHRASE Label="la_opt_CommentText" Module="Core" Type="1">Q29tbWVudCBUZXh0</PHRASE>
<PHRASE Label="la_opt_Country" Module="Core" Type="1">Q291bnRyeQ==</PHRASE>
<PHRASE Label="la_opt_CreatedOn" Module="Core" Type="1">Q3JlYXRlZCBPbg==</PHRASE>
+ <PHRASE Label="la_opt_CurrentDomain" Module="Core" Type="1">Q3VycmVudCBEb21haW4=</PHRASE>
<PHRASE Label="la_opt_day" Module="Core" Type="1">ZGF5KHMp</PHRASE>
<PHRASE Label="la_opt_Deny" Module="Core" Type="1">RGVueQ==</PHRASE>
<PHRASE Label="la_opt_Description" Module="Core" Type="1">RGVzY3JpcHRpb24=</PHRASE>
@@ -721,6 +738,7 @@
<PHRASE Label="la_opt_Everyone" Module="Core" Type="1">RXZlcnlvbmU=</PHRASE>
<PHRASE Label="la_opt_Exact" Module="Core" Type="1">RXhhY3Q=</PHRASE>
<PHRASE Label="la_opt_Expired" Module="Core" Type="1">RXhwaXJlZA==</PHRASE>
+ <PHRASE Label="la_opt_ExternalUrl" Module="Core" Type="1">RXh0ZXJuYWwgVXJs</PHRASE>
<PHRASE Label="la_opt_Failed" Module="Core" Type="1">RmFpbGVk</PHRASE>
<PHRASE Label="la_opt_FirstName" Module="Core" Type="1">Rmlyc3QgTmFtZQ==</PHRASE>
<PHRASE Label="la_opt_GuestsOnly" Module="Core" Type="1">R3Vlc3RzIE9ubHk=</PHRASE>
@@ -954,6 +972,7 @@
<PHRASE Label="la_section_UsersSearch" Module="Core" Type="1">U2VhcmNoIFVzZXJz</PHRASE>
<PHRASE Label="la_section_Values" Module="Core" Type="1">VmFsdWVz</PHRASE>
<PHRASE Label="la_SelectColumns" Module="Core" Type="1">U2VsZWN0IENvbHVtbnM=</PHRASE>
+ <PHRASE Label="la_SelectedItems" Module="Core" Type="1">U2VsZWN0ZWQgSXRlbXM=</PHRASE>
<PHRASE Label="la_selecting_categories" Module="Core" Type="1">U2VsZWN0aW5nIFNlY3Rpb25z</PHRASE>
<PHRASE Label="la_SeparatedCategoryPath" Module="Core" Type="1">T25lIGZpZWxkIGZvciBlYWNoIHNlY3Rpb24gbGV2ZWw=</PHRASE>
<PHRASE Label="la_ShortToolTip_Clone" Module="Core" Type="1">Q2xvbmU=</PHRASE>
@@ -1116,6 +1135,7 @@
<PHRASE Label="la_title_addingCustom" Module="Core" Type="1">QWRkaW5nIEN1c3RvbSBGaWVsZA==</PHRASE>
<PHRASE Label="la_title_AddingFile" Module="Core" Type="1">QWRkaW5nIEZpbGU=</PHRASE>
<PHRASE Label="la_title_AddingMailingList" Module="Core" Type="1">QWRkaW5nIE1haWxpbmcgTGlzdA==</PHRASE>
+ <PHRASE Label="la_title_AddingSiteDomain" Module="Core" Type="1">QWRkaW5nIFNpdGUgRG9tYWlu</PHRASE>
<PHRASE Label="la_title_AddingSkin" Module="Core" Type="1">QWRkaW5nIFNraW4=</PHRASE>
<PHRASE Label="la_title_AddingSpellingDictionary" Module="Core" Type="1">QWRkaW5nIFNwZWxsaW5nIERpY3Rpb25hcnk=</PHRASE>
<PHRASE Label="la_title_AddingStopWord" Module="Core" Type="1">QWRkaW5nIFN0b3AgV29yZA==</PHRASE>
@@ -1163,6 +1183,7 @@
<PHRASE Label="la_title_EditingEmailEvent" Module="Core" Type="1">RWRpdGluZyBFbWFpbCBFdmVudA==</PHRASE>
<PHRASE Label="la_title_EditingFile" Module="Core" Type="1">RWRpdGluZyBGaWxl</PHRASE>
<PHRASE Label="la_title_EditingMembership" Module="Core" Type="1">RWRpdGluZyBNZW1iZXJzaGlw</PHRASE>
+ <PHRASE Label="la_title_EditingSiteDomain" Module="Core" Type="1">RWRpdGluZyBTaXRlIERvbWFpbg==</PHRASE>
<PHRASE Label="la_title_EditingSkin" Module="Core" Type="1">RWRpdGluZyBTa2lu</PHRASE>
<PHRASE Label="la_title_EditingSpellingDictionary" Module="Core" Type="1">RWRpdGluZyBTcGVsbGluZyBEaWN0aW9uYXJ5</PHRASE>
<PHRASE Label="la_title_EditingStopWord" Module="Core" Type="1">RWRpdGluZyBTdG9wIFdvcmQ=</PHRASE>
@@ -1239,6 +1260,7 @@
<PHRASE Label="LA_TITLE_SENDEMAIL" Module="Core" Type="1">U2VuZCBFLW1haWw=</PHRASE>
<PHRASE Label="LA_TITLE_SENDINGPREPAREDEMAILS" Module="Core" Type="1">U2VuZGluZyBQcmVwYXJlZCBFLW1haWxz</PHRASE>
<PHRASE Label="la_Title_SendMailComplete" Module="Core" Type="1">TWFpbCBoYXMgYmVlbiBzZW50IFN1Y2Nlc3NmdWxseQ==</PHRASE>
+ <PHRASE Label="la_title_SiteDomains" Module="Core" Type="1">U2l0ZSBEb21haW5z</PHRASE>
<PHRASE Label="la_title_SpellingDictionary" Module="Core" Type="1">U3BlbGxpbmcgRGljdGlvbmFyeQ==</PHRASE>
<PHRASE Label="la_title_StopWords" Module="Core" Type="1">U3RvcCBXb3Jkcw==</PHRASE>
<PHRASE Label="la_title_Structure" Module="Core" Type="1">U3RydWN0dXJlICYgRGF0YQ==</PHRASE>
@@ -1296,6 +1318,7 @@
<PHRASE Label="la_ToolTip_NewPhrase" Module="Core" Type="1">TmV3IFBocmFzZQ==</PHRASE>
<PHRASE Label="la_ToolTip_NewReview" Module="Core" Type="1">TmV3IENvbW1lbnQ=</PHRASE>
<PHRASE Label="la_ToolTip_NewSearchConfig" Module="Core" Type="1">TmV3IFNlYXJjaCBGaWVsZA==</PHRASE>
+ <PHRASE Label="la_ToolTip_NewSiteDomain" Module="Core" Type="1">TmV3IFNpdGUgRG9tYWlu</PHRASE>
<PHRASE Label="la_ToolTip_NewStopWord" Module="Core" Type="1">TmV3IFN0b3AgV29yZA==</PHRASE>
<PHRASE Label="la_ToolTip_newstylesheet" Module="Core" Type="1">TmV3IFN0eWxlc2hlZXQ=</PHRASE>
<PHRASE Label="la_ToolTip_NewTerm" Module="Core" Type="1">TmV3IFRlcm0=</PHRASE>
Index: install/install_schema.sql
===================================================================
--- install/install_schema.sql (revision 13470)
+++ install/install_schema.sql (working copy)
@@ -1183,6 +1183,7 @@
CREATE TABLE CachedUrls (
UrlId int(11) NOT NULL AUTO_INCREMENT,
Url varchar(255) NOT NULL DEFAULT '',
+ DomainId int(11) NOT NULL DEFAULT '0',
`Hash` int(11) NOT NULL DEFAULT '0',
Prefixes varchar(255) NOT NULL DEFAULT '',
ParsedVars text NOT NULL,
@@ -1193,5 +1194,38 @@
KEY `Hash` (`Hash`),
KEY Prefixes (Prefixes),
KEY Cached (Cached),
- KEY LifeTime (LifeTime)
+ KEY LifeTime (LifeTime),
+ KEY DomainId (DomainId)
+);
+
+CREATE TABLE SiteDomains (
+ DomainId int(11) NOT NULL AUTO_INCREMENT,
+ DomainName varchar(255) NOT NULL DEFAULT '',
+ DomainNameUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ SSLUrl varchar(255) NOT NULL DEFAULT '',
+ SSLUrlUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ AdminEmail varchar(255) NOT NULL DEFAULT '',
+ Country varchar(3) NOT NULL DEFAULT '',
+ PrimaryLanguageId int(11) NOT NULL DEFAULT '0',
+ Languages varchar(255) NOT NULL DEFAULT '',
+ PrimaryThemeId int(11) NOT NULL DEFAULT '0',
+ Themes varchar(255) NOT NULL DEFAULT '',
+ DomainIPRange text,
+ ExternalUrl varchar(255) NOT NULL DEFAULT '',
+ RedirectOnIPMatch tinyint(4) NOT NULL DEFAULT '0',
+ Priority int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (DomainId),
+ KEY DomainName (DomainName),
+ KEY DomainNameUsesRegExp (DomainNameUsesRegExp),
+ KEY SSLUrl (SSLUrl),
+ KEY SSLUrlUsesRegExp (SSLUrlUsesRegExp),
+ KEY AdminEmail (AdminEmail),
+ KEY Country (Country),
+ KEY PrimaryLanguageId (PrimaryLanguageId),
+ KEY Languages (Languages),
+ KEY PrimaryThemeId (PrimaryThemeId),
+ KEY Themes (Themes),
+ KEY ExternalUrl (ExternalUrl),
+ KEY RedirectOnIPMatch (RedirectOnIPMatch),
+ KEY Priority (Priority)
);
\ No newline at end of file
Index: install/remove_schema.sql
===================================================================
--- install/remove_schema.sql (revision 13470)
+++ install/remove_schema.sql (working copy)
@@ -70,3 +70,4 @@
DROP TABLE Forms;
DROP TABLE Semaphores;
DROP TABLE CachedUrls;
+DROP TABLE SiteDomains;
Index: install/upgrades.sql
===================================================================
--- install/upgrades.sql (revision 13476)
+++ install/upgrades.sql (working copy)
@@ -1670,6 +1670,7 @@
CREATE TABLE CachedUrls (
UrlId int(11) NOT NULL AUTO_INCREMENT,
Url varchar(255) NOT NULL DEFAULT '',
+ DomainId int(11) NOT NULL DEFAULT '0',
`Hash` int(11) NOT NULL DEFAULT '0',
Prefixes varchar(255) NOT NULL DEFAULT '',
ParsedVars text NOT NULL,
@@ -1680,7 +1681,8 @@
KEY `Hash` (`Hash`),
KEY Prefixes (Prefixes),
KEY Cached (Cached),
- KEY LifeTime (LifeTime)
+ KEY LifeTime (LifeTime),
+ KEY DomainId (DomainId)
);
INSERT INTO ConfigurationAdmin VALUES ('CacheHandler', 'la_section_SettingsCaching', 'la_config_CacheHandler', 'select', NULL, 'Fake=la_None,Memcache=+Memcached,Apc=+Alternative PHP Cache,XCache=+XCache', 80.02, 0, 0);
@@ -1810,3 +1812,35 @@
UPDATE Phrase
SET l<%PRIMARY_LANGUAGE%>_Translation = 'Enable SEO-friendly URLs mode (MOD-REWRITE)'
WHERE Phrase = 'la_config_use_modrewrite' AND l<%PRIMARY_LANGUAGE%>_Translation = 'Use MOD REWRITE';
+
+CREATE TABLE SiteDomains (
+ DomainId int(11) NOT NULL AUTO_INCREMENT,
+ DomainName varchar(255) NOT NULL DEFAULT '',
+ DomainNameUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ SSLUrl varchar(255) NOT NULL DEFAULT '',
+ SSLUrlUsesRegExp tinyint(4) NOT NULL DEFAULT '0',
+ AdminEmail varchar(255) NOT NULL DEFAULT '',
+ Country varchar(3) NOT NULL DEFAULT '',
+ PrimaryLanguageId int(11) NOT NULL DEFAULT '0',
+ Languages varchar(255) NOT NULL DEFAULT '',
+ PrimaryThemeId int(11) NOT NULL DEFAULT '0',
+ Themes varchar(255) NOT NULL DEFAULT '',
+ DomainIPRange text,
+ ExternalUrl varchar(255) NOT NULL DEFAULT '',
+ RedirectOnIPMatch tinyint(4) NOT NULL DEFAULT '0',
+ Priority int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (DomainId),
+ KEY DomainName (DomainName),
+ KEY DomainNameUsesRegExp (DomainNameUsesRegExp),
+ KEY SSLUrl (SSLUrl),
+ KEY SSLUrlUsesRegExp (SSLUrlUsesRegExp),
+ KEY AdminEmail (AdminEmail),
+ KEY Country (Country),
+ KEY PrimaryLanguageId (PrimaryLanguageId),
+ KEY Languages (Languages),
+ KEY PrimaryThemeId (PrimaryThemeId),
+ KEY Themes (Themes),
+ KEY ExternalUrl (ExternalUrl),
+ KEY RedirectOnIPMatch (RedirectOnIPMatch),
+ KEY Priority (Priority)
+);
Index: kernel/application.php
===================================================================
--- kernel/application.php (revision 13488)
+++ kernel/application.php (working copy)
@@ -220,6 +220,13 @@
*/
var $isAdmin = false;
+ /**
+ * Instance of site domain object
+ *
+ * @var kDBItem
+ */
+ var $siteDomain = null;
+
/**
* Returns kApplication instance anywhere in the script.
*
@@ -599,30 +606,63 @@
return $theme_id;
}
+ /**
+ * Returns site primary currency ISO code
+ *
+ * @return string
+ */
function GetPrimaryCurrency()
{
- $cache_key = 'primary_currency[%CurrSerial%]';
- $primary_currency = $this->getCache($cache_key);
+ $cache_key = 'primary_currency[%CurrSerial%][%SiteDomainSerial%]:' . $this->siteDomainField('DomainId');
+ $currency_iso = $this->getCache($cache_key);
- if ($primary_currency === false) {
+ if ($currency_iso === false) {
if ($this->isModuleEnabled('In-Commerce')) {
$this->Conn->nextQueryCachable = true;
+ $currency_id = $this->siteDomainField('PrimaryCurrencyId');
+
$sql = 'SELECT ISO
FROM ' . $this->getUnitOption('curr', 'TableName') . '
- WHERE IsPrimary = 1';
- $primary_currency = $this->Conn->GetOne($sql);
+ WHERE ' . ($currency_id > 0 ? 'CurrencyId = ' . $currency_id : 'IsPrimary = 1');
+ $currency_iso = $this->Conn->GetOne($sql);
}
else {
- $primary_currency = 'USD';
+ $currency_iso = 'USD';
}
- $this->setCache($cache_key, $primary_currency);
+ $this->setCache($cache_key, $currency_iso);
}
- return $primary_currency;
+ return $currency_iso;
}
/**
+ * Returns site domain field. When none of site domains are found false is returned.
+ *
+ * @param string $field
+ * @param bool $formatted
+ * @param string $format
+ */
+ function siteDomainField($field, $formatted = false, $format = null)
+ {
+ if ($this->isAdmin) {
+ // don't apply any filtering in administrative console
+ return false;
+ }
+
+ if (!$this->siteDomain) {
+ $this->siteDomain =& $this->recallObject('site-domain.current');
+ /* @var $site_domain kDBItem */
+ }
+
+ if ($this->siteDomain->isLoaded()) {
+ return $formatted ? $this->siteDomain->GetField($field, $format) : $this->siteDomain->GetDBField($field);
+ }
+
+ return false;
+ }
+
+ /**
* Registers default classes such as ItemController, GridController and LoginController
*
* Called automatically while initializing Application
@@ -1530,21 +1570,16 @@
$ssl = isset($params['__SSL__']) ? $params['__SSL__'] : null;
if ($ssl !== null) {
$session =& $this->recallObject('Session');
- $cookie_url = trim($session->CookieDomain.$session->CookiePath, '/.');
- if ($ssl) {
- $target_url = defined('ADMIN') && ADMIN ? $this->ConfigValue('AdminSSL_URL') : false;
- if (!$target_url) {
- $target_url = $this->ConfigValue('SSL_URL');
- }
- }
- else {
- $target_url = 'http://'.DOMAIN.$this->ConfigValue('Site_Path');
- }
+ /* @var $session Session */
+ $target_url = rtrim($this->BaseURL('', $ssl, false), '/');
+ $cookie_url = trim($session->CookieDomain . $session->CookiePath, '/.');
+
// set session to GET_ONLY, to pass sid only if sid is REAL AND session is set
- if (!preg_match('#'.preg_quote($cookie_url).'#', $target_url) && $session->SessionSet) {
- $session->SetMode(smGET_ONLY);
- }
+ if (!preg_match('#' . preg_quote($cookie_url) . '#', $target_url) && $session->SessionSet) {
+ // when SSL<->NON-SSL redirect to different domain pass SID in url
+ $session->SetMode(smGET_ONLY);
+ }
}
if (isset($params['opener']) && $params['opener'] == 'u') {
@@ -2023,27 +2058,36 @@
return $ret;
}
- function BaseURL($prefix='', $ssl=null)
+ function BaseURL($prefix = '', $ssl = null, $add_port = true)
{
if ($ssl === null) {
- return PROTOCOL.SERVER_NAME.(defined('PORT')?':'.PORT : '').rtrim(BASE_PATH, '/').$prefix.'/';
+ // stay on same encryption level
+ return PROTOCOL . SERVER_NAME . ($add_port && defined('PORT') ? ':' . PORT : '') . rtrim(BASE_PATH, '/') . $prefix . '/';
}
- else {
- if ($ssl) {
- $base_url = defined('ADMIN') && ADMIN ? $this->ConfigValue('AdminSSL_URL') : false;
- if (!$base_url) {
- $base_url = $this->ConfigValue('SSL_URL');
- }
- return rtrim($base_url, '/').$prefix.'/';
+ if ($ssl) {
+ // going from http:// to https://
+ $base_url = $this->isAdmin ? $this->ConfigValue('AdminSSL_URL') : false;
+
+ if (!$base_url) {
+ $ssl_url = $this->siteDomainField('SSLUrl');
+ $base_url = $ssl_url !== false ? $ssl_url : $this->ConfigValue('SSL_URL');
}
- else {
- return 'http://'.DOMAIN.(defined('PORT')?':'.PORT : '').rtrim( $this->ConfigValue('Site_Path'), '/').$prefix.'/';
- }
+
+ return rtrim($base_url, '/') . $prefix . '/';
}
+
+ // going from https:// to http://
+ $domain = $this->siteDomainField('DomainName');
+
+ if ($domain === false) {
+ $domain = DOMAIN;
+ }
+
+ return 'http://' . $domain . ($add_port && defined('PORT') ? ':' . PORT : '') . rtrim($this->ConfigValue('Site_Path'), '/') . $prefix . '/';
}
- function Redirect($t='', $params=null, $prefix='', $index_file=null)
+ function Redirect($t = '', $params = Array(), $prefix = '', $index_file = null)
{
$js_redirect = getArrayValue($params, 'js_redirect');
@@ -2273,6 +2317,14 @@
*/
function ConfigValue($name)
{
+ if ($name == 'Smtp_AdminMailFrom') {
+ $res = $this->siteDomainField('AdminEmail');
+
+ if ($res) {
+ return $res;
+ }
+ }
+
$res = array_key_exists($name, $this->ConfigHash) ? $this->ConfigHash[$name] : false;
if ($res !== false) {
return $res;
Index: kernel/constants.php
===================================================================
--- kernel/constants.php (revision 13471)
+++ kernel/constants.php (working copy)
@@ -162,4 +162,8 @@
define('SUBMISSION_LOG_ATTACHMENT_PATH', WRITEBALE_BASE . '/user_files/submission_log/');
- define('TIMENOW', adodb_mktime()); // for faster message processing
\ No newline at end of file
+ define('TIMENOW', adodb_mktime()); // for faster message processing
+
+ // site domains
+ define('SITE_DOMAIN_REDIRECT_CURRENT', 1);
+ define('SITE_DOMAIN_REDIRECT_EXTERNAL', 2);
\ No newline at end of file
Index: kernel/globals.php
===================================================================
--- kernel/globals.php (revision 13400)
+++ kernel/globals.php (working copy)
@@ -563,17 +563,26 @@
return $ip_match;
}
- function netMatch($network, $ip) {
+ function netMatch($network, $ip)
+ {
$network = trim($network);
$ip = trim($ip);
if ($network == $ip) {
- // comparing 2 ip addresses directly
+ // comparing two ip addresses directly
return true;
}
$d = strpos($network, '-');
- if ($d === false) {
+ if ($d !== false) {
+ // ip address range specified
+ $from = ip2long(trim(substr($network, 0, $d)));
+ $to = ip2long(trim(substr($network, $d + 1)));
+
+ $ip = ip2long($ip);
+ return ($ip >= $from && $ip <= $to);
+ }
+ elseif (strpos($network, '/') !== false) {
// sigle subnet specified
$ip_arr = explode('/', $network);
@@ -589,14 +598,8 @@
return ($ip_long & $mask) == ($network_long & $mask);
}
- else {
- // ip address range specified
- $from = ip2long(trim(substr($network, 0, $d)));
- $to = ip2long(trim(substr($network, $d + 1)));
- $ip = ip2long($ip);
- return ($ip >= $from && $ip <= $to);
- }
+ return false;
}
function request_headers()
Index: kernel/processors/main_processor.php
===================================================================
--- kernel/processors/main_processor.php (revision 13400)
+++ kernel/processors/main_processor.php (working copy)
@@ -833,10 +833,14 @@
if (!$ssl) {
// not in admin or admin ssl url is empty
- $ssl = $this->Application->ConfigValue('SSL_URL');
+ $ssl_url = $this->Application->siteDomainField('SSLUrl');
+ $ssl = $ssl_url !== false ? $ssl_url : $this->Application->ConfigValue('SSL_URL');
}
- if (!$ssl) return; //SSL URL is not set - no way to require SSL
+ if (!$ssl) {
+ // SSL URL is not set - no way to require SSL
+ return;
+ }
$require = false;
Index: units/admin/admin_tag_processor.php
===================================================================
--- units/admin/admin_tag_processor.php (revision 13401)
+++ units/admin/admin_tag_processor.php (working copy)
@@ -147,7 +147,6 @@
return '';
}
-
if (array_key_exists('parent', $params) && $params['parent']) {
do {
$section = $section_data['parent'];
@@ -175,13 +174,15 @@
break;
case 'label':
- $res = $section_data['label'];
- if ($section != 'in-portal:root') {
+ if ($section && ($section != 'in-portal:root')) {
// don't translate label for top section, because it's already translated
$no_editing = array_key_exists('no_editing', $params) ? $params['no_editing'] : false;
- $res = $this->Application->Phrase($res, !$no_editing);
+ $res = $this->Application->Phrase($section_data['label'], !$no_editing);
}
+ else {
+ $res = '';
+ }
break;
default:
Index: units/helpers/helpers_config.php
===================================================================
--- units/helpers/helpers_config.php (revision 13471)
+++ units/helpers/helpers_config.php (working copy)
@@ -65,5 +65,6 @@
Array ('pseudo' => 'POP3Helper', 'class' => 'POP3Helper', 'file' => 'pop3_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
Array ('pseudo' => 'MimeDecodeHelper', 'class' => 'MimeDecodeHelper', 'file' => 'mime_decode_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
Array ('pseudo' => 'UserHelper', 'class' => 'UserHelper', 'file' => 'user_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
+ Array ('pseudo' => 'SiteHelper', 'class' => 'SiteHelper', 'file' => 'site_helper.php', 'build_event' => '', 'require_classes' => 'kHelper'),
),
);
\ No newline at end of file
Index: units/helpers/mod_rewrite_helper.php
===================================================================
--- units/helpers/mod_rewrite_helper.php (revision 13473)
+++ units/helpers/mod_rewrite_helper.php (working copy)
@@ -44,7 +44,21 @@
*/
var $_templateAliases = null;
+ /**
+ * Domain-based primary language id
+ *
+ * @var int
+ */
+ var $primaryLanguageId = false;
+
/**
+ * Domain-based primary theme id
+ *
+ * @var int
+ */
+ var $primaryThemeId = false;
+
+ /**
* Possible url endings from ModRewriteUrlEnding configuration variable
*
* @var Array
@@ -61,6 +75,12 @@
parent::kHelper();
$this->HTTPQuery =& $this->Application->recallObject('HTTPQuery');
+
+ // domain based primary language
+ $this->primaryLanguageId = $this->Application->siteDomainField('PrimaryLanguageId');
+
+ // domain based primary theme
+ $this->primaryThemeId = $this->Application->siteDomainField('PrimaryThemeId');
}
function processRewriteURL()
@@ -129,7 +149,7 @@
$sql = 'SELECT *
FROM ' . TABLE_PREFIX . 'CachedUrls
- WHERE Hash = ' . crc32($url);
+ WHERE Hash = ' . crc32($url) . ' AND DomainId = ' . (int)$this->Application->siteDomainField('DomainId');
$data = $this->Conn->GetRow($sql);
if ($data) {
@@ -194,6 +214,7 @@
$fields_hash = Array (
'Url' => $url,
'Hash' => crc32($url),
+ 'DomainId' => (int)$this->Application->siteDomainField('DomainId'),
'Prefixes' => $prefixes ? '|' . implode('|', $prefixes) . '|' : '',
'ParsedVars' => serialize($data),
'Cached' => adodb_mktime(),
@@ -409,8 +430,12 @@
}
// add language
- $default_language_id = $this->Application->GetDefaultLanguageId();
- if ($processed_params['m_lang'] && ($processed_params['m_lang'] != $default_language_id)) {
+ if (!$this->primaryLanguageId) {
+ // when domain-based language not found -> use site-wide language
+ $this->primaryLanguageId = $this->Application->GetDefaultLanguageId();
+ }
+
+ if ($processed_params['m_lang'] && ($processed_params['m_lang'] != $this->primaryLanguageId)) {
$language_name = $this->Application->getCache('language_names[%LangIDSerial:' . $processed_params['m_lang'] . '%]');
if ($language_name === false) {
$sql = 'SELECT PackName
@@ -425,8 +450,12 @@
}
// add theme
- $default_theme_id = $this->Application->GetDefaultThemeId(true);
- if ($processed_params['m_theme'] && ($processed_params['m_theme'] != $default_theme_id)) {
+ if (!$this->primaryThemeId) {
+ // when domain-based theme not found -> use site-wide theme
+ $this->primaryThemeId = $this->Application->GetDefaultThemeId(true);
+ }
+
+ if ($processed_params['m_theme'] && ($processed_params['m_theme'] != $this->primaryThemeId)) {
$theme_name = $this->Application->getCache('theme_names[%ThemeIDSerial:' . $processed_params['m_theme'] . '%]');
if ($theme_name === false) {
$sql = 'SELECT Name
@@ -533,6 +562,10 @@
// language was found by pack name
array_shift($url_parts);
}
+ elseif ($this->primaryLanguageId) {
+ // use domain-based primary language instead of site-wide primary language
+ $vars['m_lang'] = $this->primaryLanguageId;
+ }
return true;
}
@@ -577,6 +610,10 @@
// theme was found by name
array_shift($url_parts);
}
+ elseif ($this->primaryThemeId) {
+ // use domain-based primary theme instead of site-wide primary theme
+ $vars['m_theme'] = $this->primaryThemeId;
+ }
return true;
}
@@ -1076,17 +1113,31 @@
}
/**
- * Sets default parsed values before actual url parsing
+ * Sets default parsed values before actual url parsing (only, for empty url)
*
* @param Array $vars
*/
function _setDefaultValues(&$vars)
{
- $defaults = Array ('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's', 't' => 'index');
+ $defaults = Array (
+ 'm_cat_id' => 0, // no category
+ 'm_cat_page' => 1, // first category page
+ 'm_opener' => 's', // stay on same page
+ 't' => 'index' // main site page
+ );
+ if ($this->primaryLanguageId) {
+ // domain-based primary language
+ $defaults['m_lang'] = $this->primaryLanguageId;
+ }
+
+ if ($this->primaryThemeId) {
+ // domain-based primary theme
+ $defaults['m_theme'] = $this->primaryThemeId;
+ }
+
foreach ($defaults as $default_key => $default_value) {
- // bug: null is never returned
- if ($this->HTTPQuery->Get($default_key) == null) {
+ if ($this->HTTPQuery->Get($default_key) === false) {
$vars[$default_key] = $default_value;
}
}
Index: units/helpers/site_helper.php
===================================================================
--- units/helpers/site_helper.php (revision 0)
+++ units/helpers/site_helper.php (revision 0)
@@ -0,0 +1,44 @@
+<?php
+
+ class SiteHelper extends kHelper {
+
+ /**
+ * Returns default country
+ *
+ * @return string
+ */
+ function getDefaultCountry($country_prefix = '', $iso_format = true)
+ {
+ $country = $this->Application->siteDomainField($country_prefix . 'Country');
+
+ if ($iso_format && !$country) {
+ $country = 'USA';
+ }
+
+ if (!$iso_format && strlen($country)) {
+ return $this->getCountryId($country);
+ }
+
+ return $country;
+ }
+
+ /**
+ * Returns country id based on it's ISO code
+ *
+ * @param string $iso_code
+ * @return int
+ */
+ function getCountryId($iso_code)
+ {
+ static $cache = null;
+
+ if (!isset($cache)) {
+ $sql = 'SELECT CountryStateId, IsoCode
+ FROM ' . $this->Application->getUnitOption('country-state', 'TableName') . '
+ WHERE Type = ' . DESTINATION_TYPE_COUNTRY;
+ $cache = $this->Conn->GetCol($sql, 'IsoCode');
+ }
+
+ return $cache[$iso_code];
+ }
+ }
Index: units/languages/languages_event_handler.php
===================================================================
--- units/languages/languages_event_handler.php (revision 13453)
+++ units/languages/languages_event_handler.php (working copy)
@@ -174,12 +174,28 @@
*/
function SetCustomQuery(&$event)
{
- if ($event->Special == 'enabled') {
- $object =& $event->getObject();
- /* @var $object kDBList */
+ $object =& $event->getObject();
+ /* @var $object kDBList */
- $object->addFilter('enabled_filter', '%1$s.Enabled = 1');
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available'))) {
+ $object->addFilter('enabled_filter', '%1$s.Enabled = ' . STATUS_ACTIVE);
}
+
+ // site domain language picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'Languages');
+ }
+
+ // apply domain-based language filtering
+ $languages = $this->Application->siteDomainField('Languages');
+
+ if (strlen($languages)) {
+ $languages = explode('|', substr($languages, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.LanguageId IN (' . implode(',', $languages) . ')');
+ }
}
/**
Index: units/languages/languages_item.php
===================================================================
--- units/languages/languages_item.php (revision 13400)
+++ units/languages/languages_item.php (working copy)
@@ -60,13 +60,30 @@
{
$default = false;
if ($id == 'default') {
- $id = 1;
- $id_field_name = 'PrimaryLang';
+ // domain based primary language
+ $id = $this->Application->siteDomainField('PrimaryLanguageId');
+
+ if (!$id) {
+ $id = 1;
+ $id_field_name = 'PrimaryLang';
+ }
+
$default = true;
}
$res = parent::Load($id, $id_field_name, true);
+ if ($res) {
+ $available_languages = $this->Application->siteDomainField('Languages');
+
+ if ($available_languages) {
+ if (strpos($available_languages, '|' . $this->GetID() . '|') === false) {
+ // language isn't allowed in site domain
+ return $this->Clear();
+ }
+ }
+ }
+
if ($default) {
if (!$res) {
if ($this->Application->isAdmin) {
Index: units/site_domains/site_domain_eh.php
===================================================================
--- units/site_domains/site_domain_eh.php (revision 0)
+++ units/site_domains/site_domain_eh.php (revision 0)
@@ -0,0 +1,319 @@
+<?php
+
+ class SiteDomainEventHandler extends kDBEventHandler {
+
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+
+ $permissions = Array (
+ 'OnItemBuild' => Array ('self' => true),
+ );
+
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Returns ID of site domain, that matches current url
+ *
+ * @param kEvent $event
+ */
+ function getPassedID(&$event)
+ {
+ if ($event->Special == 'current') {
+ if ($this->Application->isAdmin) {
+ $event->setEventParam('raise_warnings', 0);
+ }
+ else {
+ if (PROTOCOL == 'https://') {
+ return $this->querySiteDomain('SSLUrl', rtrim($this->Application->BaseURL(), '/'));
+ }
+
+ return $this->querySiteDomain('DomainName', $_SERVER['HTTP_HOST']);
+ }
+ }
+
+ return parent::getPassedID($event);
+ }
+
+ function querySiteDomain($field, $value)
+ {
+ $site_domains = $this->getSiteDomains();
+
+ $domain_by_name = $this->getDomainByName($field, $value);
+ $domain_by_ip = $this->getDomainByIP();
+
+ if ($domain_by_ip) {
+ $site_domain = $site_domains[$domain_by_ip];
+ $redirect_mode = $site_domain['RedirectOnIPMatch'];
+
+ if (($redirect_mode == SITE_DOMAIN_REDIRECT_EXTERNAL) && ($domain_by_ip == $domain_by_name)) {
+ // redirect to external url (when visiting protected domain)
+ $external_url = $site_domain['ExternalUrl'];
+
+ if (preg_match('/^http[s]{0,1}:\/\//', $external_url)) {
+ $this->Application->Redirect('external:' . $external_url);
+ }
+ else {
+ $this->Application->Redirect('external:' . PROTOCOL . $external_url . $_SERVER['REQUEST_URI']);
+ }
+ }
+ elseif (($redirect_mode == SITE_DOMAIN_REDIRECT_CURRENT) && ($domain_by_ip != $domain_by_name)) {
+ // redirect to a domain detected by IP (when not already on it)
+ if ((PROTOCOL == 'https://') && !$site_domain['SSLUrlUsesRegExp'] && $site_domain['SSLUrl']) {
+ // need to remove sub folder from ssl url
+ $ssl_url = preg_replace('/^(https:\/\/[^\/]*)(\/.*){0,1}$/', '\\1', $site_domain['SSLUrl']);
+ $this->Application->Redirect('external:' . $ssl_url . $_SERVER['REQUEST_URI']);
+ }
+ elseif ((PROTOCOL == 'http://') && !$site_domain['DomainNameUsesRegExp']) {
+ $this->Application->Redirect('external:http://' . $site_domain['DomainName'] . $_SERVER['REQUEST_URI']);
+ }
+ }
+
+ return $domain_by_ip;
+ }
+
+ return $domain_by_name;
+ }
+
+ /**
+ * Try to match visited domain to any of existing
+ *
+ * @param string $field
+ * @param string $value
+ * @return int
+ */
+ function getDomainByName($field, $value)
+ {
+ $site_domains = $this->getSiteDomains();
+ $name_fields = Array ('DomainName', 'SSLUrl');
+
+ foreach ($site_domains as $id => $site_domain) {
+ if (in_array($field, $name_fields) && $site_domain[$field . 'UsesRegExp']) {
+ if (preg_match('/^' . $site_domain[$field] . '$/', $value)) {
+ return $id;
+ }
+ }
+ elseif ($site_domain[$field] == $value) {
+ return $id;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Try to match domain settings based on visitor's IP address
+ *
+ * @return int
+ */
+ function getDomainByIP()
+ {
+ $site_domains = $this->getSiteDomains();
+
+ foreach ($site_domains as $id => $site_domain) {
+ if (ipMatch($site_domain['DomainIPRange'], "\n")) {
+ return $id;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Load item if id is available
+ *
+ * @param kEvent $event
+ */
+ function LoadItem(&$event)
+ {
+ if ($this->Application->isAdmin) {
+ // don't load domain data from cache
+ parent::LoadItem($event);
+
+ return ;
+ }
+
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $id = (int)$this->getPassedID($event);
+
+ if ($object->isLoaded() && ($object->GetID() == $id)) {
+ // object is already loaded by same id
+ return ;
+ }
+
+ $site_domains = $this->getSiteDomains();
+ $domain_data = array_key_exists($id, $site_domains) ? $site_domains[$id] : false;
+
+ if ($object->LoadFromHash($domain_data)) {
+ $actions =& $this->Application->recallObject('kActions');
+ $actions->Set($event->Prefix_Special.'_id', $object->GetID() );
+ }
+ else {
+ $object->setID($id);
+ }
+ }
+
+ function getSiteDomains()
+ {
+ static $cache = null;
+
+ if (!isset($cache)) {
+ if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
+ $cache = $this->Application->getCache('master:domains_parsed', false);
+ }
+ else {
+ $cache = $this->Application->getDBCache('domains_parsed');
+ }
+
+ if ($cache) {
+ $cache = unserialize($cache);
+ }
+ else {
+ $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+
+ $sql = 'SELECT *
+ FROM ' . $table_name . '
+ ORDER BY Priority DESC';
+ $cache = $this->Conn->Query($sql, $id_field);
+
+ if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
+ $this->Application->setCache('master:domains_parsed', serialize($cache));
+ }
+ else {
+ $this->Application->setDBCache('domains_parsed', serialize($cache));
+ }
+ }
+ }
+
+ return $cache;
+ }
+
+ /**
+ * Removes In-Commerce related fields, when it's not installed
+ *
+ * @param kEvent $event
+ */
+ function OnAfterConfigRead(&$event)
+ {
+ parent::OnAfterConfigRead($event);
+
+ if (!$this->Application->isModuleEnabled('In-Commerce')) {
+ $remove_fields = Array (
+ 'BillingCountry', 'ShippingCountry',
+ 'PrimaryCurrencyId', 'Currencies',
+ 'PrimaryPaymentTypeId', 'PaymentTypes'
+ );
+
+ // remove field definitions
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+
+ foreach ($remove_fields as $remove_field) {
+ unset($fields[$remove_field]);
+ }
+
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+
+ // remove grid columns
+ $grids = $this->Application->getUnitOption($event->Prefix, 'Grids');
+
+ foreach ($grids as $grid_name => $grid_info) {
+ foreach ($remove_fields as $remove_field) {
+ if (array_key_exists($remove_field, $grid_info['Fields'])) {
+ unset($grids[$grid_name]['Fields'][$remove_field]);
+ }
+ }
+ }
+
+ $this->Application->setUnitOption($event->Prefix, 'Grids', $grids);
+ }
+ }
+
+ /**
+ * Delete cached information about site domains
+ *
+ * @param kEvent $event
+ */
+ function OnSave(&$event)
+ {
+ parent::OnSave($event);
+
+ if ($event->status == erSUCCESS) {
+ $this->_deleteCache();
+ }
+ }
+
+ /**
+ * Deletes cached information about site domains
+ */
+ function _deleteCache()
+ {
+ if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
+ $this->Application->deleteCache('master:domains_parsed');
+ }
+ else {
+ $this->Application->deleteDBCache('domains_parsed');
+ }
+
+ $sql = 'DELETE FROM ' . TABLE_PREFIX . 'CachedUrls';
+ $this->Conn->Query($sql);
+ }
+
+ /**
+ * Set's required fields based on redirect mode
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemLoad(&$event)
+ {
+ parent::OnAfterItemLoad($event);
+
+ $this->_setRequired($event);
+ }
+
+ /**
+ * Set's required fields based on redirect mode
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeItemCreate(&$event)
+ {
+ parent::OnBeforeItemCreate($event);
+
+ $this->_setRequired($event);
+ }
+
+ /**
+ * Set's required fields based on redirect mode
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeItemUpdate(&$event)
+ {
+ parent::OnBeforeItemUpdate($event);
+
+ $this->_setRequired($event);
+ }
+
+ /**
+ * Set's required fields
+ *
+ * @param kEvent $event
+ */
+ function _setRequired(&$event)
+ {
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $redirect_mode = $object->GetDBField('RedirectOnIPMatch');
+ $object->setRequired('ExternalUrl', $redirect_mode == SITE_DOMAIN_REDIRECT_EXTERNAL);
+ $object->setRequired('DomainIPRange', $redirect_mode > 0);
+ }
+ }
Index: units/site_domains/site_domains_config.php
===================================================================
--- units/site_domains/site_domains_config.php (revision 0)
+++ units/site_domains/site_domains_config.php (revision 0)
@@ -0,0 +1,140 @@
+<?php
+ $config = Array (
+ 'Prefix' => 'site-domain',
+ 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
+ 'EventHandlerClass' => Array ('class' => 'SiteDomainEventHandler', 'file' => 'site_domain_eh.php', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+
+ 'AutoLoad' => true,
+
+ 'QueryString' => Array (
+ 1 => 'id',
+ 2 => 'Page',
+ 3 => 'event',
+ 4 => 'mode',
+ ),
+
+ 'IDField' => 'DomainId',
+
+ 'TableName' => TABLE_PREFIX . 'SiteDomains',
+
+ 'TitleField' => 'DomainName',
+
+ 'TitlePresets' => Array (
+ 'default' => Array (
+ 'new_status_labels' => Array ('site-domain' => '!la_title_AddingSiteDomain!'),
+ 'edit_status_labels' => Array ('site-domain' => '!la_title_EditingSiteDomain!'),
+ ),
+
+ 'site_domain_list' => Array (
+ 'prefixes' => Array ('site-domain_List'), 'format' => "!la_title_SiteDomains!",
+ 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'view', 'dbl-click'),
+ ),
+
+ 'site_domain_edit' => Array (
+ 'prefixes' => Array ('site-domain'), 'format' => "#site-domain_status# '#site-domain_titlefield#' - !la_title_General!",
+ 'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
+ ),
+ ),
+
+ 'EditTabPresets' => Array (
+ 'Default' => Array (
+ 'general' => Array ('title' => 'la_tab_General', 't' => 'site_domains/site_domain_edit', 'priority' => 1),
+ ),
+ ),
+
+ 'PermSection' => Array('main' => 'in-portal:site_domains'),
+
+ 'Sections' => Array (
+ 'in-portal:site_domains' => Array (
+ 'parent' => 'in-portal:website_setting_folder',
+ 'icon' => 'site_domain',
+ 'label' => 'la_title_SiteDomains',
+ 'url' => Array('t' => 'site_domains/site_domain_list', 'pass' => 'm'),
+ 'permissions' => Array('view', 'add', 'edit', 'delete'),
+ 'priority' => 7,
+ 'type' => stTREE,
+ ),
+ ),
+
+ 'ListSQLs' => Array (
+ '' => ' SELECT %1$s.* %2$s FROM %1$s',
+ ),
+
+ 'ListSortings' => Array (
+ '' => Array (
+ 'Sorting' => Array ('Priority' => 'desc', 'DomainName' => 'asc'),
+ )
+ ),
+
+ 'Fields' => Array (
+ 'DomainId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'DomainName' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'required' => 1, 'default' => ''),
+ 'DomainNameUsesRegExp' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'SSLUrl' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
+ 'SSLUrlUsesRegExp' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'AdminEmail' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
+ 'Country' => Array (
+ 'type' => 'string', 'max_len' => 3,
+ 'formatter' => 'kOptionsFormatter',
+ 'options_sql' => ' SELECT IF(l%2$s_Name = "", l%3$s_Name, l%2$s_Name) AS Name, IsoCode
+ FROM ' . TABLE_PREFIX . 'CountryStates
+ WHERE Type = ' . DESTINATION_TYPE_COUNTRY . '
+ ORDER BY Name',
+ 'option_key_field' => 'IsoCode', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryLanguageId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language WHERE Enabled = 1 ORDER BY PackName ASC', 'option_key_field' => 'LanguageId', 'option_title_field' => 'PackName',
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Languages' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language WHERE Enabled = 1 ORDER BY PackName ASC', 'option_key_field' => 'LanguageId', 'option_title_field' => 'PackName',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryThemeId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Theme WHERE Enabled = 1 ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Themes' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Theme WHERE Enabled = 1 ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'DomainIPRange' => Array ('type' => 'string', 'default' => NULL),
+ 'ExternalUrl' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
+ 'RedirectOnIPMatch' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_Disabled', 1 => 'la_opt_CurrentDomain', 2 => 'la_opt_ExternalUrl'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Priority' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ ),
+
+ 'Grids' => Array (
+ 'Default' => Array (
+ 'Icons' => Array ('default' => 'icon16_item.png'),
+ 'Fields' => Array (
+ 'DomainId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
+ 'DomainName' => Array ('title' => 'la_col_DomainName', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
+ 'SSLUrl' => Array ('title' => 'la_col_SSLUrl', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
+ 'Country' => Array ('title' => 'la_col_Country', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryLanguageId' => Array ('title' => 'la_col_Language', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryThemeId' => Array ('title' => 'la_col_Theme', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'Priority' => Array ('title' => 'la_col_Priority', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
+ ),
+ ),
+ ),
+ );
Index: units/themes/theme_item.php
===================================================================
--- units/themes/theme_item.php (revision 13400)
+++ units/themes/theme_item.php (working copy)
@@ -20,13 +20,30 @@
{
$default = false;
if ($id == 'default') {
- $id = 1;
- $id_field_name = 'PrimaryTheme';
+ // domain based primary theme
+ $id = $this->Application->siteDomainField('PrimaryThemeId');
+
+ if (!$id) {
+ $id = 1;
+ $id_field_name = 'PrimaryTheme';
+ }
+
$default = true;
}
$res = parent::Load($id, $id_field_name, true);
+ if ($res) {
+ $available_themes = $this->Application->siteDomainField('Themes');
+
+ if ($available_themes) {
+ if (strpos($available_themes, '|' . $this->GetID() . '|') === false) {
+ // theme isn't allowed in site domain
+ return $this->Clear();
+ }
+ }
+ }
+
if ($default) {
if (!$res) {
if ($this->Application->isAdmin) {
Index: units/themes/themes_eh.php
===================================================================
--- units/themes/themes_eh.php (revision 13400)
+++ units/themes/themes_eh.php (working copy)
@@ -168,13 +168,28 @@
{
parent::SetCustomQuery($event);
- if ($event->Special == 'enabled' || !$this->Application->isAdminUser) {
+ $object =& $event->getObject();
+ /* @var $object kDBList */
+
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser) {
// "enabled" special or Front-End
+ $object->addFilter('enabled_filter', '%1$s.Enabled = ' . STATUS_ACTIVE);
+ }
- $object =& $event->getObject();
- /* @var $object kDBList */
+ // site domain theme picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
- $object->addFilter('enabled_filter', '%1$s.Enabled = 1');
+ $edit_picker_helper->applyFilter($event, 'Themes');
}
+
+ // apply domain-based theme filtering
+ $themes = $this->Application->siteDomainField('Themes');
+
+ if (strlen($themes)) {
+ $themes = explode('|', substr($themes, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.ThemeId IN (' . implode(',', $themes) . ')');
+ }
}
}
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 13471)
+++ units/users/users_event_handler.php (working copy)
@@ -1370,7 +1370,15 @@
parent::OnAfterConfigRead($event);
// 1. arrange user registration countries
- $first_country = $this->Application->ConfigValue('User_Default_Registration_Country');
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $first_country = $site_helper->getDefaultCountry('', false);
+
+ if ($first_country === false) {
+ $first_country = $this->Application->ConfigValue('User_Default_Registration_Country');
+ }
+
if ($first_country) {
// update user country dropdown sql
$fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
@@ -1414,7 +1422,6 @@
$this->Application->setUnitOption($event->Prefix, 'EditTabPresets', $edit_tab_presets);
}
}
-
}
/**
site_domains_modules_v3.patch [^] (25,776 bytes) 2010-05-05 09:23
[Show Content]
Index: in-commerce/admin_templates/site_domains/site_domain_edit.tpl
===================================================================
--- in-commerce/admin_templates/site_domains/site_domain_edit.tpl (revision 0)
+++ in-commerce/admin_templates/site_domains/site_domain_edit.tpl (revision 0)
@@ -0,0 +1,73 @@
+<inp2:adm_SetPopupSize width="750" height="560"/>
+
+<inp2:m_include t="incs/header"/>
+<inp2:m_RenderElement name="combined_header" section="in-portal:site_domains" prefix="site-domain" title_preset="site_domain_edit_in_commerce" tab_preset="Default"/>
+
+<!-- ToolBar -->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
+ submit_event('site-domain', '<inp2:site-domain_SaveEvent/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
+ cancel_edit('site-domain', 'OnCancelEdit','<inp2:site-domain_SaveEvent/>','<inp2:m_Phrase label="la_FormCancelConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarButton('reset_edit', '<inp2:m_phrase label="la_ToolTip_Reset" escape="1"/>', function() {
+ reset_form('site-domain', 'OnReset', '<inp2:m_Phrase label="la_FormResetConfirmation" escape="1"/>');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_PrevId/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
+ go_to_id('site-domain', '<inp2:site-domain_NextId/>');
+ }
+ ) );
+
+ a_toolbar.Render();
+
+ <inp2:m_if check="site-domain_IsSingle">
+ a_toolbar.HideButton('prev');
+ a_toolbar.HideButton('next');
+ a_toolbar.HideButton('sep1');
+ <inp2:m_else/>
+ <inp2:m_if check="site-domain_IsLast">
+ a_toolbar.DisableButton('next');
+ </inp2:m_if>
+ <inp2:m_if check="site-domain_IsFirst">
+ a_toolbar.DisableButton('prev');
+ </inp2:m_if>
+ </inp2:m_if>
+ </script>
+ </td>
+ </tr>
+</tbody>
+</table>
+
+<inp2:site-domain_SaveWarning name="grid_save_warning"/>
+<inp2:site-domain_ErrorWarning name="form_error_warning"/>
+
+<div id="scroll_container">
+ <table class="edit-form">
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="BillingCountry" title="la_fld_BillingCountry" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="ShippingCountry" title="la_fld_ShippingCountry" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryCurrencyId" title="la_fld_Currency" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="Currencies" title="la_fld_Currencies" optprefix="curr" option_key_field="CurrencyId" option_value_field="Translation"/>
+ <inp2:m_RenderElement name="inp_edit_options" prefix="site-domain" field="PrimaryPaymentTypeId" title="la_fld_PaymentType" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_picker" prefix="site-domain" field="PaymentTypes" title="la_fld_PaymentTypes" optprefix="pt" option_key_field="PaymentTypeId" option_value_field="Name"/>
+ <inp2:m_RenderElement name="inp_edit_filler"/>
+ </table>
+</div>
+
+<inp2:m_include t="incs/footer"/>
Index: in-commerce/install/english.lang
===================================================================
--- in-commerce/install/english.lang (revision 13400)
+++ in-commerce/install/english.lang (working copy)
@@ -90,6 +90,7 @@
<PHRASE Label="la_col_Amount" Module="In-Commerce" Type="1">QW1vdW50</PHRASE>
<PHRASE Label="la_col_Availability" Module="In-Commerce" Type="1">QXZhaWwu</PHRASE>
<PHRASE Label="la_col_BaseFee" Module="In-Commerce" Type="1">QmFzZSBGZWU=</PHRASE>
+ <PHRASE Label="la_col_BillingCountry" Module="In-Commerce" Type="1">QmlsbGluZyBDb3VudHJ5</PHRASE>
<PHRASE Label="la_col_BuiltIn" Module="In-Commerce" Type="1">QnVpbHQtSW4=</PHRASE>
<PHRASE Label="la_col_CODallowed" Module="In-Commerce" Type="1">Q09EIEFsbG93ZWQ=</PHRASE>
<PHRASE Label="la_col_Code" Module="In-Commerce" Type="1">Q29kZQ==</PHRASE>
@@ -103,6 +104,7 @@
<PHRASE Label="la_col_CouponCode" Module="In-Commerce" Type="1">Q291cG9uIENvZGU=</PHRASE>
<PHRASE Label="la_col_CouponItemType" Module="In-Commerce" Type="1">Q291cG9uIEl0ZW0gVHlwZQ==</PHRASE>
<PHRASE Label="la_col_CreditCardNumber" Module="In-Commerce" Type="1">Q3JlZGl0IENhcmQgTnVtYmVy</PHRASE>
+ <PHRASE Label="la_col_Currency" Module="In-Commerce" Type="1">Q3VycmVuY3k=</PHRASE>
<PHRASE Label="la_col_CurrencyName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_col_CurrencySymbol" Module="In-Commerce" Type="1">U3ltYm9s</PHRASE>
<PHRASE Label="la_col_CurrencySymbolPosition" Module="In-Commerce" Type="1">U3ltYm9sIFBvc2l0aW9u</PHRASE>
@@ -180,6 +182,7 @@
<PHRASE Label="la_col_ReturnedOn" Module="In-Commerce" Type="1">UmV0LiBEYXRl</PHRASE>
<PHRASE Label="la_col_ReturnType" Module="In-Commerce" Type="1">UmV0LiBUeXBl</PHRASE>
<PHRASE Label="la_col_Shipping" Module="In-Commerce" Type="1">U2hpcHBpbmc=</PHRASE>
+ <PHRASE Label="la_col_ShippingCountry" Module="In-Commerce" Type="1">U2hpcHBpbmcgQ291bnRyeQ==</PHRASE>
<PHRASE Label="la_col_ShippingFromLocation" Module="In-Commerce" Type="1">RnJvbSBMb2NhdGlvbg==</PHRASE>
<PHRASE Label="la_col_ShippingName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_col_ShippingQuoteEngineName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
@@ -311,6 +314,8 @@
<PHRASE Label="la_fld_CostType" Module="In-Commerce" Type="1">Q29zdCBUeXBl</PHRASE>
<PHRASE Label="la_fld_CouponCode" Module="In-Commerce" Type="1">Q291cG9uIENvZGU=</PHRASE>
<PHRASE Label="la_fld_CreditCardNumber" Module="In-Commerce" Type="1">Q3JlZGl0IENhcmQgTnVtYmVy</PHRASE>
+ <PHRASE Label="la_fld_Currencies" Module="In-Commerce" Type="1">Q3VycmVuY2llcw==</PHRASE>
+ <PHRASE Label="la_fld_Currency" Module="In-Commerce" Type="1">Q3VycmVuY3k=</PHRASE>
<PHRASE Label="la_fld_CurrencyName" Module="In-Commerce" Type="1">TmFtZQ==</PHRASE>
<PHRASE Label="la_fld_CurrencySymbol" Module="In-Commerce" Type="1">U3ltYm9s</PHRASE>
<PHRASE Label="la_fld_CurrencySymbolPosition" Module="In-Commerce" Type="1">U3ltYm9sIFBvc2l0aW9u</PHRASE>
@@ -381,6 +386,7 @@
<PHRASE Label="la_fld_PaymentType" Module="In-Commerce" Type="1">UGF5bWVudCBUeXBl</PHRASE>
<PHRASE Label="la_fld_PaymentTypeCurrencies" Module="In-Commerce" Type="1">QXZhaWxhYmxlIEN1cnJlbmNpZXM=</PHRASE>
<PHRASE Label="la_fld_PaymentTypeId" Module="In-Commerce" Type="1">UGF5bWVudCBUeXBlIElk</PHRASE>
+ <PHRASE Label="la_fld_PaymentTypes" Module="In-Commerce" Type="1">UGF5bWVudCBUeXBlcw==</PHRASE>
<PHRASE Label="la_fld_PercentSurcharge" Module="In-Commerce" Type="1">UGVyY2VudCBTdXJjaGFyZ2U=</PHRASE>
<PHRASE Label="la_fld_Period" Module="In-Commerce" Type="1">UGVyaW9k</PHRASE>
<PHRASE Label="la_fld_PlacedOrdersEdit" Module="In-Commerce" Type="1">QWxsb3cgUGxhY2VkIE9yZGVycyBFZGl0aW5n</PHRASE>
Index: in-commerce/install/install_schema.sql
===================================================================
--- in-commerce/install/install_schema.sql (revision 13400)
+++ in-commerce/install/install_schema.sql (working copy)
@@ -711,4 +711,18 @@
ResourceId int(10) unsigned NOT NULL default '0',
KEY ResourceId (ResourceId),
PRIMARY KEY (CustomDataId)
-);
\ No newline at end of file
+);
+
+ALTER TABLE SiteDomains
+ ADD COLUMN BillingCountry varchar(3) NOT NULL DEFAULT '',
+ ADD COLUMN ShippingCountry varchar(3) NOT NULL DEFAULT '',
+ ADD COLUMN PrimaryCurrencyId int(11) NOT NULL DEFAULT '0',
+ ADD COLUMN Currencies varchar(255) NOT NULL DEFAULT '',
+ ADD COLUMN PrimaryPaymentTypeId int(11) NOT NULL DEFAULT '0',
+ ADD COLUMN PaymentTypes varchar(255) NOT NULL DEFAULT '',
+ ADD INDEX (BillingCountry),
+ ADD INDEX (ShippingCountry),
+ ADD INDEX (PrimaryCurrencyId),
+ ADD INDEX (Currencies),
+ ADD INDEX (PrimaryPaymentTypeId),
+ ADD INDEX (PaymentTypes);
\ No newline at end of file
Index: in-commerce/install/upgrades.sql
===================================================================
--- in-commerce/install/upgrades.sql (revision 13465)
+++ in-commerce/install/upgrades.sql (working copy)
@@ -126,4 +126,18 @@
UPDATE ConfigurationValues
SET ValueList = '0=lu_none||<SQL+>SELECT l%3$s_Name AS OptionName, CountryStateId AS OptionValue FROM <PREFIX>CountryStates WHERE Type = 1 ORDER BY OptionName</SQL>'
-WHERE ValueList = '0=lu_none||<SQL>SELECT DestName AS OptionName, DestAbbr AS OptionValue FROM <PREFIX>StdDestinations WHERE DestParentId IS NULL Order BY OptionName</SQL>';
\ No newline at end of file
+WHERE ValueList = '0=lu_none||<SQL>SELECT DestName AS OptionName, DestAbbr AS OptionValue FROM <PREFIX>StdDestinations WHERE DestParentId IS NULL Order BY OptionName</SQL>';
+
+ALTER TABLE SiteDomains
+ ADD COLUMN BillingCountry varchar(3) NOT NULL DEFAULT '',
+ ADD COLUMN ShippingCountry varchar(3) NOT NULL DEFAULT '',
+ ADD COLUMN PrimaryCurrencyId int(11) NOT NULL DEFAULT '0',
+ ADD COLUMN Currencies varchar(255) NOT NULL DEFAULT '',
+ ADD COLUMN PrimaryPaymentTypeId int(11) NOT NULL DEFAULT '0',
+ ADD COLUMN PaymentTypes varchar(255) NOT NULL DEFAULT '',
+ ADD INDEX (BillingCountry),
+ ADD INDEX (ShippingCountry),
+ ADD INDEX (PrimaryCurrencyId),
+ ADD INDEX (Currencies),
+ ADD INDEX (PrimaryPaymentTypeId),
+ ADD INDEX (PaymentTypes);
\ No newline at end of file
Index: in-commerce/units/addresses/addresses_event_handler.php
===================================================================
--- in-commerce/units/addresses/addresses_event_handler.php (revision 13465)
+++ in-commerce/units/addresses/addresses_event_handler.php (working copy)
@@ -318,4 +318,21 @@
return ;
}
}
+
+ /**
+ * Sets default country for new addresses to Latvia
+ *
+ * @param kEvent $event
+ */
+ function OnAfterConfigRead(&$event)
+ {
+ parent::OnAfterConfigRead($event);
+
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $fields['Country']['default'] = $site_helper->getDefaultCountry('Shipping');
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ }
}
\ No newline at end of file
Index: in-commerce/units/currencies/currencies_event_handler.php
===================================================================
--- in-commerce/units/currencies/currencies_event_handler.php (revision 13400)
+++ in-commerce/units/currencies/currencies_event_handler.php (working copy)
@@ -95,6 +95,23 @@
if (!$this->Application->isAdminUser) {
$object->addFilter('status_filter', $object->TableName.'.Status = 1');
}
+
+ // site domain currency picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'Currencies');
+ $object->addFilter('status_filter', '%1$s.Status = ' . STATUS_ACTIVE);
+ }
+
+ // apply domain-based currency filtering
+ $currencies = $this->Application->siteDomainField('Currencies');
+
+ if (strlen($currencies)) {
+ $currencies = explode('|', substr($currencies, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.CurrencyId IN (' . implode(',', $currencies) . ')');
+ }
}
/**
@@ -208,7 +225,17 @@
function OnChangeCurrency(&$event)
{
- $this->Application->StoreVar('curr_iso', $this->Application->GetVar('curr_iso'));
+ $currency_iso = $this->Application->GetVar('curr_iso');
+ $available_currencies = $this->Application->siteDomainField('Currencies');
+
+ if ($available_currencies) {
+ if (strpos($available_currencies, '|' . $currency_iso . '|') === false) {
+ // currency isn't allowed in site domain
+ return ;
+ }
+ }
+
+ $this->Application->StoreVar('curr_iso', $currency_iso);
}
/**
Index: in-commerce/units/orders/orders_event_handler.php
===================================================================
--- in-commerce/units/orders/orders_event_handler.php (revision 13465)
+++ in-commerce/units/orders/orders_event_handler.php (working copy)
@@ -538,17 +538,16 @@
function OnProceedToBilling(&$event)
{
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
- if($items_info)
- {
- list($id,$field_values) = each($items_info);
+ if ($items_info) {
+ list($id, $field_values) = each($items_info);
$object =& $event->getObject();
$payment_type_id = $object->GetDBField('PaymentType');
- if(!$payment_type_id)
- {
- $default_type = $this->Conn->GetOne('SELECT PaymentTypeId FROM '.TABLE_PREFIX.'PaymentTypes WHERE IsPrimary = 1');
- if($default_type)
- {
+
+ if (!$payment_type_id) {
+ $default_type = $this->_getDefaultPaymentType();
+
+ if ($default_type) {
$field_values['PaymentType'] = $default_type;
$items_info[$id] = $field_values;
$this->Application->SetVar( $event->getPrefixSpecial(true), $items_info );
@@ -1115,7 +1114,8 @@
}
// get payment type
- $default_type = $this->Conn->GetOne('SELECT PaymentTypeId FROM '.TABLE_PREFIX.'PaymentTypes WHERE IsPrimary = 1');
+ $default_type = $this->_getDefaultPaymentType();
+
if ($default_type) {
$object->SetDBField('PaymentType', $default_type);
}
@@ -1133,6 +1133,25 @@
return 0;
}
+ /**
+ * Returns default payment type for order
+ *
+ * @return int
+ */
+ function _getDefaultPaymentType()
+ {
+ $default_type = $this->Application->siteDomainField('PrimaryPaymentTypeId');
+
+ if (!$default_type) {
+ $sql = 'SELECT PaymentTypeId
+ FROM ' . TABLE_PREFIX . 'PaymentTypes
+ WHERE IsPrimary = 1';
+ $default_type = $this->Conn->GetOne($sql);
+ }
+
+ return $default_type;
+ }
+
function StoreContinueShoppingLink()
{
$this->Application->StoreVar('continue_shopping', 'external:'.PROTOCOL.SERVER_NAME.$this->Application->RecallVar('last_url'));
@@ -1975,6 +1994,21 @@
$object =& $event->getObject();
/* @var $object OrdersItem */
+ $old_payment_type = $object->GetOriginalField('PaymentType');
+ $new_payment_type = $object->GetDBField('PaymentType');
+
+ if ($new_payment_type != $old_payment_type) {
+ // payment type changed -> check that it's allowed
+ $available_payment_types = $this->Application->siteDomainField('PaymentTypes');
+
+ if ($available_payment_types) {
+ if (strpos($available_payment_types, '|' . $new_payment_type . '|') === false) {
+ // payment type isn't allowed in site domain
+ $object->SetDBField('PaymentType', $old_payment_type);
+ }
+ }
+ }
+
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
/* @var $cs_helper kCountryStatesHelper */
@@ -3824,15 +3858,34 @@
$fields['Number']['format'] = str_replace('%06d', '%0'.$order_number.'d', $fields['Number']['format']);
$fields['SubNumber']['format'] = str_replace('%03d', '%0'.$order_sub_number.'d', $fields['SubNumber']['format']);
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $fields['BillingCountry']['default'] = $site_helper->getDefaultCountry('Billing');
+ $fields['ShippingCountry']['default'] = $site_helper->getDefaultCountry('Shipping');
+
if (!$this->Application->isAdminUser) {
$user_groups = explode(',', $this->Application->RecallVar('UserGroups'));
$default_group = $this->Application->ConfigValue('User_LoggedInGroup');
if (!in_array($default_group, $user_groups)){
$user_groups[]=$default_group;
}
- $fields['PaymentType']['options_sql'] .= ' AND ';
- $fields['PaymentType']['options_sql'] .= ' (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%")';
+ $sql = $fields['PaymentType']['options_sql'];
+
+ // limit payment types by domain
+ $payment_types = $this->Application->siteDomainField('PaymentTypes');
+
+ if (strlen($payment_types)) {
+ $payment_types = explode('|', substr($payment_types, 1, -1));
+ $sql .= ' AND PaymentTypeId IN (' . implode(',', $payment_types) . ')';
+ }
+
+ // limit payment types by user group
+ $sql .= ' AND (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%")';
+
+ $fields['PaymentType']['options_sql'] = $sql;
+
}
$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
Index: in-commerce/units/payment_type/payment_type_event_handler.php
===================================================================
--- in-commerce/units/payment_type/payment_type_event_handler.php (revision 13400)
+++ in-commerce/units/payment_type/payment_type_event_handler.php (working copy)
@@ -218,4 +218,38 @@
return parent::getPassedID($event);
}
+ /**
+ * Apply system filter to themes list
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ parent::SetCustomQuery($event);
+
+ $object =& $event->getObject();
+ /* @var $object kDBList */
+
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser) {
+ // "enabled" special or Front-End
+ $object->addFilter('enabled_filter', '%1$s.Status = ' . STATUS_ACTIVE);
+ }
+
+ // site domain payment type picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'PaymentTypes');
+ }
+
+ // apply domain-based payment type filtering
+ $payment_types = $this->Application->siteDomainField('PaymentTypes');
+
+ if (strlen($payment_types)) {
+ $payment_types = explode('|', substr($payment_types, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.PaymentTypeId IN (' . implode(',', $payment_types) . ')');
+ }
+ }
+
}
\ No newline at end of file
Index: in-commerce/units/sections/section_eh.php
===================================================================
--- in-commerce/units/sections/section_eh.php (revision 0)
+++ in-commerce/units/sections/section_eh.php (revision 0)
@@ -0,0 +1,101 @@
+<?php
+/**
+* @version $Id$
+* @package In-Commerce
+* @copyright Copyright (C) 1997 - 2010 Intechnic. All rights reserved.
+* @license Commercial License
+* This software is protected by copyright law and international treaties.
+* Unauthorized reproduction or unlicensed usage of the code of this program,
+* or any portion of it may result in severe civil and criminal penalties,
+* and will be prosecuted to the maximum extent possible under the law
+* See http://www.in-portal.org/commercial-license for copyright notices and details.
+*/
+
+ defined('FULL_PATH') or die('restricted access!');
+
+ class InCommerceEventHandler extends kEventHandler {
+
+ /**
+ * [HOOK] Creates site domain editing tab
+ *
+ * @param kEvent $event
+ */
+ function OnModifySiteDomainConfig(&$event)
+ {
+ $edit_tab_presets = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'EditTabPresets');
+ $edit_tab_presets['Default']['in-commerce'] = Array (
+ 'title' => 'la_title_In-Commerce', 't' => 'in-commerce/site_domains/site_domain_edit', 'priority' => 2.1
+ );
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'EditTabPresets', $edit_tab_presets);
+
+ $title_presets = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'TitlePresets');
+ $title_presets['site_domain_edit_in_commerce'] = Array (
+ 'prefixes' => Array ('site-domain'), 'format' => "#site-domain_status# '#site-domain_titlefield#' - !la_title_In-Commerce!",
+ 'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
+ );
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'TitlePresets', $title_presets);
+
+ $new_fields = Array (
+ 'BillingCountry' => Array (
+ 'type' => 'string', 'max_len' => 3,
+ 'formatter' => 'kOptionsFormatter',
+ 'options_sql' => ' SELECT IF(l%2$s_Name = "", l%3$s_Name, l%2$s_Name) AS Name, IsoCode
+ FROM ' . TABLE_PREFIX . 'CountryStates
+ WHERE Type = ' . DESTINATION_TYPE_COUNTRY . '
+ ORDER BY Name',
+ 'option_key_field' => 'IsoCode', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'ShippingCountry' => Array (
+ 'type' => 'string', 'max_len' => 3,
+ 'formatter' => 'kOptionsFormatter',
+ 'options_sql' => ' SELECT IF(l%2$s_Name = "", l%3$s_Name, l%2$s_Name) AS Name, IsoCode
+ FROM ' . TABLE_PREFIX . 'CountryStates
+ WHERE Type = ' . DESTINATION_TYPE_COUNTRY . '
+ ORDER BY Name',
+ 'option_key_field' => 'IsoCode', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryCurrencyId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Currencies WHERE Status = 1 ORDER BY ISO', 'option_key_field' => 'CurrencyId', 'option_title_field' => 'Name', 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'Currencies' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Currencies WHERE Status = 1 ORDER BY ISO', 'option_key_field' => 'CurrencyId', 'option_title_field' => 'Name', 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'PrimaryPaymentTypeId' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PaymentTypes WHERE Status = 1 ORDER BY Name ASC', 'option_key_field' => 'PaymentTypeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => 0
+ ),
+ 'PaymentTypes' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PaymentTypes WHERE Status = 1 ORDER BY Name ASC', 'option_key_field' => 'PaymentTypeId', 'option_title_field' => 'Name',
+ 'not_null' => 1, 'default' => ''
+ ),
+ );
+
+ $fields = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Fields');
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Fields', array_merge_recursive2($fields, $new_fields));
+
+ $new_columns = Array (
+ 'BillingCountry' => Array ('title' => 'la_col_BillingCountry', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'ShippingCountry' => Array ('title' => 'la_col_ShippingCountry', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryCurrencyId' => Array ('title' => 'la_col_Currency', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ 'PrimaryPaymentTypeId' => Array ('title' => 'la_col_PaymentType', 'filter_block' => 'grid_options_filter', 'width' => 250, ),
+ );
+
+ $grids = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Grids');
+ $grids['Default']['Fields'] = array_merge_recursive2($grids['Default']['Fields'], $new_columns);
+ $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Grids', $grids);
+
+ if (!$this->Application->isAdmin) {
+ // re-configure object, because it's recalled before kUnitConfigReader::AfterConfigRead is called
+ $this->Application->siteDomain->defineFields();
+ }
+ }
+
+ }
Index: in-commerce/units/sections/sections_config.php
===================================================================
--- in-commerce/units/sections/sections_config.php (revision 0)
+++ in-commerce/units/sections/sections_config.php (revision 0)
@@ -0,0 +1,34 @@
+<?php
+/**
+* @version $Id$
+* @package In-Commerce
+* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
+* @license Commercial License
+* This software is protected by copyright law and international treaties.
+* Unauthorized reproduction or unlicensed usage of the code of this program,
+* or any portion of it may result in severe civil and criminal penalties,
+* and will be prosecuted to the maximum extent possible under the law
+* See http://www.in-portal.org/commercial-license for copyright notices and details.
+*/
+
+ defined('FULL_PATH') or die('restricted access!');
+
+ $config = Array (
+ 'Prefix' => 'in-commerce-sections',
+
+ 'EventHandlerClass' => Array ('class' => 'InCommerceEventHandler', 'file' => 'section_eh.php', 'build_event' => 'OnBuild'), // for OnAfterConfigRead event
+ 'TagProcessorClass' => Array ('class' => 'kTagProcessor', 'file' => '', 'build_event' => 'OnBuild'), // for tree drawing
+
+ 'Hooks' => Array (
+ Array (
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'site-domain',
+ 'HookToSpecial' => '*',
+ 'HookToEvent' => Array ('OnAfterConfigRead'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '*',
+ 'DoEvent' => 'OnModifySiteDomainConfig',
+ ),
+ ),
+ );
|