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);
        }
        /// <summary>
        /// Synchronizes the module content between cache and database.
        /// </summary>
        /// <param name="moduleID">The module ID.</param>
        public static void SynchronizeModule(int moduleID)
        {
            var moduleController = new ModuleController();
            ArrayList modules = moduleController.GetModuleTabs(moduleID);
            var tabController = new TabController();
            foreach (ModuleInfo module in modules)
            {
                Hashtable tabSettings = tabController.GetTabSettings(module.TabID);
                if (tabSettings["CacheProvider"] != null && tabSettings["CacheProvider"].ToString().Length > 0)
                {
                    var outputProvider = OutputCachingProvider.Instance(tabSettings["CacheProvider"].ToString());
                    if (outputProvider != null)
                    {
                        outputProvider.Remove(module.TabID);
                    }
                }

                if (module.CacheTime > 0)
                {
                    var moduleProvider = ModuleCachingProvider.Instance(module.GetEffectiveCacheMethod());
                    if (moduleProvider != null)
                    {
                        moduleProvider.Remove(module.TabModuleID);
                    }
                }

                //Synchronize module is called when a module needs to indicate that the content
                //has changed and the cache's should be refreshed.  So we can update the Version
                //and also the LastContentModificationDate
                UpdateTabModuleVersion(module.TabModuleID);
                dataProvider.UpdateModuleLastContentModifiedOnDate(module.ModuleID);

                //We should also indicate that the Transalation Status has changed
                if (PortalController.GetPortalSettingAsBoolean("ContentLocalizationEnabled", module.PortalID, false))
                {
                    moduleController.UpdateTranslationStatus(module, false);
                }
		// and clear the cache
                moduleController.ClearCache(module.TabID);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// LoadActions loads the Actions collections
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]    01/19/2006  created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void LoadActions(HttpRequest request)
        {
            _actions = new ModuleActionCollection();
            _moduleGenericActions = new ModuleAction(GetNextActionID(), Localization.GetString("ModuleGenericActions.Action", Localization.GlobalResourceFile), string.Empty, string.Empty, string.Empty);
            int maxActionId = Null.NullInteger;

            //check if module Implements Entities.Modules.IActionable interface
            var actionable = _moduleControl as IActionable;
            if (actionable != null)
            {
                _moduleSpecificActions = new ModuleAction(GetNextActionID(), Localization.GetString("ModuleSpecificActions.Action", Localization.GlobalResourceFile), string.Empty, string.Empty, string.Empty);

                ModuleActionCollection moduleActions = actionable.ModuleActions;

                foreach (ModuleAction action in moduleActions)
                {
                    if (ModulePermissionController.HasModuleAccess(action.Secure, "CONTENT", Configuration))
                    {
                        if (String.IsNullOrEmpty(action.Icon))
                        {
                            action.Icon = "edit.gif";
                        }
                        if (action.ID > maxActionId)
                        {
                            maxActionId = action.ID;
                        }
                        _moduleSpecificActions.Actions.Add(action);

                        if (!UIUtilities.IsLegacyUI(ModuleId, action.ControlKey, PortalId) && action.Url.Contains("ctl"))
                        {
                            action.ClientScript = UrlUtils.PopUpUrl(action.Url, _moduleControl as Control, PortalSettings, true, false);
                        }
                    }
                }
                if (_moduleSpecificActions.Actions.Count > 0)
                {
                    _actions.Add(_moduleSpecificActions);
                }
            }

            //Make sure the Next Action Id counter is correct
            int actionCount = GetActionsCount(_actions.Count, _actions);
            if (_nextActionId < maxActionId)
            {
                _nextActionId = maxActionId;
            }
            if (_nextActionId < actionCount)
            {
                _nextActionId = actionCount;
            }

            //Custom injection of Module Settings when shared as ViewOnly
            if (Configuration != null && (Configuration.IsShared && Configuration.IsShareableViewOnly)
                    && TabPermissionController.CanAddContentToPage())
            {
                _moduleGenericActions.Actions.Add(GetNextActionID(),
                             Localization.GetString("ModulePermissions.Action", Localization.GlobalResourceFile),
                             "ModulePermissions",
                             "",
                             "action_settings.gif",
                             NavigateUrl(TabId, "ModulePermissions", false, "ModuleId=" + ModuleId, "ReturnURL=" + FilterUrl(request)),
                             false,
                             SecurityAccessLevel.ViewPermissions,
                             true,
                             false);
            }
            else
            {
                if (!Globals.IsAdminControl() && ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "DELETE,MANAGE", Configuration))
                {
                    if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "MANAGE", Configuration))
                    {
                        _moduleGenericActions.Actions.Add(GetNextActionID(),
                                                          Localization.GetString(ModuleActionType.ModuleSettings, Localization.GlobalResourceFile),
                                                          ModuleActionType.ModuleSettings,
                                                          "",
                                                          "action_settings.gif",
                                                          NavigateUrl(TabId, "Module", false, "ModuleId=" + ModuleId, "ReturnURL=" + FilterUrl(request)),
                                                          false,
                                                          SecurityAccessLevel.Edit,
                                                          true,
                                                          false);
                    }
                }
            }

            if (!string.IsNullOrEmpty(Configuration.DesktopModule.BusinessControllerClass))
            {
                //check if module implements IPortable interface, and user has Admin permissions
                if (Configuration.DesktopModule.IsPortable)
                {
                    if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "EXPORT", Configuration))
                    {
                        _moduleGenericActions.Actions.Add(GetNextActionID(),
                                     Localization.GetString(ModuleActionType.ExportModule, Localization.GlobalResourceFile),
                                     "",
                                     "",
                                     "action_export.gif",
                                     NavigateUrl(PortalSettings.ActiveTab.TabID, "ExportModule", false, "moduleid=" + ModuleId, "ReturnURL=" + FilterUrl(request)),

                                     "",
                                     false,
                                     SecurityAccessLevel.View,
                                     true,
                                     false);
                    }
                    if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "IMPORT", Configuration))
                    {
                        _moduleGenericActions.Actions.Add(GetNextActionID(),
                                     Localization.GetString(ModuleActionType.ImportModule, Localization.GlobalResourceFile),
                                     "",
                                     "",
                                     "action_import.gif",
                                     NavigateUrl(PortalSettings.ActiveTab.TabID, "ImportModule", false, "moduleid=" + ModuleId, "ReturnURL=" + FilterUrl(request)),
                                     "",
                                     false,
                                     SecurityAccessLevel.View,
                                     true,
                                     false);
                    }
                }
                if (Configuration.DesktopModule.IsSearchable && Configuration.DisplaySyndicate)
                {
                    AddSyndicateAction();
                }
            }

            //help module actions available to content editors and administrators
            const string permisisonList = "CONTENT,DELETE,EDIT,EXPORT,IMPORT,MANAGE";
            if (ModulePermissionController.HasModulePermission(Configuration.ModulePermissions, permisisonList) && request.QueryString["ctl"] != "Help")
            {
                AddHelpActions();
            }

            //Add Print Action
            if (Configuration.DisplayPrint)
            {
                //print module action available to everyone
                AddPrintAction();
            }
            if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Host, "MANAGE", Configuration))
            {
                _moduleGenericActions.Actions.Add(GetNextActionID(),
                             Localization.GetString(ModuleActionType.ViewSource, Localization.GlobalResourceFile),
                             ModuleActionType.ViewSource,
                             "",
                             "action_source.gif",
                             NavigateUrl(TabId, "ViewSource", false, "ModuleId=" + ModuleId, "ctlid=" + Configuration.ModuleControlId, "ReturnURL=" + FilterUrl(request)),
                             false,
                             SecurityAccessLevel.Host,
                             true,
                             false);
            }



            if (!Globals.IsAdminControl() && ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "DELETE,MANAGE", Configuration))
            {
                if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "DELETE", Configuration))
                {
                    //Check if this is the owner instance of a shared module.
                    string confirmText = "confirm('" + ClientAPI.GetSafeJSString(Localization.GetString("DeleteModule.Confirm")) + "')";
                    if (!Configuration.IsShared)
                    {
                        var moduleController = new ModuleController();
                        if (moduleController.GetModuleTabs(Configuration.ModuleID).Cast<ModuleInfo>().Any(instance => instance.IsShared))
                        {
                            confirmText = "confirm('" + ClientAPI.GetSafeJSString(Localization.GetString("DeleteSharedModule.Confirm")) + "')";
                        }
                    }

                    _moduleGenericActions.Actions.Add(GetNextActionID(),
                                 Localization.GetString(ModuleActionType.DeleteModule, Localization.GlobalResourceFile),
                                 ModuleActionType.DeleteModule,
                                 Configuration.ModuleID.ToString(),
                                 "action_delete.gif",
                                 "",
                                 confirmText,
                                 false,
                                 SecurityAccessLevel.View,
                                 true,
                                 false);
                }
                if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "MANAGE", Configuration))
                {
                    _moduleGenericActions.Actions.Add(GetNextActionID(),
                                 Localization.GetString(ModuleActionType.ClearCache, Localization.GlobalResourceFile),
                                 ModuleActionType.ClearCache,
                                 Configuration.ModuleID.ToString(),
                                 "action_refresh.gif",
                                 "",
                                 false,
                                 SecurityAccessLevel.View,
                                 true,
                                 false);
                }

                if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "MANAGE", Configuration))
                {
                    //module movement
                    AddMenuMoveActions();
                }
            }

            if (_moduleGenericActions.Actions.Count > 0)
            {
                _actions.Add(_moduleGenericActions);
            }

            if (_moduleMoveActions != null && _moduleMoveActions.Actions.Count > 0)
            {
                _actions.Add(_moduleMoveActions);
            }

            foreach (ModuleAction action in _moduleGenericActions.Actions)
            {
                if (!UIUtilities.IsLegacyUI(ModuleId, action.ControlKey, PortalId) && action.Url.Contains("ctl"))
                {
                    action.ClientScript = UrlUtils.PopUpUrl(action.Url, _moduleControl as Control, PortalSettings, true, false);
                }
            }
        }
