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


PHP Users_Privileges_Model::setSharedOwnerRecursively方法代码示例

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


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

示例1: handleEvent

 function handleEvent($eventName, $entityData)
 {
     global $adb, $shared_owners;
     if ($eventName == 'vtiger.entity.aftersave.final' && $shared_owners == true) {
         $moduleName = $entityData->getModuleName();
         $recordId = $entityData->getId();
         $vtEntityDelta = new VTEntityDelta();
         $delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
         $shownerids = $entityData->get('shownerid');
         $inheritsharing = $entityData->get('inheritsharing');
         if (array_key_exists("shownerid", $delta)) {
             $usersUpadated = TRUE;
             $oldValue = Vtiger_Functions::getArrayFromValue($delta['shownerid']['oldValue']);
             $currentValue = Vtiger_Functions::getArrayFromValue($delta['shownerid']['currentValue']);
             $addUsers = $currentValue;
             $removeUser = array_diff($oldValue, $currentValue);
         } else {
             $usersUpadated = FALSE;
         }
         $updateRelatedRecords = TRUE;
         if (array_key_exists("inheritsharing", $delta)) {
             $inheritsharing = $delta['inheritsharing']['currentValue'];
             $inheritsharingUpdated = TRUE;
             if ('0' === $delta['inheritsharing']['currentValue']) {
                 $updateRelatedRecords = FALSE;
                 $removedShared = TRUE;
             }
         } else {
             $inheritsharingUpdated = FALSE;
             $inheritsharing = $entityData->get('inheritsharing');
             if (!$inheritsharing) {
                 $updateRelatedRecords = FALSE;
             }
         }
         if ($usersUpadated || $inheritsharingUpdated) {
             if ($updateRelatedRecords) {
                 Users_Privileges_Model::setSharedOwnerRecursively($recordId, $addUsers, $removeUser, $moduleName);
             }
             if ($removedShared) {
                 Users_Privileges_Model::setSharedOwnerRecursively($recordId, [], $addUsers, $moduleName);
             }
         }
     }
     if ($eventName == 'vtiger.entity.link.after' && $shared_owners == true && Vtiger_Processes_Model::getConfig('sales', 'popup', 'update_shared_permissions') == 'true') {
         $destinationModule = array('Products', 'Services');
         if ($entityData['sourceModule'] == 'Potentials' && in_array($entityData['destinationModule'], $destinationModule)) {
             $adb = PearDatabase::getInstance();
             $result1 = $adb->pquery('SELECT smownerid, shownerid FROM vtiger_crmentity WHERE crmid = ?;', array($entityData['destinationRecordId']));
             $result2 = $adb->pquery('SELECT shownerid FROM vtiger_crmentity WHERE crmid = ?;', array($entityData['sourceRecordId']));
             if ($adb->num_rows($result1) == 1 && $adb->num_rows($result2) == 1) {
                 $smownerid = $adb->query_result($result1, 0, 'smownerid') . ',' . $adb->query_result($result1, 0, 'shownerid');
                 $shownerid = $adb->query_result($result2, 0, 'shownerid') . ',' . trim($smownerid, ',');
                 $adb->pquery("UPDATE vtiger_crmentity SET shownerid = ? WHERE crmid = ?;", [trim($shownerid, ','), $entityData['sourceRecordId']]);
             }
         }
     }
 }
开发者ID:rcrrich,项目名称:YetiForceCRM,代码行数:57,代码来源:SharingPrivileges.php

示例2: handleEvent

 function handleEvent($eventName, $entityData)
 {
     if ($eventName == 'vtiger.entity.aftersave.final' && vglobal('shared_owners') == true) {
         $moduleName = $entityData->getModuleName();
         $recordId = $entityData->getId();
         $vtEntityDelta = new VTEntityDelta();
         $delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
         if (array_key_exists('assigned_user_id', $delta)) {
             $usersUpadated = TRUE;
             $oldValue = Vtiger_Functions::getArrayFromValue($delta['assigned_user_id']['oldValue']);
             $currentValue = Vtiger_Functions::getArrayFromValue($delta['assigned_user_id']['currentValue']);
             $addUsers = $currentValue;
             $removeUser = array_diff($oldValue, $currentValue);
             Users_Privileges_Model::setSharedOwnerRecursively($recordId, $addUsers, $removeUser, $moduleName);
         }
     }
 }
开发者ID:nikdejan,项目名称:YetiForceCRM,代码行数:17,代码来源:SharingPrivileges.php

