コード例 #1
0
        public ActionResult marketing(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the default admin language id
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Add data to the form
            ViewBag.Domain = Domain.GetOneById(id);
            ViewBag.MarketingFiles = GetMarketingFiles(id);
            ViewBag.TranslatedTexts = StaticText.GetAll(adminLanguageId, "id", "ASC");
            ViewBag.ReturnUrl = returnUrl;

            // Redirect the user to index page if the domain is null
            if(ViewBag.Domain == null)
            {
                return Redirect("/admin_domains" + returnUrl);
            }

            // Return the view
            return View("marketing");

        } // End of the marketing method
コード例 #2
0
        public ActionResult edit(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the default admin language
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Add data to the view
            ViewBag.TranslatedTexts = StaticText.GetAll(adminLanguageId, "id", "ASC");
            ViewBag.ValueAddedTax = ValueAddedTax.GetOneById(id);
            ViewBag.ReturnUrl = returnUrl;

            // Create a new empty value added tax post if the value added taxt post does not exist
            if (ViewBag.ValueAddedTax == null)
            {
                // Add data to the view
                ViewBag.ValueAddedTax = new ValueAddedTax();
            }

            // Return the edit view
            return View("edit");

        } // End of the edit method
コード例 #3
0
        public ActionResult delete(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Create an error code variable
            Int32 errorCode = 0;

            // Delete the value added tax post and all the connected posts (CASCADE)
            errorCode = ValueAddedTax.DeleteOnId(id);

            // Check if there is an error
            if (errorCode != 0)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = errorCode;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }

            // Redirect the user to the list
            return Redirect("/admin_value_added_taxes" + returnUrl);

        } // End of the delete method
コード例 #4
0
        public ActionResult error(string id = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();

            // Set the connection id
            byte connectionId = 2;
            if (id == "invalid-input")
            {
                connectionId = 3;
            }
            else if (id == "404")
            {
                connectionId = 4;
            }            
            else
            {
                id = "general";
            }
               
            // Get the error page
            StaticPage staticPage = StaticPage.GetOneByConnectionId(connectionId, currentDomain.front_end_language);
            staticPage = staticPage != null ? staticPage : new StaticPage();

            // Get the translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");

            // Create the bread crumb list
            List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(2);
            breadCrumbs.Add(new BreadCrumb(tt.Get("start_page"), "/"));
            breadCrumbs.Add(new BreadCrumb(staticPage.link_name, "/home/error/" + id.ToString()));

            // Set form values
            ViewBag.BreadCrumbs = breadCrumbs;
            ViewBag.CurrentCategory = new Category();
            ViewBag.TranslatedTexts = tt;
            ViewBag.CurrentDomain = currentDomain;
            ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
            ViewBag.StaticPage = staticPage;
            ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

            // Return the view
            return currentDomain.custom_theme_id == 0 ? View() : View("/Views/theme/error.cshtml");

        } // End of the error method
コード例 #5
0
        public ActionResult edit(string id = "", string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();

            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession    = true;
                ViewBag.AdminErrorCode  = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return(View("index"));
            }
            else
            {
                // Redirect the user to the start page
                return(RedirectToAction("index", "admin_login"));
            }

            // Add data to the view
            ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
            ViewBag.Languages       = Language.GetAll(currentDomain.back_end_language, "name", "ASC");
            ViewBag.GiftCard        = GiftCard.GetOneById(id);
            ViewBag.ReturnUrl       = returnUrl;

            // Create a new empty gift card post if the gift card does not exist
            if (ViewBag.GiftCard == null)
            {
                // Add data to the view
                ViewBag.GiftCard = new GiftCard();
            }

            // Return the edit view
            return(View("edit"));
        } // End of the edit method
コード例 #6
0
        public ActionResult sitemap(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get form values 
            Int32 domainId = Convert.ToInt32(collection["hiddenDomainId"]);
            string priorityCategories = collection["selectPriorityCategories"];
            string priorityProducts = collection["selectPriorityProducts"];
            string changeFrequency = collection["selectChangeFrequency"];

            // Get the domain
            Domain domain = Domain.GetOneById(domainId);

            // Update the sitemap
            SitemapManager.CreateSitemap(domain, priorityCategories, priorityProducts, changeFrequency);

            // Redirect the user to the list
            return Redirect(returnUrl);

        } // End of the sitemap method
コード例 #7
0
        public ActionResult log_in_as(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get webshop settings
            KeyStringList webshopSettings = WebshopSetting.GetAllFromCache();
            string redirectHttps = webshopSettings.Get("REDIRECT-HTTPS");

            // Create the customer cookie
            HttpCookie customerCookie = new HttpCookie("CustomerCookie");
            customerCookie.Value = Tools.ProtectCookieValue(id.ToString(), "CustomerLogin");
            customerCookie.Expires = DateTime.UtcNow.AddDays(1);
            customerCookie.HttpOnly = true;
            customerCookie.Secure = redirectHttps.ToLower() == "true" ? true : false;
            Response.Cookies.Add(customerCookie);

            // Redirect the user to the start page
            return RedirectToAction("index", "home");

        } // End of the log_in_as method
