コード例 #1
0
ファイル: utils.php プロジェクト: yunter/crm
/** Function to get a user id or group id for a given entity
 * @param $record -- entity id :: Type integer
 * @returns $ownerArr -- owner id :: Type array
 */
function getRecordOwnerId($record)
{
    global $log;
    $log->debug("Entering getRecordOwnerId(" . $record . ") method ...");
    global $adb;
    $ownerArr = array();
    // Look at cache first for information
    $ownerId = VTCacheUtils::lookupRecordOwner($record);
    if ($ownerId === false) {
        $query = "select smownerid from vtiger_crmentity where crmid = ?";
        $result = $adb->pquery($query, array($record));
        if ($adb->num_rows($result) > 0) {
            $ownerId = $adb->query_result($result, 0, 'smownerid');
            // Update cache for re-use
            VTCacheUtils::updateRecordOwner($record, $ownerId);
        }
    }
    if ($ownerId) {
        // Look at cache first for information
        $count = VTCacheUtils::lookupOwnerType($ownerId);
        if ($count === false) {
            $sql_result = $adb->pquery("select count(*) as count from vtiger_users where id = ?", array($ownerId));
            $count = $adb->query_result($sql_result, 0, 'count');
            // Update cache for re-use
            VTCacheUtils::updateOwnerType($ownerId, $count);
        }
        if ($count > 0) {
            $ownerArr['Users'] = $ownerId;
        } else {
            $ownerArr['Groups'] = $ownerId;
        }
    }
    $log->debug("Exiting getRecordOwnerId method ...");
    return $ownerArr;
}
コード例 #2
0
ファイル: utils.php プロジェクト: nikdejan/YetiForceCRM
/** Function to get a user id or group id for a given entity
 * @param $record -- entity id :: Type integer
 * @returns $ownerArr -- owner id :: Type array
 */
function getRecordOwnerId($record)
{
    $log = vglobal('log');
    $log->debug("Entering getRecordOwnerId(" . $record . ") method ...");
    $adb = PearDatabase::getInstance();
    $ownerArr = [];
    $recordMetaData = Vtiger_Functions::getCRMRecordMetadata($record);
    if ($recordMetaData) {
        $ownerId = $recordMetaData['smownerid'];
        // Look at cache first for information
        $count = VTCacheUtils::lookupOwnerType($ownerId);
        if ($count === false) {
            $sql_result = $adb->pquery("select count(*) as count from vtiger_users where id = ?", array($ownerId));
            $count = $adb->query_result($sql_result, 0, 'count');
            // Update cache for re-use
            VTCacheUtils::updateOwnerType($ownerId, $count);
        }
        if ($count > 0) {
            $ownerArr['Users'] = $ownerId;
        } else {
            $ownerArr['Groups'] = $ownerId;
        }
    }
    $log->debug("Exiting getRecordOwnerId method ...");
    return $ownerArr;
}