示例3: handleEvent

 function handleEvent($eventName, $entityData)
 {
     if ($eventName == 'vtiger.entity.aftersave.final' && vglobal('shared_owners') == true) {
         $moduleName = $entityData->getModuleName();
         $recordId = $entityData->getId();
         $vtEntityDelta = new VTEntityDelta();
         $delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
         if (array_key_exists('assigned_user_id', $delta)) {
             $usersUpadated = TRUE;
             $oldValue = Vtiger_Functions::getArrayFromValue($delta['assigned_user_id']['oldValue']);
             $currentValue = Vtiger_Functions::getArrayFromValue($delta['assigned_user_id']['currentValue']);
             $addUsers = $currentValue;
             $removeUser = array_diff($oldValue, $currentValue);
             Users_Privileges_Model::setSharedOwnerRecursively($recordId, $addUsers, $removeUser, $moduleName);
         }
     }
     if ($eventName == 'vtiger.entity.link.after' && vglobal('shared_owners') == true && Vtiger_Processes_Model::getConfig('sales', 'popup', 'update_shared_permissions') == 'true') {
         $destinationModule = ['Products', 'Services'];
         if ($entityData['sourceModule'] == 'Potentials' && in_array($entityData['destinationModule'], $destinationModule)) {
             $db = PearDatabase::getInstance();
             $sourceRecordId =& $entityData['sourceRecordId'];
             $destinationRecordId =& $entityData['destinationRecordId'];
             $recordMetaData = Vtiger_Functions::getCRMRecordMetadata($sourceRecordId);
             $shownerIds = Vtiger_SharedOwner_UIType::getSharedOwners($sourceRecordId, $entityData['sourceModule']);
             $shownerIds[] = $recordMetaData['smownerid'];
             $shownerIds = array_unique($shownerIds);
             $usersExist = [];
             $shownersTable = Vtiger_SharedOwner_UIType::getShownerTable($entityData['destinationModule']);
             $result = $db->pquery('SELECT crmid, userid FROM ' . $shownersTable . ' WHERE userid IN(' . implode(',', $shownerIds) . ') AND crmid = ?', [$destinationRecordId]);
             while ($row = $db->getRow($result)) {
                 $usersExist[$row['crmid']][$row['userid']] = true;
             }
             foreach ($shownerIds as $userId) {
                 if (!isset($usersExist[$destinationRecordId][$userId])) {
                     $db->insert($shownersTable, ['crmid' => $destinationRecordId, 'userid' => $userId]);
                 }
             }
         }
     }
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:40,代码来源:SharingPrivileges.php

示例4: handleEvent

 function handleEvent($eventName, $data)
 {
     global $adb, $shared_owners;
     if ($eventName == 'vtiger.entity.aftersave.final' && $shared_owners == true) {
         $moduleName = $data->getModuleName();
         $recordId = $data->getId();
         if ($data->get('inheritsharing') != NULL && $data->get('inheritsharing') !== 0) {
             $vtEntityDelta = new VTEntityDelta();
             $delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
             if (array_key_exists("shownerid", $delta)) {
                 $oldValue = Vtiger_Functions::getArrayFromValue($delta['shownerid']['oldValue']);
                 $currentValue = Vtiger_Functions::getArrayFromValue($delta['shownerid']['currentValue']);
                 if (count($oldValue) == 0) {
                     $addUser = $currentValue;
                     $removeUser = array();
                 } else {
                     $removeUser = array_diff($oldValue, $currentValue);
                     $addUser = array_diff($currentValue, $oldValue);
                 }
                 Users_Privileges_Model::setSharedOwnerRecursively($recordId, $addUser, $removeUser, $moduleName);
             }
         }
     }
     if ($eventName == 'vtiger.entity.link.after') {
         $destinationModule = array('Products', 'Services');
         if ($entityData['sourceModule'] == 'Potentials' && in_array($entityData['destinationModule'], $destinationModule)) {
             global $adb;
             $result1 = $adb->pquery('SELECT smownerid FROM vtiger_crmentity WHERE crmid = ?;', array($entityData['destinationRecordId']));
             $result2 = $adb->pquery('SELECT smownerid,shownerid FROM vtiger_crmentity WHERE crmid = ?;', array($entityData['sourceRecordId']));
             if ($adb->num_rows($result1) == 1 && $adb->num_rows($result2) == 1) {
                 $smownerid = $adb->query_result($result1, 0, 'smownerid');
                 $shownerid = $adb->query_result($result2, 0, 'shownerid') . ',' . $smownerid;
                 if ($smownerid != $adb->query_result($result2, 0, 'smownerid')) {
                     $adb->pquery("UPDATE vtiger_crmentity SET shownerid = ? WHERE crmid = ?;", array(rtrim($shownerid, ','), $entityData['sourceRecordId']));
                 }
             }
         }
     }
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:39,代码来源:SharingPrivileges.php


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