コード例 #8
0
        public ActionResult edit()
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();

            // Create the user
            Administrator user = Administrator.GetSignedInAdministrator(currentDomain.front_end_language);

            // Check if the user exists but not are translated
            if(user == null)
            {
                user = Administrator.GetSignedInAdministrator();
            }

            // Get the translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");

            // Create the bread crumb list
            List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(3);
            breadCrumbs.Add(new BreadCrumb(tt.Get("start_page"), "/"));
            breadCrumbs.Add(new BreadCrumb(tt.Get("my_pages"), "/user"));
            breadCrumbs.Add(new BreadCrumb(tt.Get("edit") + " " + tt.Get("user_details").ToLower(), "/user/edit"));

            // Add data to the view
            ViewBag.BreadCrumbs = breadCrumbs;
            ViewBag.CurrentCategory = new Category();
            ViewBag.CurrentDomain = currentDomain;
            ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
            ViewBag.TranslatedTexts = tt;
            ViewBag.User = user;
            ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

            // Create a new empty user if the user does not exist
            if (ViewBag.User == null)
            {
                // Add data to the view
                ViewBag.User = new Administrator();
            }

            // Return the view
            return currentDomain.custom_theme_id == 0 ? View() : View("/Views/theme/edit_user_details.cshtml");

        } // End of the edit method
コード例 #9
0
        public ActionResult files(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Add data to the view
            ViewBag.Customer = Customer.GetOneById(id);
            ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
            ViewBag.ReturnUrl = returnUrl;

            // Make sure that the customer not is null
            if (ViewBag.Customer == null)
            {
                return Redirect("/admin_customers" + returnUrl);
            }

            // Return the view
            return View("files");

        } // End of the files form
コード例 #10
0
        public ActionResult index(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query paramaters
            ViewBag.QueryParams = new QueryParams(Request);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("~/Views/admin_default/index.cshtml");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Update all the webshop settings
            foreach(string key in collection.Keys)
            {
                // Get the value
                string value = collection[key];
                value = value.Length > 100 ? value.Substring(0, 100) : value;

                // Update the value for the key
                WebshopSetting.Update(key, collection[key]);
            }

            // Return the default view
            return RedirectToAction("index", "admin_default");

        } // End of the index method
コード例 #11
0
        // Get the default page
        // GET: /admin_default/
        public ActionResult index()
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();

            ViewBag.CurrentDomain = currentDomain;

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession    = true;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return(View());
            }
            else
            {
                // Redirect the user to the start page
                return(RedirectToAction("index", "admin_login"));
            }
        } // End of the index method
コード例 #12
0
        public ActionResult reset_statistics(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Reset statistics for all campaigns or for just one campaign
            if(id == 0)
            {
                Campaign.ResetStatistics();
            }
            else
            {
                Campaign.UpdateClickCount(id, 0);
            }

            // Return the index view
            return Redirect("/admin_campaigns" + returnUrl);

        } // End of the reset_statistics method
コード例 #13
0
        public ActionResult index()
        {
            // Get the current domain and the home page
            Domain currentDomain = Tools.GetCurrentDomain();
            StaticPage staticPage = StaticPage.GetOneByConnectionId(1, currentDomain.front_end_language);
            staticPage = staticPage != null ? staticPage : new StaticPage();

            // Set form values
            ViewBag.CurrentCategory = new Category();
            ViewBag.BreadCrumbs = new List<BreadCrumb>(0);
            ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");
            ViewBag.CurrentDomain = currentDomain;
            ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
            ViewBag.StaticPage = staticPage;
            ViewBag.UserSettings = (Dictionary<string, string>)Session["UserSettings"];
            ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

            // Return the view
            return currentDomain.custom_theme_id == 0 ? View() : View("/Views/theme/home.cshtml");

        } // End of the index method
コード例 #14
0
        public ActionResult download_marketing_file(Int32 id, string file_name = "", string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Create the file path string
            string filePath = Server.MapPath(file_name);

            // Check if the file exists
            if (System.IO.File.Exists(filePath))
            {
                return File(filePath, System.Net.Mime.MediaTypeNames.Application.Octet, System.IO.Path.GetFileName(filePath));
            }

            // Redirect the user to the marketing files page
            return RedirectToAction("marketing", new { id = id, returnUrl = returnUrl });

        } // End of the download_marketing_file method
コード例 #15
0
        public ActionResult images(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get form values
            Int32 administrator_id = Convert.ToInt32(collection["txtId"]);
            HttpPostedFileBase mainImage = Request.Files["uploadMainImage"];
         
            // Update images
            UpdateImages(administrator_id, mainImage);

            // Redirect the user to the list
            return Redirect(returnUrl);

        } // End of the images method
コード例 #16
0
        public ActionResult index()
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();

            // Get the signed-in administrator
            Administrator user = Administrator.GetSignedInAdministrator(currentDomain.front_end_language);

            // Check if the user is signed in
            if (user == null)
            {
                user = Administrator.GetSignedInAdministrator();
                if(user == null)
                {
                    return RedirectToAction("login", "user");
                } 
            }

            // Get the translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");

            // Create the bread crumb list
            List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(2);
            breadCrumbs.Add(new BreadCrumb(tt.Get("start_page"), "/"));
            breadCrumbs.Add(new BreadCrumb(tt.Get("my_pages"), "/user"));

            // Set form values
            ViewBag.BreadCrumbs = breadCrumbs;
            ViewBag.CurrentCategory = new Category();
            ViewBag.TranslatedTexts = tt;
            ViewBag.CurrentDomain = currentDomain;
            ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
            ViewBag.User = user;
            ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

            // Return the view
            return currentDomain.custom_theme_id == 0 ? View() : View("/Views/theme/user_start_page.cshtml");

        } // End of the index method
