Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int nb = 0;

        int.TryParse("" + objModules.GetModuleSettings(ModuleId)["nbnews"], out nb);

        int cric = -1;
        var news = new List <News>();

        if (categorie == "clubCourant")
        {
            string seo = Request.QueryString["sn"];
            if (seo != null && seo != "")
            {
                Club club = DataMapping.GetClubBySeo(seo);
                cric = club.cric;
            }



            news = DataMapping.ListNews_EN(cric: cric != -1 ? cric : 0, onlyvisible: true, category: "Clubs", tri: "dt desc", tags_included: "" + objModules.GetModuleSettings(ModuleId)["tags_included"], tags_excluded: "" + objModules.GetModuleSettings(ModuleId)["tags_excluded"]);
        }
        else if (categorie == "selectedClub")
        {
            cric = Functions.CurrentCric;
            if (cric == 0)
            {
                lbl_noClubSelected.Visible = false;
            }
            else
            {
                news = DataMapping.ListNews_EN(cric: cric, onlyvisible: true, category: "Clubs", tri: "dt desc", tags_included: "" + objModules.GetModuleSettings(ModuleId)["tags_included"], tags_excluded: "" + objModules.GetModuleSettings(ModuleId)["tags_excluded"]);
            }
        }
        else
        {
            news = DataMapping.ListNews_EN(cric: 0, onlyvisible: true, category: categorie, tri: "dt asc", where : "dt>getdate()", tags_included: "" + objModules.GetModuleSettings(ModuleId)["tags_included"], tags_excluded: "" + objModules.GetModuleSettings(ModuleId)["tags_excluded"]);
        }



        List <News> TheNews = new List <News>();

        for (int i = 0; i < Math.Min(nb, news.Count); i++)
        {
            TheNews.Add(news[i]);
        }


        if (TheNews.Count == 0)
        {
            lbl_noNews.Visible = true;
        }
        LI_News.DataSource = TheNews;
        LI_News.DataBind();
    }
Exemplo n.º 2
0
    public bool HasPermission()
    {
        string seo  = "" + Request.QueryString["sn"];
        Club   club = DataMapping.GetClubBySeo(seo);

        if (Functions.CurrentCric == club.cric && (UserInfo.IsInRole(Const.ROLE_ADMIN_CLUB) || UserInfo.IsInRole(Const.ROLE_ADMIN_DISTRICT) || UserInfo.IsSuperUser))
        {
            return(true);
        }
        return(false);
    }
Exemplo n.º 3
0
    protected void repeat_bloc_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        string seo  = "" + Request.QueryString["sn"];
        Club   club = DataMapping.GetClubBySeo(seo);

        News news = DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault() == null ? new News() : DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault();

        News.Bloc        bloc  = (News.Bloc)e.Item.DataItem;
        List <News.Bloc> blocs = DataMapping.GetNews_EN(news.id).GetListBlocs();


        Panel pnl_display = (Panel)e.Item.FindControl("pnl_display");

        pnl_display.CssClass += " Bloc" + bloc.type;

        LinkButton btn_editBloc = (LinkButton)e.Item.FindControl("btn_editBloc");

        btn_editBloc.CommandArgument = bloc.id;

        LinkButton btn_delete = (LinkButton)e.Item.FindControl("btn_delete");

        LinkButton lbt_up   = (LinkButton)e.Item.FindControl("lbt_up");
        LinkButton lbt_down = (LinkButton)e.Item.FindControl("lbt_down");



        if (Functions.CurrentCric != club.cric)
        {
            btn_editBloc.Visible = false;
            btn_delete.Visible   = false;
            lbt_down.Visible     = false;
            lbt_up.Visible       = false;
        }
        else
        {
            btn_editBloc.Visible = true;
            btn_delete.Visible   = true;
            lbt_down.Visible     = bloc.ord < blocs.Count * 10;
            lbt_up.Visible       = bloc.ord > 10;
        }

        Label lbl_contenu = (Label)e.Item.FindControl("lbl_content");

        if (bloc.type == "BlocVideo")
        {
            Video vid = new Video();
            vid = (Video)Functions.Deserialize(bloc.content, vid.GetType());
            Panel pnl_contentToDisplay = (Panel)e.Item.FindControl("pnl_contentToDisplay");
            pnl_contentToDisplay.CssClass += " videoContainer";
            lbl_contenu.Text = vid.getLink();
        }
    }
