示例#1
0
/** Depricated. Function to be replaced by getUserProfile()
 * Should be done accross the product
 *
 */
function fetchUserProfileId($userid)
{
    global $log;
    $log->debug("Entering fetchUserProfileId(" . $userid . ") method ...");
    // Look up information in cache first
    $profileid = VTCacheUtils::lookupUserProfileId($userid);
    if ($profileid === false) {
        global $adb;
        $query = "SELECT profileid FROM vtiger_role2profile WHERE roleid=(SELECT roleid FROM vtiger_user2role WHERE userid=?)";
        $result = $adb->pquery($query, array($userid));
        if ($result && $adb->num_rows($result)) {
            $profileid = $adb->query_result($result, 0, 'profileid');
            // TODO: What if there are multiple profile to one role?
        }
        // Update information to cache for re-use
        VTCacheUtils::updateUserProfileId($userid, $profileid);
    }
    $log->debug("Exiting fetchUserProfileId method ...");
    return $profileid;
}