コード例 #17
0
        public ActionResult index()
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query paramaters
            ViewBag.QueryParams = new QueryParams(Request);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("~/Views/admin_default/index.cshtml");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the default admin language
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Add data to the view
            ViewBag.TranslatedTexts = StaticText.GetAll(adminLanguageId, "id", "ASC");
            ViewBag.WebshopSettings = WebshopSetting.GetAllFromCache();

            // Return the view
            return View();

        } // End of the index method
コード例 #18
0
        } // End of the index method

        // Get the comments page
        // GET: /admin_default/comments
        public ActionResult comments()
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query paramaters
            ViewBag.QueryParams = new QueryParams(Request);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View();
            }
            else
            {
                // Redirect the user to the login page
                return RedirectToAction("index", "admin_login");
            }

        } // End of the comments method
コード例 #19
0
        public ActionResult author(Int32 id = 0)
        {
            // Get the current domain and the author
            Domain currentDomain = Tools.GetCurrentDomain();
            Administrator author = Administrator.GetOneById(id, currentDomain.front_end_language);

            // Make sure that the author not is null
            if (author == null)
            {
                Response.StatusCode = 404;
                Response.Status = "404 Not Found";
                Response.Write(Tools.GetHttpNotFoundPage());
                return new EmptyResult();
            }

            // Get the translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");

            // Create the bread crumb list
            List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(2);
            breadCrumbs.Add(new BreadCrumb(tt.Get("start_page"), "/"));
            breadCrumbs.Add(new BreadCrumb(author.author_name, "/home/author/" + id.ToString()));

            // Set form values
            ViewBag.BreadCrumbs = breadCrumbs;
            ViewBag.CurrentCategory = new Category();
            ViewBag.TranslatedTexts = tt;
            ViewBag.CurrentDomain = currentDomain;
            ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
            ViewBag.Author = author;
            ViewBag.UserSettings = (Dictionary<string, string>)Session["UserSettings"];
            ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

            // Return the view
            return currentDomain.custom_theme_id == 0 ? View() : View("/Views/theme/author.cshtml");

        } // End of the author method
コード例 #20
0
ファイル: homeController.cs プロジェクト: Kingefosa/a-webshop
        public ActionResult information(string id = "")
        {
            // Get the current domain and the static page
            Domain currentDomain = Tools.GetCurrentDomain();
            StaticPage staticPage = StaticPage.GetOneByPageName(id, currentDomain.front_end_language);

            // Make sure that the static page not is null
            if(staticPage == null)
            {
                Response.StatusCode = 404;
                Response.Status = "404 Not Found";
                Response.Write(Tools.GetHttpNotFoundPage());
                return new EmptyResult();
            }

            // Get the translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");

            // Create the bread crumb list
            List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(2);
            breadCrumbs.Add(new BreadCrumb(tt.Get("start_page"), "/"));
            breadCrumbs.Add(new BreadCrumb(staticPage.link_name, "/home/information/" + staticPage.page_name));

            // Set form values
            ViewBag.BreadCrumbs = breadCrumbs;
            ViewBag.CurrentCategory = new Category();
            ViewBag.TranslatedTexts = tt;
            ViewBag.CurrentDomain = currentDomain;
            ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
            ViewBag.StaticPage = staticPage;
            ViewBag.PricesIncludesVat = Session["PricesIncludesVat"] != null ? Convert.ToBoolean(Session["PricesIncludesVat"]) : currentDomain.prices_includes_vat;
            ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

            // Return the view
            return currentDomain.custom_theme_id == 0 ? View() : View("/Views/theme/information.cshtml");

        } // End of the information method
