protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                if (!String.IsNullOrEmpty(CssClass))
                {
                    registerLink.CssClass = CssClass;
                }

                if (Request.IsAuthenticated == false)
                {
                    if (PortalSettings.UserRegistration != (int) Globals.PortalRegistrationType.NoRegistration)
                    {
                        if (!String.IsNullOrEmpty(Text))
                        {
                            if (Text.IndexOf("src=") != -1)
                            {
                                Text = Text.Replace("src=\"", "src=\"" + PortalSettings.ActiveTab.SkinPath);
                            }
                            registerLink.Text = Text;
                        }
                        else
                        {
                            registerLink.Text = Localization.GetString("Register", Localization.GetResourceFile(this, MyFileName));
                        }
                        if (PortalSettings.Users < PortalSettings.UserQuota || PortalSettings.UserQuota == 0)
                        {
                            registerLink.Visible = true;
                        }
                        else
                        {
                            registerLink.Visible = false;
                        }

                        registerLink.NavigateUrl = !String.IsNullOrEmpty(URL)
                                            ? URL
                                            : Globals.RegisterURL(HttpUtility.UrlEncode(Globals.NavigateURL()), Null.NullString);

                        if (PortalSettings.EnablePopUps && PortalSettings.RegisterTabId == Null.NullInteger)
                        {
                            registerLink.Attributes.Add("onclick", "return " + UrlUtils.PopUpUrl(registerLink.NavigateUrl, this, PortalSettings, true, false, 600, 950));
                        }

                    }
                    else
                    {
                        registerLink.Visible = false;
                    }
                }
                else
                {
                    var objUserInfo = UserController.GetCurrentUserInfo();
                    if (objUserInfo.UserID != -1)
                    {
                        var messagingController = new MessagingController();

                        int messageCount = messagingController.GetNewMessageCount(PortalSettings.PortalId, objUserInfo.UserID);

                        registerLink.Text = objUserInfo.DisplayName;

                        if ((ShowUnreadMessages && messageCount > 0))
                        {
                            registerLink.Text = registerLink.Text + string.Format(Localization.GetString("NewMessages", Localization.GetResourceFile(this, MyFileName)), messageCount);
                        }
                        if (ShowUnreadMessages && messageCount > 0)
                        {
                            registerLink.ToolTip = String.Format(Localization.GetString("ToolTipNewMessages", Localization.GetResourceFile(this, MyFileName)), messageCount);
                        }
                        else
                        {
                            registerLink.ToolTip = Localization.GetString("ToolTip", Localization.GetResourceFile(this, MyFileName));
                        }

                        if (objUserInfo.UserID != -1)
                        {
                            registerLink.NavigateUrl =Globals.UserProfileURL(objUserInfo.UserID);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #2
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);
        }