Exemplo n.º 4
0
    protected bool createNewsClub()
    {
        try
        {
            String seo  = Request.QueryString["sn"];
            int    cric = DataMapping.GetClubBySeo(seo).cric;
            if (cric == 0)
            {
                throw new Exception("cric");
            }

            News news = DataMapping.ListNews(cric: cric, category: "accueilclub").FirstOrDefault() != null && DataMapping.ListNews(cric: cric, category: "accueilclub").FirstOrDefault().id != null?DataMapping.ListNews(cric : cric, category : "accueilclub").FirstOrDefault() : new News();

            if (news == null)
            {
                throw new Exception("News null");
            }
            if (news.id != null)
            {
                return(true);
            }


            news.cric             = cric;
            news.dt               = DateTime.Now;
            news.date_end_event   = DateTime.Now;
            news.date_start_event = DateTime.Now;
            news.title            = tbx_titre.Text;
            news.Abstract         = "";
            news.url              = "";
            news.url_text         = "";
            news.photo            = "";
            news.category         = "accueilclub";
            news.tag1             = seo;
            news.tag2             = "";
            news.visible          = "O";
            news.club_type        = "";
            news.adress_event     = "";
            news.town_event       = "";
            news.zip_event        = "";
            news.ord              = 10;
            news.text             = "";

            DataMapping.UpdateNews_EN(news);
        }
        catch (Exception ee)
        {
            Functions.Error(ee);
            return(false);
        }
        return(true);
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //pnl_content.Visible = true;
            string seo  = "" + Request.QueryString["sn"];
            Club   club = DataMapping.GetClubBySeo(seo);
            if (club != null)
            {
                LBL_nom.Text         = club.name;
                LBL_adresse_1.Text   = club.adress_1;
                LBL_adresse_2.Text   = club.adress_2;
                LBL_adresse_3.Text   = club.adress_3;
                LBL_cp.Text          = club.zip;
                LBL_ville.Text       = club.town;
                IMG_fanion.ImageUrl  = club.GetPennant();
                LBL_reunions.Text    = club.meetings;
                LBL_telephone.Text   = club.telephone;
                LBL_fax.Text         = club.fax;
                HL_email.NavigateUrl = "mailto:" + club.email;
                HL_web.NavigateUrl   = club.web;
                HL_web.Visible       = club.web != "";
                LBL_texte.Text       = club.text;

                btn_addBloc.Visible = HasPermission();

                if (!createNewsClub())
                {
                    throw new Exception("An error occured while creating the club news");
                }

                //List<News> news = DataMapping.ListNews(category:"Clubs", cric : club.cric);
                //LI_News.DataSource = news;
                //LI_News.DataBind();

                //btn_editBloc.Visible = (UserInfo.IsInRole(Const.ROLE_ADMIN_DISTRICT) || UserInfo.IsSuperUser || UserInfo.IsInRole(Const.ROLE_ADMIN_CLUB)) && Functions.CurrentCric == club.cric;
                //lbt_deleteBloc.Visible = (UserInfo.IsInRole(Const.ROLE_ADMIN_DISTRICT) || UserInfo.IsSuperUser || UserInfo.IsInRole(Const.ROLE_ADMIN_CLUB)) && Functions.CurrentCric == club.cric;

                List <Affectation> affectations = DataMapping.ListAffectation(club.cric);

                News news = DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault() == null ? new News() : DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault();

                if (news != null)
                {
                    if (news.id == null)
                    {
                        //btn_editBloc.Text = "Ajouter une présentation";
                        //pnl_content.Visible = false;
                        //lbt_deleteBloc.Visible = false;
                    }
                    else
                    {
                        List <News.Bloc> blocs = DataMapping.GetNews_EN(news.id).GetListBlocs();
                        repeat_bloc.DataSource = blocs;
                        repeat_bloc.DataBind();
                    }

                    //pnl_content.CssClass += news.tag2 + " MiniNews";



                    /*Titre1.Text = news.title;
                     *
                     *
                     * switch (news.tag2)
                     * {
                     *  case "BlocNoPhoto":
                     *      Texte1.Text = news.text;
                     *      Image1.Visible = false;
                     *      break;
                     *  case "BlocVideo":
                     *      Video vid = new Video();
                     *      vid = (Video)Functions.Deserialize(news.text, vid.GetType());
                     *      Texte1.Text = vid.getLink();
                     *      pnl_video.Visible = true;
                     *      Panel2.CssClass += " videoContainer";
                     *      break;
                     *  default :
                     *      Image1.ImageUrl = news.photo;
                     *      Texte1.Text = news.text;
                     *      Image1.Visible = true;
                     *      break;
                     * }
                     *
                     *
                     *
                     * HL_Detail.NavigateUrl = Functions.UrlAddParam(Globals.NavigateURL(newstabid), "newsid", news.id);
                     * HL_Detail1.NavigateUrl = HL_Detail.NavigateUrl;*/
                }
            }
        }
    }