コード例 #21
0
        public ActionResult edit(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get all the form values
            Int32 id = Convert.ToInt32(collection["txtId"]);
            string title = collection["txtTitle"];
            string linkname = collection["txtLinkname"];
            string description = collection["txtDescription"];
            string metaDescription = collection["txtMetaDescription"];
            string metaKeywords = collection["txtMetaKeywords"];
            string pageName = collection["txtPageName"];
            string metaRobots = collection["selectMetaRobots"];
            byte connectionId = Convert.ToByte(collection["selectConnectionId"]);
            bool inactive = Convert.ToBoolean(collection["cbInactive"]);

            // Get the default admin language id
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(adminLanguageId, "id", "ASC");

            // Get the static page
            StaticPage staticPage = StaticPage.GetOneById(id, adminLanguageId);

            // Check if the static page exists
            if (staticPage == null)
            {
                // Create an empty static page
                staticPage = new StaticPage();
            }

            // Update values
            staticPage.title = title;
            staticPage.link_name = linkname;
            staticPage.main_content = description;
            staticPage.meta_description = metaDescription;
            staticPage.meta_keywords = metaKeywords;
            staticPage.page_name = pageName;
            staticPage.meta_robots = metaRobots;
            staticPage.connected_to_page = connectionId;
            staticPage.inactive = inactive;

            // Create a error message
            string errorMessage = string.Empty;

            // Get a static page on page name
            StaticPage pageOnPageName = StaticPage.GetOneByPageName(staticPage.page_name, adminLanguageId);

            // Check for errors
            if (pageOnPageName != null && staticPage.id != pageOnPageName.id)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_language_unique"), tt.Get("page_name")) + "<br/>";
            }
            if (staticPage.page_name == string.Empty)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_required"), tt.Get("page_name")) + "<br/>";
            }
            if (AnnytabDataValidation.CheckPageNameCharacters(staticPage.page_name) == false)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_bad_chars"), tt.Get("page_name")) + "<br/>";
            }
            if (staticPage.page_name.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("page_name"), "100") + "<br/>";
            }
            if (staticPage.title.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("title"), "200") + "<br/>";
            }
            if (staticPage.link_name.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("link_name"), "100") + "<br/>";
            }
            if (staticPage.meta_description.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("meta_description"), "200") + "<br/>";
            }
            if (staticPage.meta_keywords.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("keywords"), "200") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Check if we should add or update the static page
                if (staticPage.id == 0)
                {
                    // Add the static page
                    Int64 insertId = StaticPage.AddMasterPost(staticPage);
                    staticPage.id = Convert.ToInt32(insertId);
                    StaticPage.AddLanguagePost(staticPage, adminLanguageId);
                }
                else
                {
                    // Update the static page
                    StaticPage.UpdateMasterPost(staticPage);
                    StaticPage.UpdateLanguagePost(staticPage, adminLanguageId);
                }

                // Redirect the user to the list
                return Redirect("/admin_static_pages" + returnUrl);
            }
            else
            {
                // Set form values
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.StaticPage = staticPage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the edit view
                return View("edit");
            }

        } // End of the edit method
コード例 #22
0
        public ActionResult Edit(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();

            ViewBag.CurrentDomain = currentDomain;

            // Get the return url
            string returnUrl = collection["returnUrl"];

            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession    = true;
                ViewBag.AdminErrorCode  = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return(View("index"));
            }
            else
            {
                // Redirect the user to the start page
                return(RedirectToAction("index", "admin_login"));
            }

            // Get all the form values
            string  id            = collection["txtId"];
            Int32   language_id   = Convert.ToInt32(collection["selectLanguage"]);
            string  currency_code = collection["selectCurrency"];
            decimal amount        = 0;

            decimal.TryParse(collection["txtAmount"].Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture, out amount);
            DateTime end_date = Convert.ToDateTime(collection["txtEndDate"]);

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");

            // Get the gift card
            GiftCard giftCard   = GiftCard.GetOneById(id);
            bool     postExists = true;

            // Check if the gift card exists
            if (giftCard == null)
            {
                // Create an empty gift card
                giftCard   = new GiftCard();
                postExists = false;
            }

            // Update values
            giftCard.id            = id;
            giftCard.language_id   = language_id;
            giftCard.currency_code = currency_code;
            giftCard.amount        = amount;
            giftCard.end_date      = AnnytabDataValidation.TruncateDateTime(end_date);

            // Create a error message
            string errorMessage = string.Empty;

            if (giftCard.id.Length == 0 || giftCard.id.Length > 50)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_certain_length"), tt.Get("id"), "1", "50") + "<br/>";
            }
            if (giftCard.language_id == 0)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_select_value"), tt.Get("language").ToLower()) + "<br/>";
            }
            if (giftCard.currency_code == "")
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_select_value"), tt.Get("currency").ToLower()) + "<br/>";
            }
            if (giftCard.amount < 0 || giftCard.amount > 999999999999M)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_range"), tt.Get("amount"), "999 999 999 999") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Check if we should add or update the gift card
                if (postExists == false)
                {
                    // Add the gift card
                    GiftCard.Add(giftCard);
                }
                else
                {
                    // Update the gift card
                    GiftCard.Update(giftCard);
                }

                // Redirect the user to the list
                return(Redirect("/admin_gift_cards" + returnUrl));
            }
            else
            {
                // Set form values
                ViewBag.ErrorMessage    = errorMessage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.Languages       = Language.GetAll(currentDomain.back_end_language, "id", "ASC");
                ViewBag.GiftCard        = giftCard;
                ViewBag.ReturnUrl       = returnUrl;

                // Return the edit view
                return(View("edit"));
            }
        } // End of the edit method
