Ejemplo n.º 1
0
        /// <summary>
        /// The DeleteBtn_Click server event handler on this page is
        /// used to delete a portal module from the page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteBtn_Click(Object sender, ImageClickEventArgs e)
        {
            string    pane     = ((ImageButton)sender).CommandArgument;
            ListBox   _listbox = (ListBox)Page.FindControl(pane);
            ArrayList modules  = GetModules(pane);

            if (_listbox.SelectedIndex != -1)
            {
                ModuleItem m = (ModuleItem)modules[_listbox.SelectedIndex];
                if (m.ID > -1)
                {
                    // [email protected] (20/08/2004) Add role control for delete module
                    if (PortalSecurity.IsInRoles(Security.PortalSecurity.GetDeleteModulePermissions(m.ID)))
                    {
                        // must delete from database too
                        ModulesDB moddb = new ModulesDB();
                        moddb.DeleteModule(m.ID);
                    }
                    else
                    {
                        msgError.Visible = true;
                        return;
                    }
                }
            }

            // Redirect to the same page to pick up changes
            Response.Redirect(Request.RawUrl);
        }
        /// <summary>
        /// Every guid module in page is set in cookie.
        /// This method is override in edit &amp; view controls for read the cookie
        /// and pass or denied access to edit or view module.
        /// [email protected] (2004/07/22)
        /// </summary>
        protected virtual void ModuleGuidInCookie()
        {
            HttpCookie cookie;
            DateTime   time;
            TimeSpan   span;
            string     guidsInUse = string.Empty;
            Guid       guid;

            ModulesDB mdb = new ModulesDB();

            if (portalSettings.ActivePage.Modules.Count > 0)
            {
                foreach (ModuleSettings ms in portalSettings.ActivePage.Modules)
                {
                    guid = mdb.GetModuleGuid(ms.ModuleID);
                    if (guid != Guid.Empty)
                    {
                        guidsInUse += guid.ToString().ToUpper() + "@";
                    }
                }
            }
            cookie         = new HttpCookie("RainbowSecurity", guidsInUse);
            time           = DateTime.Now;
            span           = new TimeSpan(0, 2, 0, 0, 0); // 120 minutes to expire
            cookie.Expires = time.Add(span);
            Response.AppendCookie(cookie);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The BindData helper method is used to update the tab's
        /// layout panes with the current configuration information
        /// </summary>
        private void BindData()
        {
            // Populate the "Add Module" Data
            ModulesDB m = new ModulesDB();

            SqlDataReader drCurrentModuleDefinitions = m.GetCurrentModuleDefinitions(portalSettings.PortalID);

            try
            {
//				if(this.ArePropertiesEditable)
//				{
//					while(drCurrentModuleDefinitions.Read())
//					{
//						moduleType.Items.Add(new ListItem(drCurrentModuleDefinitions["FriendlyName"].ToString(),drCurrentModuleDefinitions["ModuleDefID"].ToString() + "|" + GetHelpPath(drCurrentModuleDefinitions["DesktopSrc"].ToString())));
//					}
//				}
//				else
//				{
                while (drCurrentModuleDefinitions.Read())
                {
                    // Added by Mario Endara <*****@*****.**> 2004/11/04
                    // only users members of the "Amins" role can add Admin modules to a Tab
                    if (PortalSecurity.IsInRoles("Admins") == true ||
                        !(bool.Parse(drCurrentModuleDefinitions["Admin"].ToString())))
                    {
                        moduleType.Items.Add(new ListItem(drCurrentModuleDefinitions["FriendlyName"].ToString(), drCurrentModuleDefinitions["ModuleDefID"].ToString() + "|" + GetHelpPath(drCurrentModuleDefinitions["DesktopSrc"].ToString())));
                    }
                }
//				}
            }
            finally
            {
                drCurrentModuleDefinitions.Close();
            }
        }
Ejemplo n.º 4
0
        private static IModuleSettings ConvertRb_ModuleToModuleSettings(rb_Modules rbModules, AppleseedDBContext context)
        {
            var guidid    = new ModulesDB().GetModuleGuid(rbModules.ModuleID);
            var newmodule = new ModuleSettings
            {
                PageID                    = rbModules.TabID,
                ModuleID                  = rbModules.ModuleID,
                PaneName                  = rbModules.PaneName,
                ModuleTitle               = rbModules.ModuleTitle,
                AuthorizedEditRoles       = rbModules.AuthorizedEditRoles,
                AuthorizedViewRoles       = rbModules.AuthorizedViewRoles,
                AuthorizedAddRoles        = rbModules.AuthorizedAddRoles,
                AuthorizedDeleteRoles     = rbModules.AuthorizedDeleteModuleRoles,
                AuthorizedPropertiesRoles = rbModules.AuthorizedPropertiesRoles,
                CacheTime                 = rbModules.CacheTime,
                ModuleOrder               = rbModules.ModuleOrder,
                ShowMobile                = rbModules.ShowMobile != null && ((rbModules.ShowMobile == null) && (bool)rbModules.ShowMobile),
                DesktopSrc                = context.rb_GeneralModuleDefinitions.First(d => d.GeneralModDefID == guidid).DesktopSrc,
                //MobileSrc =  // not supported yet
                SupportCollapsable = rbModules.SupportCollapsable != null && (bool)rbModules.SupportCollapsable,
                ShowEveryWhere     = rbModules.ShowEveryWhere != null && (bool)rbModules.ShowEveryWhere,
                GuidID             = guidid,
            };

            return(newmodule);
        }
Ejemplo n.º 5
0
 public JsonResult edit(int id)
 {
     if ((UserProfile.isCurrentUserAdmin) || UserProfile.CurrentUser.HasPermission(AccessPermissions.MODULE_EDITING))
     {
         ModulesDB modules     = new ModulesDB();
         Guid      TabGuid     = new Guid("{1C575D94-70FC-4A83-80C3-2087F726CBB3}");
         int       TabModuleID = 0;
         foreach (ModuleItem m in modules.FindModuleItemsByGuid(PortalSettings.PortalID, TabGuid))
         {
             bool HasEditPermissionsOnTabs = PortalSecurity.HasEditPermissions(m.ID);
             if (HasEditPermissionsOnTabs)
             {
                 TabModuleID = m.ID;
                 break;
             }
         }
         string dir = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/PageLayout.aspx?PageID=" + id.ToString() +
                                              "&mID=" + TabModuleID + "&Alias=" + this.PortalSettings.PortalAlias + "&returntabid=" +
                                              this.PortalSettings.ActiveModule);
         return(Json(new { url = dir }));
     }
     else
     {
         string errorMessage = General.GetString("ACCESS_DENIED", "You don't have permissin to edit this module", this);
         return(Json(new { error = true, errorMess = errorMessage }));
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// The UpDown_Click server event handler on this page is
        /// used to move a portal module up or down on a tab's layout pane
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpDown_Click(Object sender, ImageClickEventArgs e)
        {
            string  cmd      = ((ImageButton)sender).CommandName;
            string  pane     = ((ImageButton)sender).CommandArgument;
            ListBox _listbox = (ListBox)Page.FindControl(pane);

            ArrayList modules = GetModules(pane);

            if (_listbox.SelectedIndex != -1)
            {
                int delta;
                int selection = -1;

                // Determine the delta to apply in the order number for the module
                // within the list.  +3 moves down one item; -3 moves up one item
                if (cmd == "down")
                {
                    delta = 3;
                    if (_listbox.SelectedIndex < _listbox.Items.Count - 1)
                    {
                        selection = _listbox.SelectedIndex + 1;
                    }
                }
                else
                {
                    delta = -3;
                    if (_listbox.SelectedIndex > 0)
                    {
                        selection = _listbox.SelectedIndex - 1;
                    }
                }

                ModuleItem m;
                m = (ModuleItem)modules[_listbox.SelectedIndex];

                if (PortalSecurity.IsInRoles(Security.PortalSecurity.GetMoveModulePermissions(m.ID)))
                {
                    m.Order += delta;

                    // reorder the modules in the content pane
                    OrderModules(modules);

                    // resave the order
                    ModulesDB admin = new ModulesDB();
                    foreach (ModuleItem item in modules)
                    {
                        admin.UpdateModuleOrder(item.ID, item.Order, pane);
                    }

                    // Redirect to the same page to pick up changes
                    Response.Redirect(AppendModuleID(Request.RawUrl, m.ID));
                }
                else
                {
                    msgError.Visible = true;
                    return;
                }
            }
        }
Ejemplo n.º 7
0
        protected void AddModuleToPane_Click(object sender, EventArgs e)
        {
            // All new modules go to the end of the content pane
            var m = new ModuleItem();

            m.Title       = this.moduleTitle.Text;
            m.ModuleDefID = Int32.Parse(this.moduleType.SelectedItem.Value);
            m.Order       = 999;

            // save to database
            var mod = new ModulesDB();

            // Change by [email protected]
            // Date: 6/2/2003
            // Original:             m.ID = _mod.AddModule(tabID, m.Order, "ContentPane", m.Title, m.ModuleDefID, 0, "Admins", "All Users", "Admins", "Admins", "Admins", false);
            // Changed by Mario Endara <*****@*****.**> (2004/11/09)
            // The new module inherits security from Pages module (current ModuleID)
            // so who can edit the tab properties/content can edit the module properties/content (except view that remains =)
            m.ID = mod.AddModule(
                this.PageID,
                m.Order,
                this.paneLocation.SelectedItem.Value,
                m.Title,
                m.ModuleDefID,
                0,
                PortalSecurity.GetEditPermissions(this.ModuleID),
                this.viewPermissions.SelectedItem.Value,
                PortalSecurity.GetAddPermissions(this.ModuleID),
                PortalSecurity.GetDeletePermissions(this.ModuleID),
                PortalSecurity.GetPropertiesPermissions(this.ModuleID),
                PortalSecurity.GetMoveModulePermissions(this.ModuleID),
                PortalSecurity.GetDeleteModulePermissions(this.ModuleID),
                false,
                PortalSecurity.GetPublishPermissions(this.ModuleID),
                false,
                false,
                false);

            // End Change [email protected]

            // reload the portalSettings from the database
            this.Context.Items["PortalSettings"] = PortalSettings.GetPortalSettings(this.PageID, this.PortalSettings.PortalAlias);
            this.PortalSettings = (PortalSettings)this.Context.Items["PortalSettings"];

            // reorder the modules in the content pane
            var modules = this.GetModules("ContentPane");

            this.OrderModules(modules);

            // resave the order
            foreach (ModuleItem item in modules)
            {
                mod.UpdateModuleOrder(item.ID, item.Order, "ContentPane");
            }

            // Redirect to the same page to pick up changes
            this.Response.Redirect(this.AppendModuleID(this.Request.RawUrl, m.ID));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// The RightLeft_Click server event handler on this page is
        /// used to move a portal module between layout panes on
        /// the tab page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RightLeft_Click(Object sender, ImageClickEventArgs e)
        {
            string  sourcePane = ((ImageButton)sender).Attributes["sourcepane"];
            string  targetPane = ((ImageButton)sender).Attributes["targetpane"];
            ListBox sourceBox  = (ListBox)Page.FindControl(sourcePane);
            ListBox targetBox  = (ListBox)Page.FindControl(targetPane);

            if (sourceBox.SelectedIndex != -1)
            {
                // get source arraylist
                ArrayList sourceList = GetModules(sourcePane);

                // get a reference to the module to move
                // and assign a high order number to send it to the end of the target list
                ModuleItem m = (ModuleItem)sourceList[sourceBox.SelectedIndex];

                if (PortalSecurity.IsInRoles(Security.PortalSecurity.GetMoveModulePermissions(m.ID)))
                {
                    // add it to the database
                    ModulesDB admin = new ModulesDB();
                    admin.UpdateModuleOrder(m.ID, 99, targetPane);

                    // delete it from the source list
                    sourceList.RemoveAt(sourceBox.SelectedIndex);

                    // reload the portalSettings from the database
                    HttpContext.Current.Items["PortalSettings"] = new PortalSettings(TabID, portalSettings.PortalAlias);
                    portalSettings = (PortalSettings)Context.Items["PortalSettings"];

                    // reorder the modules in the source pane
                    sourceList = GetModules(sourcePane);
                    OrderModules(sourceList);

                    // resave the order
                    foreach (ModuleItem item in sourceList)
                    {
                        admin.UpdateModuleOrder(item.ID, item.Order, sourcePane);
                    }

                    // reorder the modules in the target pane
                    ArrayList targetList = GetModules(targetPane);
                    OrderModules(targetList);

                    // resave the order
                    foreach (ModuleItem item in targetList)
                    {
                        admin.UpdateModuleOrder(item.ID, item.Order, targetPane);
                    }

                    // Redirect to the same page to pick up changes
                    Response.Redirect(AppendModuleID(Request.RawUrl, m.ID));
                }
                else
                {
                    msgError.Visible = true;
                }
            }
        }
Ejemplo n.º 9
0
        public JsonResult RightLeft_Click(string sourcePane, string targetPane, string pageId, string selectedIndex)
        {
            // get source arraylist
            var sourceList = this.GetModules(sourcePane, Int32.Parse(pageId));

            var index = Int32.Parse(selectedIndex);
            // get a reference to the module to move
            // and assign a high order number to send it to the end of the target list
            var m = (ModuleItem)sourceList[index];

            if (PortalSecurity.IsInRoles(PortalSecurity.GetMoveModulePermissions(m.ID)))
            {
                // add it to the database
                var admin = new ModulesDB();
                admin.UpdateModuleOrder(m.ID, 99, targetPane);

                // delete it from the source list
                sourceList.RemoveAt(index);

                // reorder the modules in the source pane
                sourceList = this.GetModules(sourcePane, Int32.Parse(pageId));
                var list = this.OrderModules(sourceList);

                // resave the order
                foreach (ModuleItem item in sourceList)
                {
                    admin.UpdateModuleOrder(item.ID, item.Order, sourcePane);
                }

                // reorder the modules in the target pane
                var targetList = this.GetModules(targetPane, Int32.Parse(pageId));
                var list2      = this.OrderModules(targetList);

                // resave the order
                foreach (ModuleItem item in targetList)
                {
                    admin.UpdateModuleOrder(item.ID, item.Order, targetPane);
                }

                StringBuilder ls = new StringBuilder();
                foreach (ModuleItem md in list)
                {
                    ls.AppendFormat("<option value=\"{0}\">{1}</option>", md.ID, md.Title);
                }

                StringBuilder sb = new StringBuilder();
                foreach (ModuleItem md in list2)
                {
                    sb.AppendFormat("<option value=\"{0}\">{1}</option>", md.ID, md.Title);
                }

                return(Json(new { error = false, source = ls.ToString(), target = sb.ToString() }));
            }
            else
            {
                return(Json(new { error = true }));
            }
        }
        /// <summary>
        /// The DeleteModuleButton_Click server event handler on this page is
        /// used to delete a portal module
        /// This method is copied directly from PortalModuleControl (exists in
        /// both places!! ugh.)
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void DeleteModuleButton_Click(Object sender, EventArgs e)
        {
            ModulesDB admin = new ModulesDB();

            //admin.DeleteModule(sender.ToString());
            Response.Write("Sending module is " + sender.ToString());
            // Redirect to the same page to pick up changes
            Page.Response.Redirect(Page.Request.RawUrl);
        }
Ejemplo n.º 11
0
        // Methods
        #region Public Methods

        /// <summary>
        /// Adds the MVC action module.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="actionPath">The action path.</param>
        /// <returns></returns>
        public static Guid AddMVCActionModule(string name, string actionPath)
        {
            var sdb             = new ModulesDB();
            var generalModDefId = Guid.NewGuid();

            sdb.AddGeneralModuleDefinitions(
                generalModDefId, name, actionPath, string.Empty, string.Empty, string.Empty, false, false);
            return(generalModDefId);
        }
        /// <summary>
        /// Public constructor. Sets base settings for module.
        /// </summary>
        public Tasks()
        {
            // Set Editor Settings [email protected] 2004/07/30
            HtmlEditorDataType.HtmlEditorSettings(_baseSettings, SettingItemGroup.MODULE_SPECIAL_SETTINGS);

            SettingItem setSortField =
                new SettingItem(new ListDataType("Title;Status;Priority;DueDate;AssignedTo;PercentComplete"));

            setSortField.Group    = SettingItemGroup.MODULE_SPECIAL_SETTINGS;
            setSortField.Required = true;
            setSortField.Value    = "DueDate";
            _baseSettings.Add("TASKS_SORT_FIELD", setSortField);

            SettingItem defaultAssignee = new SettingItem(new StringDataType());

            defaultAssignee.Group       = SettingItemGroup.MODULE_SPECIAL_SETTINGS;
            defaultAssignee.Value       = "nobody";
            defaultAssignee.EnglishName = "Default Assignee";
            defaultAssignee.Description = "Is the name of the person which the task is automatically assigned.";
            _baseSettings.Add("TASKS_DEFAULT_ASSIGNEE", defaultAssignee);

            // Task modules list
            ModulesDB     m = new ModulesDB();
            ArrayList     taskModulesListOptions = new ArrayList();
            SqlDataReader r = null;

            try
            {
                r = m.GetModulesByName("Tasks", portalSettings.PortalID);
                while (r.Read())
                {
                    taskModulesListOptions.Add(
                        new SettingOption(int.Parse(r["ModuleID"].ToString()), r["ModuleTitle"].ToString()));
                }
            }
            catch //install time
            {
            }
            finally
            {
                if (r != null && r.IsClosed == false)
                {
                    r.Close();
                }
            }

            SettingItem linkedModules =
                new SettingItem(new MultiSelectListDataType(taskModulesListOptions, "Name", "Val"));

            linkedModules.Group       = SettingItemGroup.MODULE_SPECIAL_SETTINGS;
            linkedModules.Value       = "0";
            linkedModules.EnglishName = "Linked Modules";
            linkedModules.Description =
                "Chose here any module that will automatically recieve a copy of all new assigned task.";
            _baseSettings.Add("TASKS_LINKED_MODULES", linkedModules);
        }
Ejemplo n.º 13
0
        public JsonResult UpDown_Click(string cmd, string pane, string pageId, string selectedIndex, string length)
        {
            var modules = this.GetModules(pane, Int32.Parse(pageId));
            int delta;
            var selection = -1;
            var index     = Int32.Parse(selectedIndex);

            // Determine the delta to apply in the order number for the module
            // within the list.  +3 moves down one item; -3 moves up one item
            if (cmd == "down")
            {
                delta = 3;
                if (index < Int32.Parse(length) - 1)
                {
                    selection = index + 1;
                }
            }
            else
            {
                delta = -3;
                if (index > 0)
                {
                    selection = index - 1;
                }
            }

            ModuleItem m;

            m = (ModuleItem)modules[index];

            if (PortalSecurity.IsInRoles(PortalSecurity.GetMoveModulePermissions(m.ID)))
            {
                m.Order += delta;

                // reorder the modules in the content pane
                var list = this.OrderModules(modules);

                // resave the order
                var admin = new ModulesDB();
                foreach (ModuleItem item in modules)
                {
                    admin.UpdateModuleOrder(item.ID, item.Order, pane);
                }

                StringBuilder ls = new StringBuilder();
                foreach (ModuleItem md in list)
                {
                    ls.AppendFormat("<option value=\"{0}\">{1}</option>", md.ID, md.Title);
                }
                return(Json(new { value = ls.ToString() }));
            }
            else
            {
                return(Json(new { value = "error" }));
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// OnUpdate installs or refresh module definiton on db
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnUpdate(EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    if (!btnUseInstaller.Visible)
                    {
                        ModuleInstall.InstallGroup(Server.MapPath(Path.ApplicationRoot + "/" + InstallerFileName.Text),
                                                   lblGUID.Text == string.Empty);
                    }
                    else
                    {
                        ModuleInstall.Install(FriendlyName.Text, DesktopSrc.Text, MobileSrc.Text,
                                              lblGUID.Text == string.Empty);
                    }

                    ModulesDB modules = new ModulesDB();

                    // Update the module definition
                    for (int i = 0; i < PortalsName.Items.Count; i++)
                    {
                        modules.UpdateModuleDefinitions(defID, Convert.ToInt32(PortalsName.Items[i].Value),
                                                        PortalsName.Items[i].Selected);
                    }

                    // Redirect back to the portal admin page
                    RedirectBackToReferringPage();
                }
                catch (ThreadAbortException)
                {
                    //normal with redirect
                }
                catch (Exception ex)
                {
                    lblErrorDetail.Text =
                        General.GetString("MODULE_DEFINITIONS_INSTALLING", "An error occurred installing.", this) +
                        "<br>";
                    lblErrorDetail.Text += ex.Message + "<br>";
                    if (!btnUseInstaller.Visible)
                    {
                        lblErrorDetail.Text += " Installer: " +
                                               Server.MapPath(Path.ApplicationRoot + "/" + InstallerFileName.Text);
                    }
                    else
                    {
                        lblErrorDetail.Text += " Module: '" + FriendlyName.Text + "' - Source: '" + DesktopSrc.Text +
                                               "' - Mobile: '" + MobileSrc.Text + "'";
                    }
                    lblErrorDetail.Visible = true;

                    ErrorHandler.Publish(LogLevel.Error, lblErrorDetail.Text, ex);
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// The AddModule_Click server event handler
        /// on this page is used to add a new portal module
        /// into the tab
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddModule_Click(Object sender, EventArgs e)
        {
            if (this.TabID != 0)
            {
                // All new modules go to the end of the contentpane
                string selectedModule = moduleType.SelectedItem.Value.ToString();
                int    start          = selectedModule.IndexOf("|");
                int    moduleID       = Convert.ToInt32(selectedModule.Substring(0, start).Trim());

                // Hide error message in case there was a previous error.
                moduleError.Visible = false;

                // This allows the user to pick what type of people can view the module being added.
                // If Authorised Roles is selected from the dropdown then every role that has view permission for the
                // Add Role module will be added to the view permissions of the module being added.
                string viewPermissionRoles = viewPermissions.SelectedValue.ToString();
                if (viewPermissionRoles == "Authorised Roles")
                {
                    viewPermissionRoles = Rainbow.Security.PortalSecurity.GetViewPermissions(this.ModuleID);
                }

                try
                {
                    ModuleItem m = new ModuleItem();
                    m.Title       = moduleTitle.Text;
                    m.ModuleDefID = moduleID;
                    m.Order       = 999;

                    // save to database
                    ModulesDB _mod = new ModulesDB();
                    m.ID = _mod.AddModule(TabID, m.Order, paneLocation.SelectedValue.ToString(), m.Title, m.ModuleDefID, 0, Rainbow.Security.PortalSecurity.GetEditPermissions(this.ModuleID), viewPermissionRoles, Rainbow.Security.PortalSecurity.GetAddPermissions(this.ModuleID), Rainbow.Security.PortalSecurity.GetDeletePermissions(this.ModuleID), Rainbow.Security.PortalSecurity.GetPropertiesPermissions(this.ModuleID), Rainbow.Security.PortalSecurity.GetMoveModulePermissions(this.ModuleID), Rainbow.Security.PortalSecurity.GetDeleteModulePermissions(this.ModuleID), false, Rainbow.Security.PortalSecurity.GetPublishPermissions(this.ModuleID), false, false, false);
                }
                catch (Exception ex)
                {
                    moduleError.Visible = true;
                    Rainbow.Configuration.ErrorHandler.HandleException("There was an error with the Add Module Module while trying to add a new module.", ex);
                }
                finally
                {
                    if (moduleError.Visible == false)
                    {
                        // Reload page to pick up changes
                        Response.Redirect(Request.RawUrl, false);
                    }
                }
            }
            else
            {
                moduleError.TextKey = "ADDMODULE_HOMEPAGEERROR";
                moduleError.Text    = "You are currently on the homepage using the default virtual ID (The default ID is set when no specific page is selected. e.g. www.yourdomain.com. Please select your homepage from the Navigation menu e.g. 'Home' so that you can add a module against the page's actual ID.";
                moduleError.Visible = true;
            }
        }
Ejemplo n.º 16
0
        private string giveMeFriendlyName(Guid guid)
        {
            string friendlyName = string.Empty;

            using (SqlDataReader auxDr = new ModulesDB().GetSingleModuleDefinition(guid)) {
                if (auxDr.Read())
                {
                    friendlyName = auxDr["FriendlyName"] as string;
                }
            }
            return(friendlyName);
        }
        /// <summary>
        /// Handles OnDelete
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnDelete(EventArgs e)
        {
            base.OnDelete(e);

            ModulesDB modules = new ModulesDB();

            // TODO add userEmail and useRecycler
            modules.DeleteModule(_moduleID);

            _moduleID = 0;

            RedirectBackToReferringPage();
        }
 /// <summary>
 /// Productses the specified tab.
 /// </summary>
 /// <param name="tab">The tab.</param>
 /// <returns></returns>
 private bool products(int tab)
 {
     if (!AutoShopDetect)
     {
         return(false);
     }
     if (!CurrentCache.Exists(Key.TabNavigationSettings(tab, "Shop")))
     {
         PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
         bool           exists         = new ModulesDB().ExistModuleProductsInPage(tab, portalSettings.PortalID);
         CurrentCache.Insert(Key.TabNavigationSettings(tab, "Shop"), exists);
     }
     return((bool)CurrentCache.Get(Key.TabNavigationSettings(tab, "Shop")));
 }
Ejemplo n.º 19
0
        /// <summary>
        /// The BindData helper method is used to bind the list of
        /// module definitions for this portal to an asp:datalist server control
        /// </summary>
        protected void BindData()
        {
            // Get the portal's defs from the database
            SqlDataReader dr = new ModulesDB().GetCurrentModuleDefinitions(this.PortalSettings.PortalID);

            DataTable userTable = new DataTable();

            userTable.Columns.Add(new DataColumn("FriendlyName", typeof(string)));
            userTable.Columns.Add(new DataColumn("ModuleDefID", typeof(string)));

            DataTable adminTable = new DataTable();

            adminTable.Columns.Add(new DataColumn("FriendlyName", typeof(string)));
            adminTable.Columns.Add(new DataColumn("ModuleDefID", typeof(string)));

            DataRow drow;

            while (dr.Read())
            {
                if (bool.Parse(dr["Admin"].ToString()))
                {
                    drow = adminTable.NewRow();
                    drow["ModuleDefID"] = dr["ModuleDefID"];
                    string aux = dr["FriendlyName"].ToString();
                    if (aux.StartsWith("Admin"))
                    {
                        aux = aux.Substring(5);
                        while (aux[0] == ' ' || aux[0] == '-')
                        {
                            aux = aux.Substring(1);
                        }
                    }
                    drow["FriendlyName"] = aux;
                    adminTable.Rows.Add(drow);
                }
                else
                {
                    drow = userTable.NewRow();
                    drow["ModuleDefID"]  = dr["ModuleDefID"];
                    drow["FriendlyName"] = dr["FriendlyName"];
                    userTable.Rows.Add(drow);
                }
            }
            userModules.DataSource = userTable;
            userModules.DataBind();
            adminModules.DataSource = adminTable;
            adminModules.DataBind();
            dr.Close();
        }
Ejemplo n.º 20
0
        /// <summary>
        /// The BindData helper method is used to update the tab's
        ///   layout panes with the current configuration information
        /// </summary>
        /// <remarks>
        /// </remarks>
        private void BindData()
        {
            // Populate the "Add Module" Data
            var m = new ModulesDB();

            var drCurrentModuleDefinitions = m.GetCurrentModuleDefinitions(this.PortalSettings.PortalID);

            try
            {
                //              if(this.ArePropertiesEditable)
                //              {
                //                  while(drCurrentModuleDefinitions.Read())
                //                  {
                //                      moduleType.Items.Add(new ListItem(drCurrentModuleDefinitions["FriendlyName"].ToString(),drCurrentModuleDefinitions["ModuleDefID"].ToString() + "|" + GetHelpPath(drCurrentModuleDefinitions["DesktopSrc"].ToString())));
                //                  }
                //              }
                //              else
                //              {
                while (drCurrentModuleDefinitions.Read())
                {
                    // Added by Mario Endara <*****@*****.**> 2004/11/04
                    // only users members of the "Amins" role can add Admin modules to a Tab
                    if (PortalSecurity.IsInRoles("Admins") ||
                        !bool.Parse(drCurrentModuleDefinitions["Admin"].ToString()))
                    {
                        this.moduleType.Items.Add(
                            new ListItem(
                                drCurrentModuleDefinitions["FriendlyName"].ToString(),
                                string.Format(
                                    "{0}|{1}",
                                    drCurrentModuleDefinitions["ModuleDefID"],
                                    GetHelpPath(drCurrentModuleDefinitions["DesktopSrc"].ToString()))));

                        var actions = ModelServices.GetMVCActionModules();
                        foreach (var key in actions.Keys)
                        {
                            this.moduleType.Items.Add(new ListItem(key, actions[key]));
                        }
                    }
                }

                //              }
            }
            finally
            {
                drCurrentModuleDefinitions.Close();
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Registers the portable area module.
        /// </summary>
        /// <param name="areaName">Name of the area.</param>
        /// <param name="controllerName">Name of the controller</param>
        /// <param name="assemblyFullName">Full name of the assembly.</param>
        /// <returns>mid</returns>
        public static Guid RegisterPortableAreaModule(string areaName, string assemblyFullName, string controllerName)
        {
            Guid mId;
            var  sdb          = new ModulesDB();
            var  friendlyName = String.Format("{0} - {1}", areaName, controllerName);

            try {
                mId = sdb.GetGeneralModuleDefinitionByName(friendlyName);
            }
            catch (ArgumentException) {
                // No existe el módulo, entonces lo creo
                mId = AddPortableArea(areaName, assemblyFullName, controllerName, friendlyName, sdb, "Module");
            }

            return(mId);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// The reorder.
        /// </summary>
        /// <param name="modulesByPane">
        /// The modules by pane.
        /// </param>
        public static void Reorder(Dictionary <string, ArrayList> modulesByPane)
        {
            // var settings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
            // var pageId = settings.ActivePage.PageID;
            var sdb = new ModulesDB();

            foreach (var str in modulesByPane.Keys)
            {
                var list        = modulesByPane[str];
                var moduleOrder = 0;
                foreach (int num3 in list)
                {
                    sdb.UpdateModuleOrder(num3, moduleOrder, str);
                    moduleOrder++;
                }
            }
        }
        /// <summary>
        /// OnUpdate installs or refresh module definition on db
        /// </summary>
        /// <param name="e">
        /// The <see cref="T:System.EventArgs"/> instance containing the event data.
        /// </param>
        protected override void OnUpdate(EventArgs e)
        {
            if (this.Page.IsValid)
            {
                try
                {
                    var modules = new ModulesDB();
                    modules.AddGeneralModuleDefinitions(
                        new Guid(this.ModuleGuid.Text),
                        this.FriendlyName.Text,
                        this.DesktopSrc.Text,
                        this.MobileSrc.Text,
                        "Appleseed.Modules.OneFileModule.dll",
                        "Appleseed.Content.Web.ModulesOneFileModule",
                        false,
                        false);

                    // Update the module definition
                    for (var i = 0; i < this.PortalsName.Items.Count; i++)
                    {
                        modules.UpdateModuleDefinitions(
                            this.defId,
                            Convert.ToInt32(this.PortalsName.Items[i].Value),
                            this.PortalsName.Items[i].Selected);
                    }

                    // Redirect back to the portal admin page
                    this.RedirectBackToReferringPage();
                }
                catch (ThreadAbortException)
                {
                    // normal with redirect
                }
                catch (Exception ex)
                {
                    this.lblErrorDetail.Text =
                        string.Format("{0}<br />", General.GetString("MODULE_DEFINITIONS_INSTALLING", "An error occurred installing.", this));
                    this.lblErrorDetail.Text   += string.Format("{0}<br />", ex.Message);
                    this.lblErrorDetail.Text   += string.Format(" Module: '{0}' - Source: '{1}' - Mobile: '{2}'", this.FriendlyName.Text, this.DesktopSrc.Text, this.MobileSrc.Text);
                    this.lblErrorDetail.Visible = true;

                    ErrorHandler.Publish(LogLevel.Error, this.lblErrorDetail.Text, ex);
                }
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleDefId"></param>
        /// <param name="pageId"></param>
        /// <param name="title"></param>
        /// <param name="alsoIfExists"></param>
        /// <returns></returns>
        public static int AddModuleToPage(int moduleDefId, int pageId, string title, bool alsoIfExists)
        {
            var module = default(rb_Modules);

            using (var context = new AppleseedDBContext()) {
                module = context.rb_Modules.Where(d => d.TabID == pageId && d.ModuleDefID == moduleDefId).FirstOrDefault();
            }

            if (module == default(rb_Modules) || alsoIfExists)
            {
                var sdb = new ModulesDB();
                return(sdb.AddModule(pageId, 0, "ContentPane", title, moduleDefId, 0, "Admins", "All Users", "Admins", "Admins", "Admins", "Admins", "Admins", false, string.Empty, true, false, false));
            }
            else
            {
                return(module.ModuleID);
            }
        }
        /// <summary>
        /// OnUpdate installs or refresh module definiton on db
        /// </summary>
        /// <param name="e"></param>
        protected override void OnUpdate(EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    if (!btnUseInstaller.Visible)
                    {
                        Rainbow.Helpers.ModuleInstall.InstallGroup(Server.MapPath(Rainbow.Settings.Path.ApplicationRoot + "/" + InstallerFileName.Text), lblGUID.Text == string.Empty);
                    }
                    else
                    {
                        Rainbow.Helpers.ModuleInstall.Install(FriendlyName.Text, DesktopSrc.Text, MobileSrc.Text, lblGUID.Text == string.Empty);
                    }

                    ModulesDB modules = new ModulesDB();

                    // Update the module definition
                    for (int i = 0; i < PortalsName.Items.Count; i++)
                    {
                        modules.UpdateModuleDefinitions(defID, Convert.ToInt32(PortalsName.Items[i].Value), (bool)PortalsName.Items[i].Selected);
                    }

                    // Redirect back to the portal admin page
                    RedirectBackToReferringPage();
                }
                catch (Exception ex)
                {
                    lblErrorDetail.Text = Esperantus.Localize.GetString("MODULE_DEFINITIONS_INSTALLING", "An error occurred installing.", this) + "<br>";
                    if (!btnUseInstaller.Visible)
                    {
                        lblErrorDetail.Text += " Installer: " + Server.MapPath(Rainbow.Settings.Path.ApplicationRoot + "/" + InstallerFileName.Text);
                    }
                    else
                    {
                        lblErrorDetail.Text += " Module: '" + FriendlyName.Text + "' - Source: '" + DesktopSrc.Text + "' - Mobile: '" + MobileSrc.Text + "'";
                    }
                    lblErrorDetail.Visible = true;

                    Rainbow.Configuration.ErrorHandler.HandleException(lblErrorDetail.Text, ex);
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// This method override the security cookie for allow
        /// to access property pages of selected module in tab.
        /// [email protected] (2004/07/23)
        /// </summary>
        private void SetSecurityAccess()
        {
            HttpCookie cookie;
            DateTime   time;
            TimeSpan   span;
            string     guidsInUse = string.Empty;
            Guid       guid;

            ModulesDB mdb = new ModulesDB();

            foreach (ListItem li in leftPane.Items)
            {
                guid = mdb.GetModuleGuid(int.Parse(li.Value));
                if (guid != Guid.Empty)
                {
                    guidsInUse += guid.ToString().ToUpper() + "@";
                }
            }

            foreach (ListItem li in contentPane.Items)
            {
                guid = mdb.GetModuleGuid(int.Parse(li.Value));
                if (guid != Guid.Empty)
                {
                    guidsInUse += guid.ToString().ToUpper() + "@";
                }
            }

            foreach (ListItem li in rightPane.Items)
            {
                guid = mdb.GetModuleGuid(int.Parse(li.Value));
                if (guid != Guid.Empty)
                {
                    guidsInUse += guid.ToString().ToUpper() + "@";
                }
            }

            cookie         = new HttpCookie("RainbowSecurity", guidsInUse);
            time           = DateTime.Now;
            span           = new TimeSpan(0, 2, 0, 0, 0);    // 120 minutes to expire
            cookie.Expires = time.Add(span);
            base.Response.AppendCookie(cookie);
        }
Ejemplo n.º 27
0
        public JsonResult DeleteBtn_Click(string pane, string pageId, string selectedIndex)
        {
            var modules = this.GetModules(pane, Int32.Parse(pageId));
            var index   = Int32.Parse(selectedIndex);

            var m = (ModuleItem)modules[index];

            if (m.ID > -1)
            {
                // [email protected] (20/08/2004) Add role control for delete module
                if (PortalSecurity.IsInRoles(PortalSecurity.GetDeleteModulePermissions(m.ID)))
                {
                    // must delete from database too
                    var moddb = new ModulesDB();

                    // TODO add userEmail and useRecycler
                    moddb.DeleteModule(m.ID);

                    // reorder the modules in the pane
                    modules = this.GetModules(pane, Int32.Parse(pageId));
                    var list = this.OrderModules(modules);

                    // resave the order
                    foreach (ModuleItem item in modules)
                    {
                        moddb.UpdateModuleOrder(item.ID, item.Order, pane);
                    }

                    StringBuilder ls = new StringBuilder();
                    foreach (ModuleItem md in list)
                    {
                        ls.AppendFormat("<option value=\"{0}\">{1}</option>", md.ID, md.Title);
                    }
                    return(Json(new { error = false, value = ls.ToString() }));
                }
                else
                {
                    return(Json(new { error = true }));
                }
            }
            return(Json(new { error = true }));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Handles OnDelete
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnDelete(EventArgs e)
        {
            base.OnDelete(e);
            if (this._moduleID > 0)
            {
                ModulesDB modules = new ModulesDB();
                // TODO add userEmail and useRecycler
                modules.DeleteModule(_moduleID);

                _moduleID = 0;
            }

            if (this._pageID > 0)
            {
                var tabs = new PagesDB();
                tabs.DeletePage(this._pageID);
            }

            RedirectBackToReferringPage();
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var modules = new ModulesDB();

            // If this is the first visit to the page, bind the definition data
            if (this.Page.IsPostBack)
            {
                this.addModule = bool.Parse(this.ViewState["addModule"].ToString());
            }
            else
            {
                this.ViewState["addModule"] = this.addModule;
                if (this.addModule)
                {
                    this.DeleteButton.Visible = false;
                }
                else
                {
                    // Obtain the module definition to edit from the database
                    var def = modules.GetSingleModuleDefinition(this.defId);

                    // WLF: Set UI values
                    this.FriendlyName.Text  = def.FriendlyName;
                    this.DesktopSrc.Text    = def.DesktopSource;
                    this.MobileSrc.Text     = def.MobileSource;
                    this.ModuleGuid.Text    = def.GeneralModDefID.ToString();
                    this.ModuleGuid.Enabled = false;
                }

                // Clear existing items in checkbox list
                this.PortalsName.Items.Clear();

                // Populate checkbox list with all portals
                // and "check" the ones already configured for this tab
                var portals = modules.GetModuleInUse(this.defId).ToArray();
                this.PortalsName.Items.AddRange(portals);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// OnUpdate installs or refresh module definiton on db
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnUpdate(EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    ModulesDB modules = new ModulesDB();
                    modules.AddGeneralModuleDefinitions(new Guid(ModuleGuid.Text), FriendlyName.Text, DesktopSrc.Text,
                                                        MobileSrc.Text,
                                                        "Rainbow.Modules.OneFileModule.dll",
                                                        "Rainbow.Content.Web.ModulesOneFileModule", false, false);

                    // Update the module definition
                    for (int i = 0; i < PortalsName.Items.Count; i++)
                    {
                        modules.UpdateModuleDefinitions(defID, Convert.ToInt32(PortalsName.Items[i].Value),
                                                        PortalsName.Items[i].Selected);
                    }

                    // Redirect back to the portal admin page
                    RedirectBackToReferringPage();
                }
                catch (ThreadAbortException)
                {
                    //normal with redirect
                }
                catch (Exception ex)
                {
                    lblErrorDetail.Text =
                        General.GetString("MODULE_DEFINITIONS_INSTALLING", "An error occurred installing.", this) +
                        "<br>";
                    lblErrorDetail.Text += ex.Message + "<br>";
                    lblErrorDetail.Text += " Module: '" + FriendlyName.Text + "' - Source: '" + DesktopSrc.Text +
                                           "' - Mobile: '" + MobileSrc.Text + "'";
                    lblErrorDetail.Visible = true;

                    ErrorHandler.Publish(LogLevel.Error, lblErrorDetail.Text, ex);
                }
            }
        }