Exemple #4
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);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // validate module
            // load module
            ModuleInfo _mod = null;
            PortalSettings portalSettings = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings();

            try {
                ModuleController modCtrl = new ModuleController();
                int mid = Convert.ToInt32(Request.Params["mid"]);

                ArrayList mods = modCtrl.GetModuleTabs(mid);
                if (mods == null || mods.Count == 0) {
                    throw new Exception();
                }

                _mod = (ModuleInfo)mods[0];
                if (_mod == null || _mod.ModuleID <= 0) {
                    throw new Exception();
                }
            } catch (Exception ex) {
                _mod = null;
            }

            if (_mod == null) {
                Response.Write("Invalid Module!");
            } else {


                if (Request.Files != null && Request.Files.Count > 0) {
                    try {
                        string parentFolder = uploadPath.Value;
                        if (parentFolder.Length > 0 && parentFolder[parentFolder.Length - 1] != '\\')
                            parentFolder += '\\';

                        string path = portalSettings.HomeDirectoryMapPath + parentFolder + Path.GetFileName(Request.Files[0].FileName);
                        if (File.Exists(path)) {
                            if (cbUploadOverwrite.Checked) {
                                File.Delete(path);
                            } else {
                                throw new Exception("A file with the same name already exists. ");
                            }
                        }

                        Request.Files[0].SaveAs(path);
                        Response.Write(uploadPath.Value);
                    } catch (Exception ex) {
                        Response.Write("Error uploading file (Server response: " + ex.Message + ")");
                    }

                    Response.End();
                }



                if (!Page.IsPostBack) {

                    try {
                        // load module settings
                        ModuleController modCtrl = new ModuleController();
                        int mid = Convert.ToInt32(Request.Params["mid"]);

                        ArrayList mods = modCtrl.GetModuleTabs(mid);
                        if (mods == null || mods.Count == 0) {
                            throw new Exception();
                        }

                        ModuleInfo mod = (ModuleInfo)mods[0];
                        if (mod == null || mod.ModuleID <= 0) {
                            throw new Exception();
                        }

                        FastShotSettings fsSettings = new FastShotSettings();
                        fsSettings.Load(mod.ModuleID);

                        // load templates
                        List<string> templates = new List<string>();
                        foreach (string dir in System.IO.Directory.GetDirectories(Server.MapPath(TemplateSourceDirectory + "/templates/"))) {
                            if (System.IO.Path.GetFileName(dir)[0] == '.') {
                                continue;
                            }
                            foreach (string subDir in System.IO.Directory.GetDirectories(dir)) {
                                if (System.IO.Path.GetFileName(subDir)[0] == '.') {
                                    continue;
                                }
                                templates.Add(JsonEncode(System.IO.Path.GetFileName(dir) + "/" + System.IO.Path.GetFileName(subDir)));
                            }
                        }

                        Page.ClientScript.RegisterStartupScript(GetType(), "initSettings", "avt.fs.settings = {mid: " + fsSettings.ModuleId.ToString() + ", title: '" + JsonEncode(mod.ModuleTitle) + "', template: '" + JsonEncode(fsSettings.Template) + "', thumb_w: " + fsSettings.ThumbWidth + ", thumb_h: " + fsSettings.ThumbHeight + "};", true);
                        Page.ClientScript.RegisterStartupScript(GetType(), "initTemplates", "avt.fs.templates = [\"" + string.Join("\",\"", templates.ToArray()) + "\"];", true);
                        Page.ClientScript.RegisterStartupScript(GetType(), "initReturnUrl", "avt.fs.returnUrl = \"" + DotNetNuke.Common.Globals.NavigateURL(mod.TabID) + "\";", true);
                        
                    } catch {
                        Page.ClientScript.RegisterStartupScript(GetType(), "initSettings", "avt.fs.settings = {mid: -1, title = 'Invalid Module'};", true);
                    }

                    FastShotController fsCtrl = new FastShotController();
                    if (fsCtrl.IsActivated()) {
                        btnActivate.Visible = false;
                    } else {
                        btnActivate.Attributes["onclick"] = "window.location='" + TemplateSourceDirectory + "/Activation.aspx?rurl=" + Server.UrlEncode(Request.Url.OriginalString) + "';";
                    }
                }
            }

            //AJAX.RegisterScriptManager();
            //SearchBoostController sbCtrl = new SearchBoostController();
            //PortalController portalCtrl = new PortalController();

            //// init instances
            //if (DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo().IsSuperUser) {
            //    ScriptManager.RegisterStartupScript(this, GetType(), "initInstAll", "avt.sb.inst = " + GetInstAllJson() + "; avt.sb.inst.byPortal = {};", true);
            //    foreach (PortalInfo portaInfo in portalCtrl.GetPortals()) {
            //        ScriptManager.RegisterStartupScript(this, GetType(), "initInstP" + portaInfo.PortalID.ToString(), "avt.sb.inst.byPortal[" + portaInfo.PortalID.ToString() + "] = {caption: '"+ portaInfo.PortalName +" (Id: "+ portaInfo.PortalID.ToString() +")', data: " + GetInstJson(portaInfo.PortalID) + "};", true);
            //    }
            //} else {
            //    ScriptManager.RegisterStartupScript(this, GetType(), "initInstAll", "avt.sb.inst = " + GetInstAllJson(DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().PortalId) + ";", true);
            //}

            //// init instances on current portal
            //ScriptManager.RegisterStartupScript(this, GetType(), "initInstC", "avt.sb.inst.cPortal = " + GetInstJson(DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().PortalId) + ";", true);

            //// init custom rules
            //ScriptManager.RegisterStartupScript(this, GetType(), "initSearchTargets", "avt.sb.targets = " + GetRulesJson() + ";", true);

            //// set return url
            //if (Request.UrlReferrer != null && !string.IsNullOrEmpty(Request.UrlReferrer.ToString()) && !Request.UrlReferrer.ToString().Contains("SearchBoostStudio.aspx") && !Request.UrlReferrer.ToString().Contains("/avt.SearchBoost/Activation.aspx")) {
            //    ScriptManager.RegisterStartupScript(this, GetType(), "initReturnUrl", "avt.sb.returnUrl = '" + Request.UrlReferrer.ToString() + "';", true);
            //} else {
            //    ScriptManager.RegisterStartupScript(this, GetType(), "initReturnUrl", "avt.sb.returnUrl = '" + HttpRuntime.AppDomainAppVirtualPath + "';", true);
            //}

            //// set if superuser
            //if (DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo().IsSuperUser) {
            //    ScriptManager.RegisterStartupScript(this, GetType(), "initSuperUSer", "avt.sb.isSuperUser = true;", true);
            //}

            //// check if we need to load an instance on startup
            //if (!string.IsNullOrEmpty(Request.QueryString["iinst"])) {
            //    SearchInstance searchInst = sbCtrl.GetInstance(Request.QueryString["iinst"]);
            //    if (searchInst != null) {
            //        ScriptManager.RegisterStartupScript(this, GetType(), "initCurrentInstance", "avt.sb.current = '" + Request.QueryString["iinst"] + "';", true);
            //    }
            //}

            //if (sbCtrl.IsActivated()) {
            //    btnActivate.Visible = false;
            //} else {
            //    btnActivate.Attributes["onclick"] = "window.location='" + TemplateSourceDirectory + "/Activation.aspx?rurl=" + Server.UrlEncode(Request.Url.OriginalString) + "';";
            //}
        }