コード例 #23
0
        public ActionResult edit(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get the return url
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get all the form values
            Int32 id = Convert.ToInt32(collection["txtId"]);
            Int32 language_id = Convert.ToInt32(collection["selectLanguage"]);
            string name = collection["txtName"];
            string url = collection["txtUrl"];
            string ad_slot = collection["selectAdSlot"];
            string ad_code = collection["txtDescription"];
            bool inactive = Convert.ToBoolean(collection["cbInactive"]);
            string keywords = collection["txtSearch"];
            Int32 currentPage = Convert.ToInt32(collection["hiddenPage"]);

            // Get the default admin language id
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(adminLanguageId, "id", "ASC");

            // Get the ad
            Ad ad = Ad.GetOneById(id);
            bool postExists = true;

            // Check if the ad exists
            if (ad == null)
            {
                // Create an empty ad
                ad = new Ad();
                postExists = false;
            }

            // Update values
            ad.name = name;
            ad.language_id = language_id;
            ad.ad_slot = ad_slot;
            ad.ad_code = ad_code;
            ad.inactive = inactive;

            // Check if the user wants to do a search
            if (collection["btnSearch"] != null)
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage;
                ViewBag.Ad = ad;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the edit view
                return View("edit");
            }

            // Check if the user wants to do a search
            if (collection["btnPreviousPage"] != null)
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage - 1;
                ViewBag.Ad = ad;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the edit view
                return View("edit");
            }

            // Check if the user wants to do a search
            if (collection["btnNextPage"] != null)
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage + 1;
                ViewBag.Ad = ad;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the edit view
                return View("edit");
            }

            // Create a error message
            string errorMessage = string.Empty;

            // Check for errors in the ad
            if (ad.language_id == 0)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_select_value"), tt.Get("language").ToLower()) + "<br/>";
            }
            if (ad.name.Length > 50)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("name"), "50") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Check if we should add or update the ad
                if (postExists == false)
                {
                    // Add the ad
                    Ad.Add(ad);
                }
                else
                {
                    // Update the ad
                    Ad.Update(ad);
                }

                // Redirect the user to the list
                return Redirect(returnUrl);
            }
            else
            {
                // Set form values
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.Ad = ad;
                ViewBag.ReturnUrl = returnUrl;

                // Return the edit view
                return View("edit");
            }

        } // End of the edit method
コード例 #24
0
        public ActionResult delete(Int32 id = 0, string returnUrl = "/admin_static_pages")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the language id
            int languageId = 0;
            if (Request.Params["lang"] != null)
            {
                Int32.TryParse(Request.Params["lang"], out languageId);
            }

            // Create an error code variable
            Int32 errorCode = 0;

            // Check if we should delete the full post or just the translation
            if (languageId == 0 || languageId == currentDomain.back_end_language)
            {
                // Delete the static page and all the connected posts (CASCADE)
                errorCode = StaticPage.DeleteOnId(id);
            }
            else
            {
                // Delete the translated static page post
                errorCode = StaticPage.DeleteLanguagePostOnId(id, languageId);
            }

            // Check if there is an error
            if (errorCode != 0)
            {
                ViewBag.AdminErrorCode = errorCode;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }

            // Redirect the user to the list
            return Redirect(returnUrl);

        } // End of the delete method
コード例 #25
0
        public ActionResult translate(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get all the form values
            Int32 translationLanguageId = Convert.ToInt32(collection["selectLanguage"]);
            Int32 id = Convert.ToInt32(collection["hiddenStaticPageId"]);
            string title = collection["txtTranslatedTitle"];
            string linkname = collection["txtTranslatedLinkname"];
            string description = collection["txtTranslatedDescription"];
            string metadescription = collection["txtTranslatedMetadescription"];
            string metakeywords = collection["txtTranslatedMetakeywords"];
            string pagename = collection["txtTranslatedPagename"];
            bool inactive = Convert.ToBoolean(collection["cbInactive"]);
            string returnUrl = collection["returnUrl"];
            string keywords = collection["txtSearch"];
            Int32 currentPage = Convert.ToInt32(collection["hiddenPage"]);

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor", "Translator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the standard static page
            StaticPage standardStaticPage = StaticPage.GetOneById(id, currentDomain.back_end_language);

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");

            // Create the translated static page
            StaticPage translatedStaticPage = new StaticPage();
            translatedStaticPage.id = id;
            translatedStaticPage.title = title;
            translatedStaticPage.link_name = linkname;
            translatedStaticPage.main_content = description;
            translatedStaticPage.meta_description = metadescription;
            translatedStaticPage.meta_keywords = metakeywords;
            translatedStaticPage.page_name = pagename;
            translatedStaticPage.inactive = inactive;

            // Check if the user wants to do a search
            if (collection["btnSearch"] != null)
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = 1;
                ViewBag.LanguageId = translationLanguageId;
                ViewBag.Languages = Language.GetAll(currentDomain.back_end_language, "name", "ASC");
                ViewBag.StandardStaticPage = standardStaticPage;
                ViewBag.TranslatedStaticPage = translatedStaticPage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the translate view
                return View("translate");
            }

            // Check if the user wants to do a search
            if (collection["btnPreviousPage"] != null)
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage - 1;
                ViewBag.LanguageId = translationLanguageId;
                ViewBag.Languages = Language.GetAll(currentDomain.back_end_language, "name", "ASC");
                ViewBag.StandardStaticPage = standardStaticPage;
                ViewBag.TranslatedStaticPage = translatedStaticPage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the translate view
                return View("translate");
            }

            // Check if the user wants to do a search
            if (collection["btnNextPage"] != null)
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage + 1;
                ViewBag.LanguageId = translationLanguageId;
                ViewBag.Languages = Language.GetAll(currentDomain.back_end_language, "name", "ASC");
                ViewBag.StandardStaticPage = standardStaticPage;
                ViewBag.TranslatedStaticPage = translatedStaticPage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the translate view
                return View("translate");
            }

            // Create a error message
            string errorMessage = string.Empty;

            // Get a static page on page name
            StaticPage pageOnPageName = StaticPage.GetOneByPageName(translatedStaticPage.page_name, currentDomain.back_end_language);

            // Check the page name
            if (pageOnPageName != null && translatedStaticPage.id != pageOnPageName.id)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_language_unique"), tt.Get("page_name")) + "<br/>";
            }
            if (translatedStaticPage.page_name == string.Empty)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_required"), tt.Get("page_name")) + "<br/>";
            }
            if (AnnytabDataValidation.CheckPageNameCharacters(translatedStaticPage.page_name) == false)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_bad_chars"), tt.Get("page_name")) + "<br/>";
            }
            if (translatedStaticPage.page_name.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("page_name"), "100") + "<br/>";
            }
            if (translatedStaticPage.title.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("title"), "200") + "<br/>";
            }
            if (translatedStaticPage.link_name.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("link_name"), "100") + "<br/>";
            }
            if (translatedStaticPage.meta_description.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("meta_description"), "200") + "<br/>";
            }
            if (translatedStaticPage.meta_keywords.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("keywords"), "200") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Get the saved static page
                StaticPage staticPage = StaticPage.GetOneById(id, translationLanguageId);

                if (staticPage == null)
                {
                    // Add a new translated static page
                    StaticPage.AddLanguagePost(translatedStaticPage, translationLanguageId);
                }
                else
                {
                    // Update values for the saved static page
                    staticPage.title = translatedStaticPage.title;
                    staticPage.link_name = translatedStaticPage.link_name;
                    staticPage.main_content = translatedStaticPage.main_content;
                    staticPage.meta_description = translatedStaticPage.meta_description;
                    staticPage.meta_keywords = translatedStaticPage.meta_keywords;
                    staticPage.page_name = translatedStaticPage.page_name;
                    staticPage.inactive = translatedStaticPage.inactive;

                    // Update the static page translation
                    StaticPage.UpdateLanguagePost(staticPage, translationLanguageId);
                }

                // Redirect the user to the list
                return Redirect(returnUrl);
            }
            else
            {
                // Set form values
                ViewBag.Keywords = keywords;
                ViewBag.CurrentPage = currentPage;
                ViewBag.LanguageId = translationLanguageId;
                ViewBag.Languages = Language.GetAll(currentDomain.back_end_language, "name", "ASC");
                ViewBag.StandardStaticPage = standardStaticPage;
                ViewBag.TranslatedStaticPage = translatedStaticPage;
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the translate view
                return View("translate");
            }

        } // End of the translate method