Exemplo n.º 6
0
    protected void repeat_bloc_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string seo  = "" + Request.QueryString["sn"];
        Club   club = DataMapping.GetClubBySeo(seo);

        #region editBloc
        if (e.CommandSource == (LinkButton)e.Item.FindControl("btn_editBloc"))
        {
            LinkButton btn_editBloc = (LinkButton)e.Item.FindControl("btn_editBloc");
            btn_validate.CommandArgument = btn_editBloc.CommandArgument;
            pnl_add.Visible     = true;
            btn_addBloc.Visible = false;
            repeat_bloc.Visible = false;
            News.Bloc bloc = DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs().Where(x => x.id == btn_editBloc.CommandArgument).First();
            switch (bloc.type)
            {
            case "BlocNoPhoto":

                tbx_contenu.Text = bloc.content;
                break;

            case "BlocVideo":

                Video vid = new Video();
                vid          = (Video)Functions.Deserialize(bloc.content, vid.GetType());
                tbx_url.Text = vid.Url;
                break;

            default:
                img.ImageUrl = bloc.photo;
                break;
            }
            foreach (ListItem li in rbl_type.Items)
            {
                if ("Bloc" + li.Value == bloc.type)
                {
                    li.Selected = true;
                }
            }
            tbx_titre.Text = bloc.title;
        }
        #endregion editBloc

        else if (e.CommandSource == (LinkButton)e.Item.FindControl("btn_delete"))
        {
            LinkButton btn_delete = (LinkButton)e.Item.FindControl("btn_delete");
            News.Bloc  bloc       = DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs().Where(x => x.id == btn_delete.CommandArgument).FirstOrDefault();

            if (bloc == null)
            {
                throw new Exception("bloc null");
            }
            if (!DataMapping.DeleteNewsBloc(bloc))
            {
                throw new Exception("An error occured while deleting the bloc");
            }

            Response.Redirect("~/" + club.seo + "/");
        }
        else if (e.CommandSource == (LinkButton)e.Item.FindControl("lbt_up"))
        {
            int        cric    = club.cric;
            LinkButton lbt_up  = (LinkButton)e.Item.FindControl("lbt_up");
            News       news    = DataMapping.ListNews(cric: cric, category: "accueilclub").FirstOrDefault();
            News.Bloc  bloc    = DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs().Where(x => x.id == lbt_up.CommandArgument).FirstOrDefault();;
            News.Bloc  bloc_up = null;

            foreach (News.Bloc b in DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs())
            {
                if (bloc != null && b.ord == bloc.ord - 10)
                {
                    bloc_up = b;
                }
            }

            if (bloc == null || bloc_up == null)
            {
                throw new Exception("Error can't find blocs");
            }


            int tempord = bloc.ord;
            bloc.ord    = bloc_up.ord;
            bloc_up.ord = tempord;

            DataMapping.UpdateNewsBloc(bloc, news.id);
            DataMapping.UpdateNewsBloc(bloc_up, news.id);

            Response.Redirect("~/" + club.seo + "/");
        }
        else if (e.CommandSource == (LinkButton)e.Item.FindControl("lbt_down"))
        {
            int        cric     = club.cric;
            LinkButton lbt_down = (LinkButton)e.Item.FindControl("lbt_down");
            News       news     = DataMapping.ListNews(cric: cric, category: "accueilclub").FirstOrDefault();
            News.Bloc  bloc     = DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs().Where(x => x.id == lbt_down.CommandArgument).FirstOrDefault();;
            News.Bloc  bloc_up  = null;

            foreach (News.Bloc b in DataMapping.GetNews_EN(DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault().id).GetListBlocs())
            {
                if (bloc != null && b.ord == bloc.ord + 10)
                {
                    bloc_up = b;
                }
            }

            if (bloc == null || bloc_up == null)
            {
                throw new Exception("Error can't find blocs");
            }


            int tempord = bloc.ord;
            bloc.ord    = bloc_up.ord;
            bloc_up.ord = tempord;

            DataMapping.UpdateNewsBloc(bloc, news.id);
            DataMapping.UpdateNewsBloc(bloc_up, news.id);

            Response.Redirect("~/" + club.seo + "/");
        }
    }
