Показать сообщение отдельно
Старый 06.09.2006, 13:19   #8  
oip is offline
oip
Axapta
Лучший по профессии 2014
 
2,564 / 1416 (53) ++++++++
Регистрация: 28.11.2005
Записей в блоге: 1
Исправил кое-что:
X++:
public void new(anytype _p1)
{
    // custom RLS, OIP, 05.09.06 -->
    int                     i,j,k;
    QueryBuildRange         r;
    QueryBuilddatasource    ds;
    QueryBuilddatasource    childDS;
    QueryBuilddatasource    intDS;
    QueryBuilddatasource    restrictDS;
    Query                   q;
    SysRecordLevelSecurity  RLSTable;
    Query                   restriction;
    userGroupId             groupId;
    userGroupList           groupList;
    // custom RLS, OIP, 05.09.06 <--
    if (_p1)
    {
        super (_p1);

        if (this.args() &&
            !this.args().caller() &&
            typeOf(_p1) == Types::Class &&
            !SysdictClass::isEqualOrSuperClass(classidget(_p1), classNum(Query)))
        {
            this.args().caller(_p1);
        }

        // custom RLS, OIP, 05.09.06 -->
        q = this.query();
        for(i=1; i<= q.dataSourceCount(); i++)
        {
            ds = q.dataSourceNo(i);
            while select RLSTable
                where RLSTable.tabId == ds.table()
                join groupList
                where   groupList.groupId == RLSTable.groupId &&
                        groupList.userId  == curUserId()
            {
                if(RLSTable.restriction != conNull() &&
                   sysQuery::isPackedOk(RLSTable.restriction))
                {
                    restriction = new QueryRun(RLSTable.restriction).query();
                    if(restriction.dataSourceCount()>1)
                    {
                        for(j=2;j<= restriction.dataSourceCount();j++)
                        {
                            restrictDS = restriction.dataSourceNo(j);
                            intDS = restrictDS.parentDataSource();
                            if (!SysQuery::tableOccurrence(q, restrictDS.table(), q.dataSourceCount()))
                            {
                                childDS = q.dataSourceTable(intDS.table()).addDataSource(restrictDS.table());
                                childDS.relations(true);
                                childDS.joinMode(JoinMode::ExistsJoin);
                                childDS.fetchMode(QueryFetchMode::One2One);
                            }
                            else
                            {
                                childDS = q.dataSourceTable(restrictDS.table());
                            }
                            for(k=1;k<=restrictDS.rangeCount();k++)
                            {
                                r = restrictDS.range(k);
                                SysQuery::findOrCreateRange(childDs, r.field()).value(r.value());
                            }
                        }
                    }
                }
            }
        }
    }
    // custom RLS, OIP, 05.09.06 <--

    loadLastUsedQuery   = true;
    saveQueryPrUser     = true;
    allowSave           = true;
    allowAddRange       = QueryAllowAdd::AllFields;
    allowAddSorting     = QueryAllowAdd::AllFields;
    showSorting         = true;
}

Последний раз редактировалось oip; 06.09.2006 в 15:11.