コード例 #26
0
        public ActionResult login(FormCollection collection)
        {
            // Get data from the form
            string returnUrl = collection["hiddenReturnUrl"];
            string user_name = collection["txtUserName"];
            string password = collection["txtPassword"];

            // Get the user
            Administrator user = Administrator.GetOneByUserName(user_name);

            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");

            // Check if the user exists and if the password is correct
            if (user != null && Administrator.ValidatePassword(user_name, password) == true)
            {
                // Get website settings
                KeyStringList websiteSettings = WebsiteSetting.GetAllFromCache();
                string redirectHttps = websiteSettings.Get("REDIRECT-HTTPS");

                // Create the administrator cookie
                HttpCookie adminCookie = new HttpCookie("Administrator");
                adminCookie.Value = Tools.ProtectCookieValue(user.id.ToString(), "Administration");
                adminCookie.Expires = DateTime.UtcNow.AddDays(1);
                adminCookie.HttpOnly = true;
                adminCookie.Secure = redirectHttps.ToLower() == "true" ? true : false;
                Response.Cookies.Add(adminCookie);

                // Redirect the user to the checkout page
                return Redirect(returnUrl);
            }
            else
            {
                // Create a new user
                user = new Administrator();
                user.admin_user_name = user_name;
                string error_message = "&#149; " + tt.Get("error_login");

                // Create the bread crumb list
                List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(3);
                breadCrumbs.Add(new BreadCrumb(tt.Get("start_page"), "/"));
                breadCrumbs.Add(new BreadCrumb(tt.Get("my_pages"), "/user"));
                breadCrumbs.Add(new BreadCrumb(tt.Get("log_in"), "/user/login"));

                // Set values
                ViewBag.BreadCrumbs = breadCrumbs;
                ViewBag.CurrentCategory = new Category();
                ViewBag.TranslatedTexts = tt;
                ViewBag.CurrentDomain = currentDomain;
                ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
                ViewBag.User = user;
                ViewBag.ErrorMessage = error_message;
                ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

                // Return the login view
                return currentDomain.custom_theme_id == 0 ? View() : View("/Views/theme/user_login.cshtml");
            }

        } // End of the login method
