Package com.ikanow.infinit.e.data_model.store.social.community

Examples of com.ikanow.infinit.e.data_model.store.social.community.CommunityApprovePojo


      if (0 == sendTo.length()) {
        throw new RuntimeException("community " + c.getName() + " / " + c.getId() + " has no owner/moderator");
      }
     
      //create a community request and post to db
      CommunityApprovePojo cap = new CommunityApprovePojo();
      cap.set_id(new ObjectId());
      cap.setCommunityId( c.getId().toString() );
      cap.setIssueDate(new Date());
      cap.setPersonId(owner.get_id().toString());
      cap.setRequesterId(p.get_id().toString());
      cap.setType("source");
      cap.setSourceId(source.getId().toString());
      DbManager.getSocial().getCommunityApprove().insert(cap.toDb());   
     
      // Message Body
      String body = "<p>" + p.getDisplayName() + " has requested that the following source be " +
        "added to the " + c.getName() + " community:</p>" +
        "<p>" +
        "Title: " + source.getTitle() + "<br/>" +
        "Description: " + source.getDescription() + "<br/>" +
        "URL (eg): " + source.getRepresentativeUrl() + "<br/>" +
        "</p>" +
        "<p>Please click on the Approve or Reject links below to complete the approval process: </p>" +
        "<li><a href=\"" + rootUrl + "social/community/requestresponse/" + cap.get_id().toString() + "/true\">Approve new Source</a></li>" +
        "<li><a href=\"" + rootUrl + "social/community/requestresponse/" + cap.get_id().toString() + "/false\">Reject new Source</a></li>";             
     
      // Send
      new SendMail(new PropertiesManager().getAdminEmailAddress(), sendTo.toString(), subject, body).send("text/html")
    }
    return true;
