예제 #1
0
        public IEnumerable <S22.Xmpp.Jid> GetBlocklist()
        {
            this.AssertValid();
            if (this.block.Supported)
            {
                return(this.block.GetBlocklist());
            }
            PrivacyList privacyList        = null;
            string      defaultPrivacyList = this.im.GetDefaultPrivacyList();

            if (defaultPrivacyList != null)
            {
                privacyList = this.im.GetPrivacyList(defaultPrivacyList);
            }
            foreach (PrivacyList list2 in this.im.GetPrivacyLists())
            {
                if (list2.Name == "blocklist")
                {
                    privacyList = list2;
                }
            }
            HashSet <S22.Xmpp.Jid> set = new HashSet <S22.Xmpp.Jid>();

            if (privacyList != null)
            {
                foreach (PrivacyRule rule in privacyList)
                {
                    if (rule is JidPrivacyRule)
                    {
                        set.Add((rule as JidPrivacyRule).Jid);
                    }
                }
            }
            return(set);
        }
예제 #2
0
 public void Block(S22.Xmpp.Jid jid)
 {
     this.AssertValid();
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     if (this.block.Supported)
     {
         this.block.Block(jid);
     }
     else
     {
         PrivacyList privacyList        = null;
         string      defaultPrivacyList = this.im.GetDefaultPrivacyList();
         if (defaultPrivacyList != null)
         {
             privacyList = this.im.GetPrivacyList(defaultPrivacyList);
         }
         foreach (PrivacyList list2 in this.im.GetPrivacyLists())
         {
             if (list2.Name == "blocklist")
             {
                 privacyList = list2;
             }
         }
         if (privacyList == null)
         {
             privacyList = new PrivacyList("blocklist");
         }
         privacyList.Add(new JidPrivacyRule(jid, false, 0, 0), true);
         this.im.EditPrivacyList(privacyList);
         this.im.SetDefaultPrivacyList(privacyList.Name);
         this.im.SetActivePrivacyList(privacyList.Name);
     }
 }
예제 #3
0
        public void Load()
        {
            PrivacyList privacys = new PrivacyList();

            privacys.Load();

            Assert.IsTrue(privacys.Count > 0);
        }
예제 #4
0
        private static Privacy LoadPrivacy()
        {
            PrivacyList privacies = new PrivacyList();

            privacies.Load();
            Privacy privacy = privacies.FirstOrDefault(p => p.Description == "Public");

            return(privacy);
        }
예제 #5
0
 public void Unblock(S22.Xmpp.Jid jid)
 {
     this.AssertValid();
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     if (this.block.Supported)
     {
         this.block.Unblock(jid);
     }
     else
     {
         PrivacyList privacyList        = null;
         string      defaultPrivacyList = this.im.GetDefaultPrivacyList();
         if (defaultPrivacyList != null)
         {
             privacyList = this.im.GetPrivacyList(defaultPrivacyList);
         }
         foreach (PrivacyList list2 in this.im.GetPrivacyLists())
         {
             if (list2.Name == "blocklist")
             {
                 privacyList = list2;
             }
         }
         if (privacyList != null)
         {
             ISet <JidPrivacyRule> set = new HashSet <JidPrivacyRule>();
             foreach (PrivacyRule rule in privacyList)
             {
                 if (rule is JidPrivacyRule)
                 {
                     JidPrivacyRule item = rule as JidPrivacyRule;
                     if (!(!(item.Jid == jid) || item.Allow))
                     {
                         set.Add(item);
                     }
                 }
             }
             foreach (JidPrivacyRule rule3 in set)
             {
                 privacyList.Remove(rule3);
             }
             if (privacyList.Count == 0)
             {
                 this.im.SetDefaultPrivacyList(null);
                 this.im.RemovePrivacyList(privacyList.Name);
             }
             else
             {
                 this.im.EditPrivacyList(privacyList);
                 this.im.SetDefaultPrivacyList(privacyList.Name);
             }
         }
     }
 }
예제 #6
0
        public void Delete()
        {
            PrivacyList privacys = new PrivacyList();

            privacys.Load();

            Privacy privacy = privacys.FirstOrDefault(p => p.Description == "TestUpdate");

            int rowsAffected = privacy.Delete();

            Assert.IsTrue(rowsAffected == 1);
        }
예제 #7
0
        public void LoadById()
        {
            PrivacyList privacys = new PrivacyList();

            privacys.Load();
            Privacy privacy = new Privacy();


            privacy.LoadById(privacys.FirstOrDefault(p => p.Description == "Test").Id);

            Assert.AreEqual("Test", privacy.Description);
        }