Exemple #6
0
 private static void AddAllTabsModules(TabInfo tab)
 {
     var objmodules = new ModuleController();
     var portalSettings = new PortalSettings(tab.TabID, tab.PortalID);
     foreach (ModuleInfo allTabsModule in objmodules.GetAllTabsModules(tab.PortalID, true))
     {
         //[DNN-6276]We need to check that the Module is not implicitly deleted.  ie If all instances are on Pages
         //that are all "deleted" then even if the Module itself is not deleted, we would not expect the 
         //Module to be added
         var canAdd =
         (from ModuleInfo allTabsInstance in objmodules.GetModuleTabs(allTabsModule.ModuleID) select new TabController().GetTab(allTabsInstance.TabID, tab.PortalID, false)).Any(
             t => !t.IsDeleted) && (!portalSettings.ContentLocalizationEnabled || allTabsModule.CultureCode == tab.CultureCode);
         if (canAdd)
         {
             objmodules.CopyModule(allTabsModule, tab, Null.NullString, true);
         }
     }
 }
        public static TabInfo MessagingPage(string ModuleFriendlyName)
        {
            if (((_MessagingPage != null)))
            {
                return _MessagingPage;
            }

            var mc = new ModuleController();
            ModuleInfo md = mc.GetModuleByDefinition(PortalSettings.Current.PortalId, ModuleFriendlyName);
            if ((md != null))
            {
                ArrayList a = mc.GetModuleTabs(md.ModuleID);
                if ((a != null))
                {
                    var mi = a[0] as ModuleInfo;
                    if ((mi != null))
                    {
                        var tc = new TabController();
                        _MessagingPage = tc.GetTab(mi.TabID, PortalSettings.Current.PortalId, false);
                    }
                }
            }

            return _MessagingPage;
        }
        private void Delete(ModuleAction Command)
        {
            var moduleController = new ModuleController();
            var module = moduleController.GetModule(int.Parse(Command.CommandArgument), ModuleContext.TabId, true);

            //Check if this is the owner instance of a shared module.
            var user = UserController.GetCurrentUserInfo();
            var eventLogController = new EventLogController();
            if (!module.IsShared)
            {
                foreach(ModuleInfo instance in moduleController.GetModuleTabs(module.ModuleID))
                {
                    if(instance.IsShared)
                    {
                        //HARD Delete Shared Instance
                        moduleController.DeleteTabModule(instance.TabID, instance.ModuleID, false);
                        eventLogController.AddLog(instance, PortalSettings, user.UserID, "", EventLogController.EventLogType.MODULE_DELETED);
                    }
                }
            }

            moduleController.DeleteTabModule(ModuleContext.TabId, int.Parse(Command.CommandArgument), true);
            eventLogController.AddLog(module, PortalSettings, user.UserID, "", EventLogController.EventLogType.MODULE_SENT_TO_RECYCLE_BIN);

            //Redirect to the same page to pick up changes
            Response.Redirect(Request.RawUrl, true);
        }