protected void submitTranslation_Click(object sender, EventArgs e)
        {
            var modCtrl = new ModuleController();
            var tabCtrl = new TabController();

            foreach (TabInfo localizedTab in Tab.LocalizedTabs.Values)
            {
                //Make Deep copies of all modules
                var moduleCtrl = new ModuleController();
                foreach (KeyValuePair<int, ModuleInfo> kvp in moduleCtrl.GetTabModules(Tab.TabID))
                {
                    ModuleInfo sourceModule = kvp.Value;
                    ModuleInfo localizedModule = null;

                    //Make sure module has the correct culture code
                    if (string.IsNullOrEmpty(sourceModule.CultureCode))
                    {
                        sourceModule.CultureCode = Tab.CultureCode;
                        moduleCtrl.UpdateModule(sourceModule);
                    }

                    if (!sourceModule.LocalizedModules.TryGetValue(localizedTab.CultureCode, out localizedModule))
                    {
                        if (!sourceModule.IsDeleted)
                        {
                            //Shallow (Reference Copy)

                            {
                                if (sourceModule.AllTabs)
                                {
                                    foreach (ModuleInfo m in moduleCtrl.GetModuleTabs(sourceModule.ModuleID))
                                    {
                                        //Get the tab
                                        TabInfo allTabsTab = tabCtrl.GetTab(m.TabID, m.PortalID, false);
                                        TabInfo localizedAllTabsTab = null;
                                        if (allTabsTab.LocalizedTabs.TryGetValue(localizedTab.CultureCode, out localizedAllTabsTab))
                                        {
                                            moduleCtrl.CopyModule(m, localizedAllTabsTab, Null.NullString, true);
                                        }
                                    }
                                }
                                else
                                {
                                    moduleCtrl.CopyModule(sourceModule, localizedTab, Null.NullString, true);
                                }
                            }

                            //Fetch new module
                            localizedModule = moduleCtrl.GetModule(sourceModule.ModuleID, localizedTab.TabID);

                            //Convert to deep copy
                            moduleCtrl.LocalizeModule(localizedModule, LocaleController.Instance.GetLocale(localizedTab.CultureCode));
                        }
                    }
                }

                var users = new Dictionary<int, UserInfo>();

                //Give default translators for this language and administrators permissions
                tabCtrl.GiveTranslatorRoleEditRights(localizedTab, users);

                //Send Messages to all the translators of new content
                foreach (var translator in users.Values.Where(user => user.UserID != PortalSettings.AdministratorId))
                {
                    AddTranslationSubmittedNotification(localizedTab, translator);
                }
            }

            //Redirect to refresh page (and skinobjects)
            Response.Redirect(Request.RawUrl, true);
        }
        protected void submitTranslation_Click(object sender, EventArgs e)
        {
            sendTranslationMessageConfirm.Visible = true;
            try
            {

                var tabCtrl = new TabController();

                // loop through all localized version of this page
                foreach (TabInfo localizedTab in Tab.LocalizedTabs.Values)
                {
                    var users = new Dictionary<int, UserInfo>();

                    //Give default translators for this language and administrators permissions
                    tabCtrl.GiveTranslatorRoleEditRights(localizedTab, users);

                    //Send Messages to all the translators of new content
                    foreach (var translator in users.Values.Where(user => user.UserID != PortalSettings.AdministratorId))
                    {
                        AddTranslationSubmittedNotification(localizedTab, translator);
                    }
                }
                txtTranslationComment.Text = "";
                sendTranslationMessageRow.Visible = false;
                sendTranslationMessageConfirm.Attributes.Remove("class");
                sendTranslationMessageConfirm.Attributes.Add("class", "dnnFormMessage dnnFormSuccess");

                sendTranslationMessageConfirmMessage.Text = LocalizeString("TranslationMessageConfirmMessage.Text");
            }
            catch (Exception)
            {
                sendTranslationMessageConfirm.Attributes.Remove("class");
                sendTranslationMessageConfirm.Attributes.Add("class", "dnnFormMessage dnnFormError");
                sendTranslationMessageConfirmMessage.Text = LocalizeString("TranslationMessageConfirmMessage.Error");
                throw;
            }
        }
Example #3
0
        protected void readyForTranslationButton_Click(object sender, EventArgs e)
        {
            var modCtrl = new ModuleController();
            var tabCtrl = new TabController();

            foreach (TabInfo localizedTab in Tab.LocalizedTabs.Values)
            {
                //Make Deep copies of all modules
                var moduleCtrl = new ModuleController();
                foreach (KeyValuePair<int, ModuleInfo> kvp in moduleCtrl.GetTabModules(Tab.TabID))
                {
                    ModuleInfo sourceModule = kvp.Value;
                    ModuleInfo localizedModule = null;

                    //Make sure module has the correct culture code
                    if (string.IsNullOrEmpty(sourceModule.CultureCode))
                    {
                        sourceModule.CultureCode = Tab.CultureCode;
                        moduleCtrl.UpdateModule(sourceModule);
                    }

                    if (!sourceModule.LocalizedModules.TryGetValue(localizedTab.CultureCode, out localizedModule))
                    {
                        if (!sourceModule.IsDeleted)
                        {
                            //Shallow (Reference Copy)

                            {
                                if (sourceModule.AllTabs)
                                {
                                    foreach (ModuleInfo m in moduleCtrl.GetModuleTabs(sourceModule.ModuleID))
                                    {
                                        //Get the tab
                                        TabInfo allTabsTab = tabCtrl.GetTab(m.TabID, m.PortalID, false);
                                        TabInfo localizedAllTabsTab = null;
                                        if (allTabsTab.LocalizedTabs.TryGetValue(localizedTab.CultureCode, out localizedAllTabsTab))
                                        {
                                            moduleCtrl.CopyModule(m, localizedAllTabsTab, Null.NullString, true);
                                        }
                                    }
                                }
                                else
                                {
                                    moduleCtrl.CopyModule(sourceModule, localizedTab, Null.NullString, true);
                                }
                            }

                            //Fetch new module
                            localizedModule = moduleCtrl.GetModule(sourceModule.ModuleID, localizedTab.TabID);

                            //Convert to deep copy
                            moduleCtrl.LocalizeModule(localizedModule, LocaleController.Instance.GetLocale(localizedTab.CultureCode));
                        }
                    }
                }

                var users = new Dictionary<int, UserInfo>();

                //Give default translators for this language and administrators permissions
                tabCtrl.GiveTranslatorRoleEditRights(localizedTab, users);

                //Send Messages to all the translators of new content
                foreach (UserInfo translator in users.Values)
                {
                    if (translator.UserID != PortalSettings.AdministratorId)
                    {
                        var message = new Message();
                        message.FromUserID = PortalSettings.AdministratorId;
                        message.ToUserID = translator.UserID;
                        message.Subject = Localization.GetString("NewContentMessage.Subject", LocalResourceFile);
                        message.Status = MessageStatusType.Unread;
                        message.Body = string.Format(Localization.GetString("NewContentMessage.Body", LocalResourceFile),
                                                     localizedTab.TabName,
                                                     Globals.NavigateURL(localizedTab.TabID, false, PortalSettings, Null.NullString, localizedTab.CultureCode, new string[] { }));

                        var messageCtrl = new MessagingController();
                        messageCtrl.SaveMessage(message);
                    }
                }
            }

            //Redirect to refresh page (and skinobjects)
            Response.Redirect(Request.RawUrl, true);
        }