/** * Get Patron Profile * * This is responsible for retrieving the profile for a specific patron. * * @param array|User $patron The patron array * * @return mixed Array of the patron's profile data on success, * PEAR_Error otherwise. * @access public */ public function getMyProfile($patron) { /** @var Memcache $memCache */ global $memCache; global $serverName; $memCacheProfileKey = "patronProfile_{$serverName}_"; if (is_object($patron)) { $memCacheProfileKey .= $patron->username; } else { $memCacheProfileKey .= $patron['username']; } $forceReload = isset($_REQUEST['reload']); if (!$forceReload && $memCacheProfileKey) { $cachedValue = $memCache->get($memCacheProfileKey); if (!$cachedValue) { $forceReload = true; } // when not found in memcache turn on reload to short-circuit redundant memcache checks in each of the ILS drivers for getMyProfile() } if ($forceReload) { $profile = $this->driver->getMyProfile($patron, $forceReload); if (PEAR_Singleton::isError($profile)) { // echo("Error loading profile " . print_r($profile, true)); return $profile; } $profile['readingHistorySize'] = ''; global $user; if ($user && $user->trackReadingHistory && $user->initialReadingHistoryLoaded) { require_once ROOT_DIR . '/sys/ReadingHistoryEntry.php'; $readingHistoryDB = new ReadingHistoryEntry(); $readingHistoryDB->userId = $user->id; $readingHistoryDB->deleted = 0; $profile['readingHistorySize'] = $readingHistoryDB->count(); } $cachedValue = $profile; global $configArray; $memCacheResult = $memCache->replace($memCacheProfileKey, $cachedValue, 0, $configArray['Caching']['patron_profile']); // Update the existing key } return $cachedValue; }