コード例 #27
0
        public ActionResult edit_rating(FormCollection collection)
        {
            // Make sure that the user is signed in
            Administrator user = Administrator.GetSignedInAdministrator();

            // Get the current domain
            Domain domain = Tools.GetCurrentDomain();

            // Get the translated texts
            KeyStringList tt = StaticText.GetAll(domain.front_end_language, "id", "ASC");

            // Check if the post request is valid
            if (user == null || collection == null)
            {
                return RedirectToAction("login", "user");
            }

            // Get the form data
            Int32 post_id = Convert.ToInt32(collection["hiddenPostId"]);
            Int32 language_id = Convert.ToInt32(collection["hiddenLanguageId"]);
            decimal userVote = 0;
            decimal.TryParse(collection["userVote"], NumberStyles.Any, CultureInfo.InvariantCulture, out userVote);

            // Get the post
            Post post = Post.GetOneById(post_id, language_id);

            // Try to get a saved rating
            PostRating postRating = PostRating.GetOneById(post_id, user.id, language_id);

            // Add or update the rating
            if (postRating != null && postRating.administrator_id == user.id)
            {
                // Update values
                postRating.rating_date = DateTime.UtcNow;
                postRating.rating = userVote;

                // Update the rating
                PostRating.Update(postRating);
            }
            else
            {
                // Create a new rating
                postRating = new PostRating();

                // Update values
                postRating.post_id = post_id;
                postRating.administrator_id = user.id;
                postRating.language_id = language_id;
                postRating.rating_date = DateTime.UtcNow;
                postRating.rating = userVote;

                // Add the rating
                PostRating.Add(postRating);
            }

            // Send a email to the administrator of the website
            string subject = tt.Get("rating") + " - " + domain.website_name;
            string message = tt.Get("post") + ": " + postRating.post_id.ToString() + "<br />"
                + tt.Get("language") + ": " + postRating.language_id.ToString() + "<br />"
                + tt.Get("user_name") + ": " + user.admin_user_name + "<br />" 
                + tt.Get("rating") + ": " + postRating.rating.ToString();
            Tools.SendEmailToHost("", subject, message);

            // Update the rating for the post
            Post.UpdateRating(postRating.post_id, postRating.language_id);

            // Redirect the user to the post
            return Redirect("/home/post/" + post.page_name + "#comments");

        } // End of the edit_rating method
コード例 #28
0
        public ActionResult edit(FormCollection collection)
        {
            // Get all the form values
            Int32 id = Convert.ToInt32(collection["txtId"]);
            string user_name = collection["txtUserName"];
            string password = collection["txtPassword"];
            string email = collection["txtEmail"];
            string author_name = collection["txtAuthorName"];
            string author_description = collection["txtAuthorDescription"];
            HttpPostedFileBase authorImage = Request.Files["uploadMainImage"];

            // Modify the author description
            author_description = author_description.Replace(Environment.NewLine, "<br />");

            // Get the current domain
            Domain domain = Tools.GetCurrentDomain();

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(domain.front_end_language, "id", "ASC");

            // Get the user
            Administrator user = Administrator.GetOneById(id, domain.front_end_language);

            // Check if the user exists
            if (user == null)
            {
                // Check if the user exists but not are translated
                user = Administrator.GetOneById(id);
                if(user == null)
                {
                    // Create an empty user
                    user = new Administrator();
                }
            }

            // Update values
            user.admin_user_name = user_name;
            user.email = email;
            user.author_name = author_name;
            user.author_description = author_description;

            // Create a error message
            string errorMessage = string.Empty;

            // Get the user on user name
            Administrator userOnUserName = Administrator.GetOneByUserName(user.admin_user_name);

            // Check for errors
            if (userOnUserName != null && user.id != userOnUserName.id)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_unique"), tt.Get("user_name")) + "<br/>";
            }
            if (user.admin_user_name.Length > 50)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("user_name"), "50") + "<br/>";
            }
            if (user.author_name.Length > 50)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("name"), "50") + "<br/>";
            }
            if (AnnytabDataValidation.IsEmailAddressValid(user.email) == null)
            {
                errorMessage += "&#149; " + tt.Get("error_email_valid") + "<br/>";
            }
            if (authorImage.ContentLength > 0 && Tools.IsImageJpeg(authorImage) == false)
            {
                errorMessage += "&#149; " + tt.Get("error_invalid_jpeg") + "<br/>";
            }
            if (authorImage.ContentLength > 262144)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_image_size"), "256 kb") + "<br/>"; ;
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Check if we should add or update the user
                if (user.id == 0)
                {
                    // Add the user
                    user.admin_role = "User";
                    Int64 insertId = Administrator.AddMasterPost(user);
                    user.id = Convert.ToInt32(insertId);
                    Administrator.AddLanguagePost(user, domain.front_end_language);
                    Administrator.UpdatePassword(user.id, PasswordHash.CreateHash(password));

                    // Get website settings
                    KeyStringList websiteSettings = WebsiteSetting.GetAllFromCache();
                    string redirectHttps = websiteSettings.Get("REDIRECT-HTTPS");

                    // Create the administrator cookie
                    HttpCookie adminCookie = new HttpCookie("Administrator");
                    adminCookie.Value = Tools.ProtectCookieValue(user.id.ToString(), "Administration");
                    adminCookie.Expires = DateTime.UtcNow.AddDays(1);
                    adminCookie.HttpOnly = true;
                    adminCookie.Secure = redirectHttps.ToLower() == "true" ? true : false;
                    Response.Cookies.Add(adminCookie);
                }
                else
                {
                    // Update the user
                    Administrator.UpdateMasterPost(user);

                    // Update or add the language post
                    if (Administrator.GetOneById(id, domain.front_end_language) != null)
                    {
                        Administrator.UpdateLanguagePost(user, domain.front_end_language);
                    }
                    else
                    {
                        Administrator.AddLanguagePost(user, domain.front_end_language);
                    }
                    

                    // Only update the password if it has changed
                    if (password != "")
                    {
                        Administrator.UpdatePassword(user.id, PasswordHash.CreateHash(password));
                    }
                }

                // Update the image
                if (authorImage.ContentLength > 0)
                {
                    UpdateImage(user.id, authorImage);
                }

                // Redirect the user to the start page
                return RedirectToAction("index");
            }
            else
            {
                // Create the bread crumb list
                List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(3);
                breadCrumbs.Add(new BreadCrumb(tt.Get("start_page"), "/"));
                breadCrumbs.Add(new BreadCrumb(tt.Get("my_pages"), "/user"));
                breadCrumbs.Add(new BreadCrumb(tt.Get("edit") + " " + tt.Get("user_details").ToLower(), "/user/edit"));

                // Set form values
                ViewBag.BreadCrumbs = breadCrumbs;
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.CurrentCategory = new Category();
                ViewBag.CurrentDomain = domain;
                ViewBag.CurrentLanguage = Language.GetOneById(domain.front_end_language);
                ViewBag.TranslatedTexts = tt;
                ViewBag.User = user;
                ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

                // Return the edit view
                return domain.custom_theme_id == 0 ? View("edit") : View("/Views/theme/edit_user_details.cshtml");
            }

        } // End of the edit method
