当前位置: 首页>>代码示例>>PHP>>正文


PHP DBObjectSearch::AddCondition_ReferencedBy方法代码示例

本文整理汇总了PHP中DBObjectSearch::AddCondition_ReferencedBy方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObjectSearch::AddCondition_ReferencedBy方法的具体用法?PHP DBObjectSearch::AddCondition_ReferencedBy怎么用?PHP DBObjectSearch::AddCondition_ReferencedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBObjectSearch的用法示例。


在下文中一共展示了DBObjectSearch::AddCondition_ReferencedBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: MakeSelectFilter

 /**
  *	...
  */
 public function MakeSelectFilter($sClass, $aAllowedOrgs, $aSettings = array(), $sAttCode = null)
 {
     if ($sAttCode == null) {
         $sAttCode = $this->GetOwnerOrganizationAttCode($sClass);
     }
     if (empty($sAttCode)) {
         return $oFilter = new DBObjectSearch($sClass);
     }
     $oExpression = new FieldExpression($sAttCode, $sClass);
     $oFilter = new DBObjectSearch($sClass);
     $oListExpr = ListExpression::FromScalars($aAllowedOrgs);
     $oCondition = new BinaryExpression($oExpression, 'IN', $oListExpr);
     $oFilter->AddConditionExpression($oCondition);
     if ($this->HasSharing()) {
         if ($sAttCode == 'id' && isset($aSettings['bSearchMode']) && $aSettings['bSearchMode']) {
             // Querying organizations (or derived)
             // and the expected list of organizations will be used as a search criteria
             // Therefore the query can also return organization having objects shared with the allowed organizations
             //
             // 1) build the list of organizations sharing something with the allowed organizations
             // Organization <== sharing_org_id == SharedObject having org_id IN {user orgs}
             $oShareSearch = new DBObjectSearch('SharedObject');
             $oOrgField = new FieldExpression('org_id', 'SharedObject');
             $oShareSearch->AddConditionExpression(new BinaryExpression($oOrgField, 'IN', $oListExpr));
             $oSearchSharers = new DBObjectSearch('Organization');
             $oSearchSharers->AllowAllData();
             $oSearchSharers->AddCondition_ReferencedBy($oShareSearch, 'sharing_org_id');
             $aSharers = array();
             foreach ($oSearchSharers->ToDataArray(array('id')) as $aRow) {
                 $aSharers[] = $aRow['id'];
             }
             // 2) Enlarge the overall results: ... OR id IN(id1, id2, id3)
             if (count($aSharers) > 0) {
                 $oSharersList = ListExpression::FromScalars($aSharers);
                 $oFilter->MergeConditionExpression(new BinaryExpression($oExpression, 'IN', $oSharersList));
             }
         }
         $aShareProperties = SharedObject::GetSharedClassProperties($sClass);
         if ($aShareProperties) {
             $sShareClass = $aShareProperties['share_class'];
             $sShareAttCode = $aShareProperties['attcode'];
             $oSearchShares = new DBObjectSearch($sShareClass);
             $oSearchShares->AllowAllData();
             $sHierarchicalKeyCode = MetaModel::IsHierarchicalClass('Organization');
             $oOrgField = new FieldExpression('org_id', $sShareClass);
             $oSearchShares->AddConditionExpression(new BinaryExpression($oOrgField, 'IN', $oListExpr));
             $aShared = array();
             foreach ($oSearchShares->ToDataArray(array($sShareAttCode)) as $aRow) {
                 $aShared[] = $aRow[$sShareAttCode];
             }
             if (count($aShared) > 0) {
                 $oObjId = new FieldExpression('id', $sClass);
                 $oSharedIdList = ListExpression::FromScalars($aShared);
                 $oFilter->MergeConditionExpression(new BinaryExpression($oObjId, 'IN', $oSharedIdList));
             }
         }
     }
     // if HasSharing
     return $oFilter;
 }
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:63,代码来源:userrights.class.inc.php


注:本文中的DBObjectSearch::AddCondition_ReferencedBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。