View Full Code Here


                // Caleb: this means change update to $set
                /////////////////////////////////////////////////////////////////////////////////////////////////
                DbManager.getSocial().getCommunity().update(query, cp.toDb());
                             
                //send email out to owner for approval
                CommunityApprovePojo cap = cp.createCommunityApprove(personIdStr,communityIdStr,"join",personIdStr);
                DbManager.getSocial().getCommunityApprove().insert(cap.toDb());
               
                // Get to addresses for Owner and Moderators
                String toAddresses = getToAddressesFromCommunity(cp);
               
                PropertiesManager propManager = new PropertiesManager();
                String rootUrl = propManager.getUrlRoot();
               
                String subject = pp.getDisplayName() + " is trying to join infinit.e community: " + cp.getName();
                String body = pp.getDisplayName() + " is trying to join infinit.e community: " + cp.getName() + "<br/>Do you want to accept this request?" +
                "<br/><a href=\"" + rootUrl + "social/community/requestresponse/"+cap.get_id().toString() + "/true\">Accept</a> " +
                "<a href=\"" + rootUrl + "social/community/requestresponse/"+cap.get_id().toString() + "/false\">Deny</a>";
               
                SendMail mail = new SendMail(new PropertiesManager().getAdminEmailAddress(), toAddresses, subject, body);
               
                if (mail.send("text/html"))
                {
View Full Code Here

                  // Caleb: this means change update to $set
                  /////////////////////////////////////////////////////////////////////////////////////////////////
                  DbManager.getSocial().getCommunity().update(query, cp.toDb());
                 
                  //send email out inviting user
                  CommunityApprovePojo cap = cp.createCommunityApprove(personIdStr,communityIdStr,"invite",userIdStr);
                  DbManager.getSocial().getCommunityApprove().insert(cap.toDb());
                 
                  PropertiesManager propManager = new PropertiesManager();
                  String rootUrl = propManager.getUrlRoot();
                 
                  if (null == rootUrl) {
                    rp.setResponse(new ResponseObject("Invite Community",false,"The system was unable to email the invite because an invite was required and root.url is not set up."));
                    return rp;
                  }
                 
                  String subject = "Invite to join infinit.e community: " + cp.getName();
                  String body = "You have been invited to join the community " + cp.getName() +
                    "<br/><a href=\"" + rootUrl + "social/community/requestresponse/"+cap.get_id().toString() + "/true\">Accept</a> " +
                    "<a href=\"" + rootUrl + "social/community/requestresponse/"+cap.get_id().toString() + "/false\">Deny</a>";
                 
                  SendMail mail = new SendMail(new PropertiesManager().getAdminEmailAddress(), pp.getEmail(), subject, body);
                 
                  if (mail.send("text/html"))
                  {
                    if (isSysAdmin) {
                      rp.setResponse(new ResponseObject("Invite Community",true,"Invited user to community successfully: " + cap.get_id().toString()));
                    }
                    else {
                      rp.setResponse(new ResponseObject("Invite Community",true,"Invited user to community successfully"));                 
                    }
                  }
View Full Code Here

        // Attempt to retrieve the invite from the social.communityapprove collection
        DBObject dbo = DbManager.getSocial().getCommunityApprove().findOne(new BasicDBObject("_id", new ObjectId(requestIdStr)));
       
        if (dbo != null )
        {
          CommunityApprovePojo cap = CommunityApprovePojo.fromDb(dbo, CommunityApprovePojo.class);
          if ( cap.getType().equals("source"))
          {
            //approving a source
            if ( resp.equals("true"))
            {
              rp = sourceHandler.approveSource(cap.getSourceId(), cap.getCommunityId(), cap.getRequesterId());
            }
            else
            {
              rp = sourceHandler.denySource(cap.getSourceId(), cap.getCommunityId(), cap.getRequesterId());
            }
            if ( rp.getResponse().isSuccess() )
            {
              //remove request object now
              DbManager.getSocial().getCommunityApprove().remove(new BasicDBObject("_id",new ObjectId(requestIdStr)));
            }
          }
          else
          {
            //approving a user joining a community
            BasicDBObject query = new BasicDBObject("_id",new ObjectId(cap.getCommunityId()));
            DBObject dboComm = DbManager.getSocial().getCommunity().findOne(query);
           
            //get user
            BasicDBObject queryPerson = new BasicDBObject("_id",new ObjectId(cap.getPersonId()));
            DBObject dboperson = DbManager.getSocial().getPerson().findOne(queryPerson);
            PersonPojo pp = PersonPojo.fromDb(dboperson, PersonPojo.class);
           
            if ( dboComm != null )
            {
              CommunityPojo cp = CommunityPojo.fromDb(dboComm, CommunityPojo.class);
              boolean isStillPending = isMemberPending(cp, pp);
              //make sure the user is still waiting to join the community, otherwise remove this request and return
              if ( isStillPending )
              {
                if ( resp.equals("false"))
                {
                  //if response is false (deny), always just remove user from community             
                  cp.removeMember(new ObjectId(cap.getPersonId()));
                  /////////////////////////////////////////////////////////////////////////////////////////////////
                  // TODO (INF-1214): Make this code more robust to handle changes to the community that need to
                  // Caleb: this means change update to $set
                  /////////////////////////////////////////////////////////////////////////////////////////////////
                  DbManager.getSocial().getCommunity().update(query, cp.toDb());
                }
                else
                {
                  //if response is true (allow), always just add community info to user, and change status to active
                 
                  if ( dboperson != null)
                  {
                    cp.updateMemberStatus(cap.getPersonId(), "active");
                    cp.setNumberOfMembers(cp.getNumberOfMembers()+1);
                    /////////////////////////////////////////////////////////////////////////////////////////////////
                    // TODO (INF-1214): Make this code more robust to handle changes to the community that need to
                    // Caleb: this means change update to $set
                    /////////////////////////////////////////////////////////////////////////////////////////////////
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.data_model.store.social.community.CommunityApprovePojo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.