Exemplo n.º 7
0
    /*protected void btn_editBloc_Click(object sender, EventArgs e)
     * {
     *  //btn_editBloc.Visible = false;
     *  //pnl_content.Visible = false;
     *  //lbt_deleteBloc.Visible = false;
     *  pnl_add.Visible = true;
     *  string seo = "" + Request.QueryString["sn"];
     *
     *  Club club = DataMapping.GetClubBySeo(seo);
     *  News news = DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault()==null? new News() : DataMapping.ListNews(cric: club.cric, category: "accueilclub").FirstOrDefault();
     *
     *  img.ImageUrl = news.photo;
     *  tbx_titre.Text = news.title;
     *
     *  if (news != null)
     *  {
     *
     *      switch (news.tag2)
     *      {
     *          case "BlocNoPhoto":
     *              tbx_contenu.Text = news.text;
     *              break;
     *          case null:
     *              tbx_contenu.Text = news.text;
     *              break;
     *          case "BlocVideo":
     *              Video vid = new Video();
     *              vid = (Video)Functions.Deserialize(news.text, vid.GetType());
     *              tbx_url.Text = vid.Url;
     *              tbx_contenu.Visible = false;
     *              break;
     *          default:
     *              tbx_contenu.Text = news.text;
     *              pnl_image.Visible = true;
     *              break;
     *      }
     *
     *      foreach (ListItem li in rbl_type.Items)
     *      {
     *          if ("Bloc" + li.Value == news.tag2)
     *          {
     *              li.Selected = true;
     *              break;
     *          }
     *
     *      }
     *
     *  }
     * }*/

    #region buttons

    protected void btn_validate_Click(object sender, EventArgs e)
    {
        string seo  = "" + Request.QueryString["sn"];
        Club   club = DataMapping.GetClubBySeo(seo);
        int    cric = club.cric;
        News   news = DataMapping.ListNews(cric: cric, category: "accueilclub").FirstOrDefault();

        News.Bloc bloc = new News.Bloc();
        btn_addBloc.Visible = false;
        repeat_bloc.Visible = false;
        if (btn_validate.CommandArgument != null && btn_validate.CommandArgument != "")
        {
            foreach (News.Bloc b in DataMapping.GetNews_EN(news.id).GetListBlocs())
            {
                if (b.id == btn_validate.CommandArgument)
                {
                    bloc = b;
                }
            }
        }

        switch (rbl_type.SelectedValue)
        {
        case "NoPhoto":
            bloc.content      = tbx_contenu.Text;
            bloc.content_type = "text";
            bloc.photo        = "";
            break;

        case "Video":
            Video vid = new Video();
            vid.Url = tbx_url.Text;
            if (vid.Url.Contains("youtube"))
            {
                vid.Type = "youtube";
            }
            else if (vid.Url.Contains("daily"))
            {
                vid.Type = "daily";
            }
            else
            {
                vid.Type = "vimeo";
            }
            bloc.content      = Functions.Serialize(vid);
            bloc.photo        = "";
            bloc.content_type = "video/" + vid.Type;
            break;

        default:
            bloc.photo        = img.ImageUrl;
            bloc.content      = tbx_contenu.Text;
            bloc.content_type = "photo";
            break;
        }

        bloc.type    = "Bloc" + rbl_type.SelectedValue;
        bloc.title   = tbx_titre.Text;
        bloc.ord     = bloc.id == null? (1 + DataMapping.GetNews_EN(news.id).GetListBlocs().Count) * 10 : bloc.ord;
        bloc.visible = "O";

        DataMapping.UpdateNewsBloc(bloc, news.id);



        Response.Redirect("~/" + Request.QueryString["sn"] + "/");
    }