예제 #8
0
        // GET: Privacy
        public ActionResult Index()
        {
            User userin = System.Web.HttpContext.Current.Session["user"] as User;

            if (userin == null || userin.UserTypeDescription != "Admin")
            {
                return(RedirectToAction("Index", "Home"));
            }

            privacies = new PrivacyList();
            privacies.Load();
            return(View(privacies));
        }
예제 #9
0
 /// <summary>
 /// Blocks all communication to and from the XMPP entity with the specified JID.
 /// </summary>
 /// <param name="jid">The JID of the XMPP entity to block.</param>
 /// <exception cref="ArgumentNullException">The jid parameter is
 /// null.</exception>
 /// <exception cref="NotSupportedException">The server does not support the
 /// 'Blocking Command' extension and does not support privacy-list management.
 /// </exception>
 /// <exception cref="XmppErrorException">The server returned an XMPP error code.
 /// Use the Error property of the XmppErrorException to obtain the specific
 /// error condition.</exception>
 /// <exception cref="XmppException">The server returned invalid data or another
 /// unspecified XMPP error occurred.</exception>
 /// <exception cref="InvalidOperationException">The XmppClient instance is
 /// not connected to a remote host.</exception>
 /// <exception cref="ObjectDisposedException">The XmppClient object
 /// has been disposed.</exception>
 public void Block(Jid jid)
 {
     AssertValid();
     jid.ThrowIfNull("jid");
     // If our server supports the 'Blocking Command' extension, we can just
     // use that.
     if (block.Supported)
         block.Block(jid);
     else
     {
         // Privacy list blocking. If our server doesn't support privacy lists, we're
         // out of luck.
         PrivacyList privacyList = null;
         string name = im.GetDefaultPrivacyList();
         if (name != null)
             privacyList = im.GetPrivacyList(name);
         // If no default list has been set, look for a 'blocklist' list.
         foreach (var list in im.GetPrivacyLists())
         {
             if (list.Name == "blocklist")
                 privacyList = list;
         }
         // If 'blocklist' doesn't exist, create it and set it as default.
         if (privacyList == null)
             privacyList = new PrivacyList("blocklist");
         privacyList.Add(new JidPrivacyRule(jid, false, 0), true);
         // Save the privacy list and activate it.
         im.EditPrivacyList(privacyList);
         im.SetDefaultPrivacyList(privacyList.Name);
         im.SetActivePrivacyList(privacyList.Name);
     }
 }
예제 #10
0
        public ActionResult Create(ProjectPrivaciesUserStatuses ppus, string returnurl)
        {
            //double check authentication
            if (Authenticate.IsAuthenticated())
            {
                try
                {
                    PrivacyList plist = new PrivacyList();
                    plist.Load();
                    ppus.Privacies = plist;
                    StatusList slist = new StatusList();
                    slist.Load();
                    ppus.Statuses = slist;
                    if (ppus.SelectedLanguages == null)
                    {
                        ppus.SelectedLanguages = new List <string>();
                    }
                    ProjectList Projects  = new ProjectList();
                    User        userin    = System.Web.HttpContext.Current.Session["user"] as User;
                    string      username  = userin.Username;
                    string      strUserID = userin.Id.ToString();
                    ppus.Project.UserId    = userin.Id;
                    ppus.Project.UserEmail = userin.Email;

                    Projects.LoadbyUser(userin);

                    if (ppus.Project.Name == null)
                    {
                        ModelState.AddModelError(string.Empty, "Project requires a name!");
                    }
                    else
                    {
                        foreach (Project p in Projects)
                        {
                            if (ppus.Project.Name == p.Name)
                            {
                                ModelState.AddModelError(string.Empty, "Project name already exists!");
                            }
                        }

                        if (ppus.DateCreated == null)
                        {
                            ModelState.AddModelError(string.Empty, "Date Created required!");
                        }
                        else if (ppus.LastUpdated == null)
                        {
                            ppus.LastUpdated = ppus.DateCreated;
                        }
                    }

                    UploadedImage ui = new UploadedImage
                    {
                        FilePath   = ppus.Project.Image,
                        Fileupload = ppus.Fileupload,
                        UserName   = username,
                        ObjectType = "Project",
                        ObjectName = ppus.Project.Name
                    };

                    UploadedZip uz = new UploadedZip
                    {
                        FilePath    = ppus.Project.Filepath,
                        Fileupload  = ppus.Fileupload,
                        UserName    = username,
                        ProjectName = ppus.Project.Name
                    };

                    if (!ModelState.IsValid)
                    {
                        ppus.User = new User();
                        ppus.SelectedLanguages  = new List <string>();
                        ppus.AvailableLanguages = new List <SelectListItem>();
                        ppus.Languages          = new LanguageList();
                        ppus.Language           = new Language();
                        ppus.ProjectLanguage    = new ProjectLanguage();
                        ppus.ProjectLanguages   = new ProjectLanguageList();
                        ppus.User.LoadById(userin.Id);
                        ppus.Languages.Load();
                        ppus.AvailableLanguages = GetLanguages(ppus.Languages);
                        return(View(ppus));
                    }

                    string fp = ui.Upload();
                    // fp will return null if no upload file was choosen else use upload file to save to database
                    if (fp != null)
                    {
                        ppus.Project.Image = fp;
                    }
                    else
                    {
                        ppus.Project.Image = null;
                    }

                    fp = uz.Upload();
                    // fp will return null if no upload file was choosen else use upload file to save to database
                    if (fp != null)
                    {
                        ppus.Project.Filepath = fp;
                    }
                    else
                    {
                        ppus.Project.Filepath = null;
                    }

                    ppus.Project.Insert(ppus.SelectedLanguages);
                    return(RedirectToAction("EditProjects", "UserProfile", new { returnurl = HttpContext.Request.Url }));
                }
                catch { return(View(ppus)); }
            }
            else
            {
                return(RedirectToAction("Index", "Login", new { returnurl = HttpContext.Request.Url }));
            }
        }
