Ejemplo n.º 1
0
        private static int GetOrCreateDiscussionId(
            ISession session,
            int accountid,
            Type type,
            int objectid,
            ManagedSecurityContext sec)
        {
            Discussion d = Find(session, accountid, type, objectid, sec);

            if (d != null)
            {
                return(d.Id);
            }

            ManagedDiscussionMapEntry mapentry = ManagedDiscussionMap.Find(type);

            TransitDiscussion td = new TransitDiscussion();

            td.AccountId    = accountid;
            td.Name         = mapentry.Name;
            td.Personal     = true;
            td.Description  = string.Empty;
            td.Created      = td.Modified = DateTime.UtcNow;
            td.ObjectId     = objectid;
            td.DataObjectId = ManagedDataObject.Find(session, type);

            // creating a discussion that belongs to a different user (commenting on someone's items)
            ManagedDiscussion      m_d   = new ManagedDiscussion(session);
            ManagedSecurityContext o_sec = new ManagedSecurityContext(session, accountid);

            return(m_d.CreateOrUpdate(td, o_sec));
        }
Ejemplo n.º 2
0
        public static bool TryFind(DataObject dataobject, out ManagedDiscussionMapEntry result)
        {
            result = null;
            if (dataobject == null)
            {
                return(false);
            }
            CreateTypeMap();
            Type t = Assembly.GetAssembly(typeof(DataObject)).GetType(dataobject.Name, true);

            return(s_GlobalTypeMap.TryGetValue(t, out result));
        }
Ejemplo n.º 3
0
        public static int GetOrCreateDiscussionId(
            ISession session,
            string typename,
            int objectid,
            ManagedSecurityContext sec)
        {
            ManagedDiscussionMapEntry mapentry = ManagedDiscussionMap.Find(
                Assembly.GetAssembly(typeof(Account)).GetType(typename));
            // find the owner's account id
            int account_id = mapentry.GetAccountId(session, objectid);

            return(GetOrCreateDiscussionId(session, account_id, mapentry.Type, objectid, sec));
        }
Ejemplo n.º 4
0
        public override ACL GetACL(Type type)
        {
            ManagedDiscussionMapEntry mapentry = null;
            ACL acl = null;

            if (mInstance.Personal && ManagedDiscussionMap.TryFind(mInstance.DataObject, out mapentry))
            {
                acl = mapentry.GetACL(Session, mInstance.ObjectId, typeof(Discussion));
            }
            else
            {
                acl = base.GetACL(type);
                acl.Add(new ACLEveryoneAllowRetrieve());
            }

            acl.Add(new ACLAccount(mInstance.Account, DataOperation.All));
            return(acl);
        }
Ejemplo n.º 5
0
        public override ACL GetACL(Type type)
        {
            ManagedDiscussionMapEntry mapentry = null;
            ACL acl = null;

            if (mInstance.Discussion.Personal && ManagedDiscussionMap.TryFind(mInstance.Discussion.DataObject, out mapentry))
            {
                acl = mapentry.GetACL(Session, mInstance.Discussion.ObjectId, typeof(DiscussionThread));
            }
            else
            {
                acl = base.GetACL(type);
                acl.Add(new ACLEveryoneAllowRetrieve());
                acl.Add(new ACLAuthenticatedAllowCreate());
            }

            return(acl);
        }
Ejemplo n.º 6
0
 public static bool TryFind(Type type, out ManagedDiscussionMapEntry result)
 {
     CreateTypeMap();
     return s_GlobalTypeMap.TryGetValue(type, out result);
 }
Ejemplo n.º 7
0
 public static bool TryFind(DataObject dataobject, out ManagedDiscussionMapEntry result)
 {
     result = null;
     if (dataobject == null) return false;
     CreateTypeMap();
     Type t = Assembly.GetAssembly(typeof(DataObject)).GetType(dataobject.Name, true);
     return s_GlobalTypeMap.TryGetValue(t, out result);
 }
Ejemplo n.º 8
0
 public static bool TryFind(ISession session, int dataobject_id, out ManagedDiscussionMapEntry result)
 {
     DataObject dataobject = session.Load<DataObject>(dataobject_id);
     return TryFind(dataobject, out result);
 }
Ejemplo n.º 9
0
 public static bool TryFind(Type type, out ManagedDiscussionMapEntry result)
 {
     CreateTypeMap();
     return(s_GlobalTypeMap.TryGetValue(type, out result));
 }
Ejemplo n.º 10
0
        public static bool TryFind(ISession session, int dataobject_id, out ManagedDiscussionMapEntry result)
        {
            DataObject dataobject = session.Load <DataObject>(dataobject_id);

            return(TryFind(dataobject, out result));
        }