コード例 #29
0
        public ActionResult forgot_password(FormCollection collection)
        {
            // Get form data
            string user_name = collection["txtUserName"];

            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();

            // Get translated texts
            KeyStringList translatedTexts = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");

            // Get the user
            Administrator user = Administrator.GetOneByUserName(user_name);

            // Create a random password
            string password = Tools.GeneratePassword();
            
            // Create a error message
            string error_message = "";

            // Check if the user exists
            if(user != null)
            {
                // Create the mail message
                string subject = translatedTexts.Get("forgot") + " " + translatedTexts.Get("password").ToLower() + " - " + currentDomain.website_name;
                string message = translatedTexts.Get("user_name") + ": " + user.admin_user_name + "<br />" 
                    + translatedTexts.Get("password") + ": " + password + "<br /><br />"
                    + "<a href=\"" + currentDomain.web_address + "/user/login\">" + translatedTexts.Get("log_in") + "</a><br />";

                // Try to send the email message
                if(Tools.SendEmailToUser(user.email, subject, message) == false)
                {
                    error_message += "&#149; " + translatedTexts.Get("error_send_email");
                }
            }
            else
            {
                error_message += "&#149; " + translatedTexts.Get("error_user_exists");
            }

            // Check if there is a error message
            if (error_message == "")
            {
                // Update the password
                Administrator.UpdatePassword(user.id, PasswordHash.CreateHash(password));

                // Redirect the user to the login page
                return RedirectToAction("login");
            }
            else
            {
                // Create the bread crumb list
                List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(3);
                breadCrumbs.Add(new BreadCrumb(translatedTexts.Get("start_page"), "/"));
                breadCrumbs.Add(new BreadCrumb(translatedTexts.Get("my_pages"), "/user"));
                breadCrumbs.Add(new BreadCrumb(translatedTexts.Get("forgot") + " " + translatedTexts.Get("password").ToLower(), "/user/forgot_password"));

                // Set values
                ViewBag.BreadCrumbs = breadCrumbs;
                ViewBag.CurrentCategory = new Category();
                ViewBag.TranslatedTexts = translatedTexts;
                ViewBag.CurrentDomain = currentDomain;
                ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
                ViewBag.User = new Administrator();
                ViewBag.ErrorMessage = error_message;
                ViewBag.CultureInfo = Tools.GetCultureInfo(ViewBag.CurrentLanguage);

                // Return the view
                return currentDomain.custom_theme_id == 0 ? View() : View("/Views/theme/forgot_password.cshtml");
            }

        } // End of the forgot_password method
コード例 #30
0
        public ActionResult edit(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get the return url
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get all the form values
            Int32 id = Convert.ToInt32(collection["txtId"]);
            string userName = collection["txtUserName"];
            string password = collection["txtPassword"];
            string role = collection["selectAdminRole"];

            // Get the default admin language id
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(adminLanguageId, "id", "ASC");

            // Get the administrator
            Administrator administrator = Administrator.GetOneById(id);
            bool postExists = true;

            // Check if the administrator exists
            if (administrator == null)
            {
                // Create an empty administrator
                administrator = new Administrator();
                postExists = false;
            }

            // Update values
            administrator.admin_user_name = userName;
            administrator.admin_role = role;

            // Create a error message
            string errorMessage = string.Empty;

            // Get a administrator on user name
            Administrator adminOnUserName = Administrator.GetOneByUserName(userName);

            // Check for errors in the administrator
            if (adminOnUserName != null && administrator.id != adminOnUserName.id)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_unique"), tt.Get("user_name")) + "<br/>";
            }
            if (administrator.admin_user_name.Length > 50)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("user_name"), "50") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Check if we should add or update the administrator
                if (postExists == false)
                {
                    // Add the administrator
                    Int32 insertId = (Int32)Administrator.Add(administrator);
                    Administrator.UpdatePassword(insertId, PasswordHash.CreateHash(password));
                }
                else
                {
                    // Update the administrator
                    Administrator.Update(administrator);

                    // Only update the password if it has changed
                    if (password != "")
                    {
                        Administrator.UpdatePassword(administrator.id, PasswordHash.CreateHash(password));
                    }
                }

                // Redirect the user to the list
                return Redirect("/admin_administrators" + returnUrl);
            }
            else
            {
                // Set form values
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.Administrator = administrator;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the edit view
                return View("edit");
            }

        } // End of the edit method