예제 #11
0
        public ActionResult EditProject(Guid id, ScreenshotProjects ppus)
        {
            if (Authenticate.IsAuthenticated())
            {
                try
                {
                    ppus.Language  = new Language();
                    ppus.Languages = new LanguageList();

                    if (ppus.SelectedLanguages == null)
                    {
                        ppus.SelectedLanguages = new List <string>();
                    }

                    if (ppus.AvailableLanguages == null)
                    {
                        ppus.AvailableLanguages = new List <SelectListItem>();
                        if (ppus.Languages.Count < 1)
                        {
                            //Load Languages
                            ppus.Languages.Load();
                        }
                        else
                        {
                            // Languages already loaded
                        }
                        ppus.AvailableLanguages = GetLanguages(ppus.Languages);
                    }

                    PrivacyList plist = new PrivacyList();
                    plist.Load();
                    ppus.Privacies = plist;
                    StatusList slist = new StatusList();
                    slist.Load();

                    ppus.ProjectLanguage  = new ProjectLanguage();
                    ppus.ProjectLanguages = new ProjectLanguageList();
                    ppus.Statuses         = slist;
                    ppus.ScreenshotList   = new ScreenshotList();
                    ppus.ScreenshotList.LoadbyProjectID(id);
                    ppus.ProjectId = id;

                    // Deletes all languages associated with project currently
                    ppus.ProjectLanguages.LoadByProjectId(id);
                    foreach (ProjectLanguage pl in ppus.ProjectLanguages)
                    {
                        pl.Delete();
                    }

                    // Insert New languages parsed from input into ProjectLanguage table
                    foreach (var pl in ppus.SelectedLanguages)
                    {
                        ProjectLanguage projlang = new ProjectLanguage();
                        ppus.ProjectLanguage.ProjectId  = id;
                        ppus.ProjectLanguage.LanguageId = (Guid.Parse(pl));
                        ppus.ProjectLanguage.Insert();
                    }

                    User        userin   = System.Web.HttpContext.Current.Session["user"] as User;
                    ProjectList Projects = new ProjectList();
                    Projects.LoadbyUser(userin);
                    string username  = userin.Username;
                    string strUserID = userin.Id.ToString();

                    if (ppus.Project.Name == null)
                    {
                        ModelState.AddModelError(string.Empty, "Project requires a name!");
                    }
                    else
                    {
                        foreach (Project p in Projects)
                        {
                            if (ppus.Project.Name == p.Name)
                            {
                                if (ppus.Project.Id != p.Id)
                                {
                                    ModelState.AddModelError(string.Empty, "Another project already exists with this name!");
                                }
                            }
                        }

                        if (ppus.DateCreated == null)
                        {
                            ModelState.AddModelError(string.Empty, "Date Created required!");
                        }
                        else if (ppus.LastUpdated == null)
                        {
                            ppus.LastUpdated = ppus.DateCreated;
                        }
                    }
                    UploadedZip zu = new UploadedZip
                    {
                        FilePath    = ppus.Project.Filepath,
                        Fileupload  = ppus.ZipFileupload,
                        UserName    = username,
                        ProjectName = ppus.Project.Name
                    };
                    UploadedImage ui = new UploadedImage
                    {
                        FilePath   = ppus.Project.Image,
                        Fileupload = ppus.Fileupload,
                        UserName   = username,
                        ObjectType = "Project",
                        ObjectName = ppus.Project.Name
                    };


                    if (!ModelState.IsValid)
                    {
                        ppus.Languages          = new LanguageList();
                        ppus.SelectedLanguages  = new List <string>();
                        ppus.AvailableLanguages = new List <SelectListItem>();
                        ppus.Privacies          = new PrivacyList();
                        ppus.Statuses           = new StatusList();
                        ppus.User = new User();
                        ppus.User.LoadById(userin.Id);
                        ppus.Privacies.Load();
                        ppus.Statuses.Load();
                        ppus.Languages.Load();
                        ppus.AvailableLanguages = GetLanguages(ppus.Languages);
                        return(View(ppus));
                    }
                    string fp = ui.Upload();
                    string zp = zu.Upload();
                    // fp will return null if no upload file was choosen else use upload file to save to database
                    if (fp != null)
                    {
                        ppus.Project.Image = fp;
                    }
                    else
                    {
                        ppus.Project.Image = null;
                    }

                    if (zp != null)
                    {
                        ppus.Project.Filepath = zp;
                    }
                    else
                    {
                        ppus.Project.Filepath = null;
                    }

                    ppus.Project.DateCreated = ppus.DateCreated;
                    ppus.Project.LastUpdated = ppus.LastUpdated;
                    ppus.Project.Update();
                    return(RedirectToAction("EditProjects", "UserProfile"));
                }
                catch { return(View(ppus)); }
            }
            else
            {
                return(RedirectToAction("Index", "Login", new { returnurl = HttpContext.Request.Url }));
            }
        }
