Beispiel #1
0
        /// <summary>
        /// Modify rights associated with specified fields.
        /// </summary>
        /// <param name="rights">Rights object to modify.</param>
        /// <remarks>Use this method to change rights across fine-grained fields of information.</remarks>
        public void ModifyFieldRights(SuperOffice.CRM.Security.FieldRights rights)
        {
            if (!Constants.EnableContact)
            {
                return;
            }

            _rightsManager.SignalEvent(Constants.SentryName.DevNet, Constants.SentryEntities.Contact, SentryState.BeforeModified, rights);

            if (_sunIsNotShining)
            {
                rights[QueryInfo.MainTable.TextId] = RightsFactory.Get(EFieldRight.None, "But one can still modify department");
            }

            _rightsManager.SignalEvent(Constants.SentryName.DevNet, Constants.SentryEntities.Contact, SentryState.AfterModified, rights);
        }
        /// <summary>
        /// Modify table rights.
        /// </summary>
        /// <param name="rights">Rights object to modify.</param>
        /// <remarks>Set everything to read only if department ends with '_'
        /// unless the current user is the owner.
        /// </remarks>
        public void ModifyTableRights(TableRights rights)
        {
            //get the value of the Dept
            string department = GetFieldValue(QueryInfo.MainTable.Department) as string;

            //check to see dept value not empty, ans the value ends with a
            //"_" and the logged in user is not the owner.
            if (!string.IsNullOrEmpty(department) &&
                department.Trim().EndsWith("_") &&
                _sentry.GetRecordOwnershipIndex() != EOwnershipIndex.Owner)
            {
                //modify the rights
                foreach (TableInfo ti in rights.Keys.ToArray())
                {
                    rights[ti] = rights[ti] & RightsFactory.Get(ETableRight.R,
                                                                "make all read only since dept value ends with '_'");
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Modify rights associated with specified tables.
        /// </summary>
        /// <param name="rights">Rights object to modify.</param>
        /// <remarks>Use this method to change rights across related blocks of information, i.e. table-wide rights.</remarks>
        public void ModifyTableRights(SuperOffice.CRM.Security.TableRights rights)
        {
            if (!Constants.EnableContact)
            {
                _rightsManager.SignalEvent(Constants.SentryName.DevNet, Constants.SentryEntities.Contact, "Contact sentry not enabled!");
                return;
            }

            try
            {
                _rightsManager.SignalEvent(Constants.SentryName.DevNet, Constants.SentryEntities.Contact, SentryState.BeforeModified, rights);

                string department = GetFieldValue(QueryInfo.MainTable.Department) as string;
                if (!string.IsNullOrEmpty(department) && department.Trim().EndsWith("_") && _sentry.GetRecordOwnershipIndex() != EOwnershipIndex.Owner)
                {
                    _rightsManager.SignalEvent(Constants.SentryName.DevNet, Constants.SentryEntities.Contact, "Updating Contact!");

                    _sunIsNotShining = true;
                    TableRights newRights = new TableRights();
                    foreach (TableInfo ti in rights.Keys)
                    {
                        newRights[ti] = rights[ti] & RightsFactory.Get(ETableRight.R, "The sun is not shining on trailing '_'");
                    }

                    foreach (TableInfo ti in newRights.Keys)
                    {
                        rights[ti] = newRights[ti];
                    }
                }
                else
                {
                    _sunIsNotShining = false;
                }

                _rightsManager.SignalEvent(Constants.SentryName.DevNet, Constants.SentryEntities.Contact, SentryState.AfterModified, rights);
            }
            catch (Exception e)
            {
                _rightsManager.SignalEvent(Constants.SentryName.DevNet, Constants.SentryEntities.Contact, e.GetBaseException().Message);
                throw;
            }
        }