예제 #12
0
        public ActionResult EditPortfolio(Guid id, UserProfile up)
        {
            if (Authenticate.IsAuthenticated())
            {
                try
                {
                    User          userin     = System.Web.HttpContext.Current.Session["user"] as User;
                    PortfolioList Portfolios = new PortfolioList();
                    Portfolios.LoadbyUser(userin);
                    up.Portfolios = Portfolios;
                    ProjectList projects = new ProjectList();
                    projects.LoadbyPortfolioID(id);
                    PrivacyList privacies = new PrivacyList();
                    privacies.Load();
                    up.Privacies = privacies;
                    up.Projects  = projects;
                    string username = userin.Username;

                    if (up.Portfolio.Name == null)
                    {
                        ModelState.AddModelError(string.Empty, "Portfolio requires a name!");
                    }
                    else
                    {
                        foreach (Portfolio p in Portfolios)
                        {
                            if (up.Portfolio.Name == p.Name)
                            {
                                if (up.Portfolio.Id != p.Id)
                                {
                                    ModelState.AddModelError(string.Empty, "Another portfolio already exists with this name!");
                                }
                            }
                        }
                    }
                    UploadedImage ui = new UploadedImage
                    {
                        FilePath   = up.Portfolio.PortfolioImage,
                        Fileupload = up.Fileupload,
                        UserName   = username,
                        ObjectType = "Portfolio",
                        ObjectName = up.Portfolio.Name
                    };

                    string fp = ui.Upload();

                    // fp will return null if no upload file was choosen else use upload file to save to database
                    if (fp != null)
                    {
                        up.Portfolio.PortfolioImage = fp;
                    }
                    else
                    {
                        up.Portfolio.PortfolioImage = null;
                    }

                    if (!ModelState.IsValid)
                    {
                        up.Privacies = new PrivacyList();
                        up.User      = new User();
                        up.User.LoadById(userin.Id);
                        up.Privacies.Load();
                        up.Projects.LoadbyPortfolioID(up.Portfolio.Id);
                        return(View(up));
                    }
                    up.Portfolio.Update();
                    return(RedirectToAction("EditPortfolios"));
                }
                catch { return(View(up)); }
            }
            else
            {
                return(RedirectToAction("Index", "Login", new { returnurl = HttpContext.Request.Url }));
            }
        }